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

相关推荐
小股虫3 小时前
分布式事务:在增长中台,我们如何做到“发出去的内容”和“记录的数据”不打架?
分布式·微服务·云原生·架构·团队建设·方法论
忧郁蓝调264 小时前
Redis不停机数据迁移:基于 redis-shake 的跨实例 / 跨集群同步方案
运维·数据库·redis·阿里云·缓存·云原生·paas
java1234_小锋5 小时前
ZooKeeper集群中服务器之间是怎样通信的?
分布式·zookeeper·云原生
easy_coder5 小时前
从“未知故障”到“自治诊断”:基于双路召回与RAG的智能诊断系统构建
人工智能·云原生·云计算
eddy-原6 小时前
ELKStack 与 Kubernetes 核心基础知识点综合作业
云原生·容器·kubernetes
无心水10 小时前
【神经风格迁移:工程化】27、神经风格迁移全栈进阶实战:Docker容器化与K8s部署,从单机到云原生
docker·云原生·架构·神经风格迁移·docker容器化·ai部署·vgg算法
victory043110 小时前
K8S 从Harbor当中拉取镜像 连接方法
云原生·容器·kubernetes
勇气要爆发11 小时前
Kubernetes (K8S):云时代的“超级舵手”
云原生·容器·kubernetes
杜子不疼.11 小时前
Spring Cloud Alibaba 微服务架构:注册中心 + 配置中心搭建
微服务·云原生·架构
大新新大浩浩11 小时前
ubuntu2204 + k8s 1.32.5 +GPU-Operator 24.9.2搭建GPU-k8s平台
云原生·容器·kubernetes