K8S 部署 ingress-nginx 配置 https
生成证书
mkdir cert && cd cert
# 生成私钥 tls.key, 密钥位数是 2048
openssl genrsa -out tls.key 2048
# 使用 tls.key 生成自签证书
openssl req -new -x509 -key tls.key -days 10000 -out tls.crt -subj /C=CN/ST=GuangDong/L=Guangzhou/O=DevOps/CN=boss.pcidata.com
创建secret
kubectl create secret tls boss-ingress-secret --cert=tls.crt --key=tls.key kubectl get secret kubectl describe secret boss-ingress-secret
配置ingress
vi ingress-boss-tls.yaml
# 内容为
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-boss-tls namespace: default annotations: kubernetes.io/ingress.class: "nginx" spec: tls: - hosts: - boss.pcidata.com secretName: boss-ingress-secret rules: - host: boss.pcidata.com http: paths: - path: backend: serviceName: sscp-page-management-svc servicePort: 9100
kubectl apply -f ingress-boss-tls.yaml
#查看ingress配置,这时会多了一个443端口
kubectl get ingress kubectl describe ingress ingress-boss-tls
# 浏览器访问
https://boss.pcidata.com/#/
如对您有帮助,支持下呗!
微信
支付宝