河曲智叟 发表于 2024-6-10 10:16:23

K8S==ingress配置自签名证书

安装openssl

Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions
生成证书

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout example.local.key -out example.local.crt -subj "/CN=example.local/O=example.local"
创建K8S secret

kubectl create secret tls example-local-tls --key example.local.key --cert example.local.crt
检察
kubectl get secret example-local-tls -o yaml
https://img-blog.csdnimg.cn/direct/9cf790241b1a48b2ad31c454b1cbce4a.png

创建SSL转发

nginx-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: example.local
    http:
      paths:
      - path: /
      pathType: Prefix
      backend:
          service:
            name: nginx-service
            port:
            number: 80
tls:
- hosts:
    - example.local
    secretName: example-local-tls
kubectl apply -f nginx-ingress.yaml
访问

https://example.local/
https://img-blog.csdnimg.cn/direct/c6fb5205441f49a9a9f1d126ec2bda68.png
https://img-blog.csdnimg.cn/direct/7ff58a4f8f7949b59faddbc67df8a0ac.png


检察ingress转发日记

kubectl get pods -n ingress-nginx
kubectl logs -n ingress-nginx ingress-nginx-controller-5b5f8c9f5d-abcdef
https://img-blog.csdnimg.cn/direct/b102e63fe5b74aacaf7e5680ff8434f0.png



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: K8S==ingress配置自签名证书