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

相关推荐
掘金-我是哪吒6 小时前
分布式微服务系统架构第150集:JavaPlus技术文档平台日更
分布式·微服务·云原生·架构·系统架构
技术管理修行7 小时前
【二】主流架构模式深度对比:单体、前后端分离与微服务
微服务·云原生·架构·服务发现·前后端分离·单体架构
进击的程序汪10 小时前
K8s 容器性能问题排查与诊断指南
云原生·容器·kubernetes
容器魔方11 小时前
HDC 2025丨华为云云原生剧透!智能驱动的全新一代AI-Native云原生基础设施
云原生·容器·云计算
2401_8532757312 小时前
对微服务的了解
微服务·云原生·架构
郝同学的测开笔记12 小时前
云原生探索系列(十九):Go 语言 context.Context
后端·云原生·go
掘金-我是哪吒16 小时前
分布式微服务系统架构第148集:JavaPlus技术文档平台日更
分布式·微服务·云原生·架构·系统架构
AKAMAI16 小时前
什么是云原生应用?
后端·云原生·云计算
爱瑞瑞16 小时前
震惊!k8s竟然是这么显示资源的使用情况的!
云原生·kubernetes
Mr_wilson_liu17 小时前
k8s的pod服务一直是Terminating状态,怎么强制杀掉
云原生·容器·kubernetes