k8s Nginx-ingress配置https
Posted 青衫解衣
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s Nginx-ingress配置https相关的知识,希望对你有一定的参考价值。
官网:
https://kubernetes.github.io/ingress-nginx/examples/auth/client-certs/
创建证书:
说明:测试发现指定namespace和默认default都行,和namespace没有关系,证书放在当前目录下即可。
kubectl create secret tls test-cc --key=test.sit.51zhaoyou.com.key --cert=test.sit.51zhaoyou.com.pem
kubectl create secret tls test.sit.51zhaoyou.com --key=test.sit.51zhaoyou.com.key --cert=test.sit.51zhaoyou.com.pem -n nginx-example
查看证书:
# kubectl describe secrets -n nginx-example
关联service:
https主要是下面几行。
[root@master ~]# cat test-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
namespace: nginx-example
name: nginx-test
spec:
tls:
- hosts:
- test.sit.51zhaoyou.com
secretName: test-cc
rules:
- host: test.sit.51zhaoyou.com
http:
paths:
- path: /
backend:
serviceName: my-nginx
servicePort: 80
查看ingress:
[root@master ~]# kubectl get ing -A
NAMESPACE NAME HOSTS ADDRESS PORTS AGE
nginx-example nginx-test test.sit.51zhaoyou.com 80, 443 20m
绑定本地host文件:
Windows:
192.168.1.15 test.sit.51zhaoyou.com
浏览器访问:
以上是关于k8s Nginx-ingress配置https的主要内容,如果未能解决你的问题,请参考以下文章
k8s集群通过nginx-ingress做tcpudp 4层网络转发
如何使用一个负载均衡器为两个域的两个入口配置 nginx-ingress
如何使用 nginx-ingress 控制器通过 TCP 公开多个服务?