备考ICA----Istio实验13---使用 Istio Ingress 暴露应用

备考ICA----Istio实验13---使用Istio Ingress TLS暴露应用

1. 环境部署

清理之前实验遗留,并重新部署httpbin服务进行测试

bash 复制代码
# 清理之前的环境
kubectl delete vs httpbin
kubectl delete gw mygateway
# 部署httpbin
kubectl apply -f istio/samples/httpbin/httpbin.yaml 

确认应用被正确创建

bash 复制代码
kubectl get deployments,svc httpbin

2. 为httpbin创建ingress

创建一个ingress指向httpbin服务,测试服务本身是否正常

bash 复制代码
kubectl create ingress httpbin-ingress \
 --rule 'httpbin.example.com/status*=httpbin:8000' \
 --annotation kubernetes.io/ingress.class=istio

确认ingress被正确创建

bash 复制代码
kubectl get ingress

访问测试

bash 复制代码
curl -s -I -HHost:httpbin.example.com "http://192.168.126.220/status/200"

3. 为httpbin创建ingress TLS

通过IngressClass连接istio.io/ingresss-controller将流量转给httpbin服务

3.1 创建 Istio ingressclass

ingress/IngressClass.yaml

yaml 复制代码
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: istio
spec:
  controller: istio.io/ingress-controller

部署istio ingressclass

bash 复制代码
kubectl apply -f ingress/IngressClass.yaml

3.2 调用Istio Ingressclass

重建httpbin的ingress

bash 复制代码
kubectl delete ingress httpbin-ingress
kubectl create ingress httpbin-ingress \
 --rule 'httpbin.example.com/status*=httpbin:8000' \
 --class istio
kubectl get ingress

访问测试

bash 复制代码
curl -s -I -HHost:httpbin.example.com "http://192.168.126.220/status/200"

3.3 使用 TLS ingress

bash 复制代码
kubectl delete ingress httpbin-ingress
kubectl create secret tls httpbin-credential \
--key=example_certs_httpbin/httpbin.example.com.key \
--cert=example_certs_httpbin/httpbin.example.com.crt 
kubectl create ingress httpbin-ingress \
 --rule 'httpbin.example.com/status*=httpbin:8000,tls=httpbin-credential' \
 --class istio

确认hosts中存在httpbin.example.com的解析,访问测试

bash 复制代码
curl -k -vvv https://httpbin.example.com

可以看到证书已经被加载

到浏览器中查看证书详情,也是和我们之前生成并绑定的证书相符

至此备考ICA----Istio实验13---使用 Istio Ingress 暴露应用实验完成

相关推荐
步步为营DotNet10 小时前
.NET 11 中 Native AOT 在云原生场景下的深度剖析与实践
云原生·.net
xiaogg367810 小时前
Rancher2.0搭建kubernetes(K8S)集群
云原生·容器·kubernetes
蜀道山老天师12 小时前
Docker 实战教程:从基础流程到云桌面、Zabbix 监控、Portainer 可视化部署
运维·docker·云原生·容器·zabbix
qingy_204613 小时前
【架构师之路】绪论
微服务·云原生·架构
IT策士13 小时前
第 42 篇 k8s之日志管理:使用 EFK 或 Loki 采集日志
云原生·容器·kubernetes
无心水14 小时前
【Harness:落地实战】24、Harness CI/CD+GitOps深度实战:智能交付与渐进发布——企业级云原生DevOps全解析
人工智能·ci/cd·云原生·openclaw·harness·hermes·honcho
Plastic garden14 小时前
k8s(4)Kubernetes Pod 管控例子
云原生·容器·kubernetes
codeejun14 小时前
每日一Go-75、CI/CD 到 K8s:云原生ArgoCD / GitOps 全流程实战(Go + Gin)
ci/cd·云原生·golang
xingyuzhisuan15 小时前
异地多活聚合 API 架构:跨区域故障自动切换落地实践
微服务·云原生·架构
Clf丶忆笙15 小时前
搭建支持多语言开发的Quarkus环境:Java、Kotlin与Scala全栈指南
java·开发语言·云原生·kotlin·scala·quarkus