k8s 给服务设置https访问

k8s 给服务设置https访问

查看Pod

 kubectl get pods -n <名称空间名> 

查看 Ingress 配置

kubectl get ingresses -n <ingress 名> 

查看 Ingress 相关Pod的分布情况

kubectl get pod -o wide -n ingress-nginx 

查看 Ingress Pod 的配置文件

kubectl get pod nginx-ingress-controller-fvcvx -o yaml -n ingress-nginx 

查看 Ingress 的配置文件

kubectl get ing -o yaml -n po-ams 

编辑 Ingress 配置文件

kubectl edit ing -n po-ams  编辑的命令是 kubectl edit ing -n po-ams   

查看日志

kubectl logs -n po-ams po-ams-ser-6cdcd79b4d-xmsnm 

配置ingress https 访问

  • 利用证书申请下来的公钥和私钥 创建secret密钥
kubectl create secret tls tls-secret --key tls.key --cert tls.crt
  • 编辑 Ingress 配置文件
kubectl edit ing -n po-ams
spec:
  tls: # 创建tls
    - hosts: # 下面指定域名 
      - nginx.itheima.com
      - tomcat.itheima.com
      secretName: tls-secret # 指定秘钥  

保存

  • 查看转发规则
[root@k8s-master01 ~]# kubectl describe ing ingress-https -n dev
...
TLS:
  tls-secret terminates nginx.itheima.com,tomcat.itheima.com 
Rules:
Host              Path Backends
----              ---- --------
nginx.itheima.com  /  nginx-service:80 (10.244.1.97:80,10.244.1.98:80,10.244.2.119:80)
tomcat.itheima.com /  tomcat-service:8080(10.244.1.99:8080,10.244.2.117:8080,10.244.2.120:8080)
...
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值