备考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 暴露应用实验完成

相关推荐
熊文豪10 小时前
openEuler 云原生实战:部署高性能 Redis 集群与压测分析
数据库·redis·云原生·openeuler
阿里云云原生11 小时前
阿里云微服务引擎 MSE 及 API 网关 2025 年 10 月产品动态
阿里云·微服务·云原生·云计算
Tadas-Gao12 小时前
MySQL存储架构解析:从数据无序到索引艺术的演进
数据库·分布式·mysql·微服务·云原生·架构
CV_J13 小时前
编写微服务api
微服务·云原生·架构
黑黍16 小时前
如何在k8s中配置并使用nvidia显卡
云原生·容器·kubernetes
没有口袋啦19 小时前
《云原生基础》
云原生
兮动人20 小时前
PrettyZoo:优雅易用的 ZooKeeper 可视化管理工具
分布式·zookeeper·云原生·prettyzoo
byte轻骑兵21 小时前
WSL+openEuler云原生实践:Docker全流程部署与多容器编排深度评测
docker·云原生·容器·openeuler
悠闲蜗牛�1 天前
智能时代技术融合之道:大模型、微服务与数据安全的系统化实践
微服务·云原生·架构
人生苦短1281 天前
Kubernetes(k8s)
云原生·容器·kubernetes