简体   繁体   中英

how use secrets in .yaml file in ingress

I create my secret in my cluster using this command

kubectl create secret tls server --key server.key --cert server.crt

I am using ingress-nginx for my deployment file and I want to use above secrete in.yaml file. Anyone know how can I use this

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
   name: alpha-ingress-srv
   annotations:
     kubernetes.io/ingress.class: "nginx"
     nginx.ingress.kubernetes.io/use-regex: "true"
     # nginx.ingress.kubernetes.io/ssl-certificate: "fake-ssl-cert"
     # nginx.ingress.kubernetes.io/ssl-certificate-key: "fake-ssl-cert"
     nginx.ingress.kubernetes.io/ssl-certificate: "server"
     nginx.ingress.kubernetes.io/ssl-certificate-key: "server.key"
spec:
   rules:
     - host: kavishkamk.live
       http:
          paths:
           - path: /api/users/?(.*)
             pathType: Prefix
             backend:
               service:
                 name: alpha-auth-srv
                 port:
                    number: 4000

You just need to add the tls field to your spec:

spec:
   tls:
   - hosts:
       - kavishkamk.live
     secretName: server   
   rules:
     - host: kavishkamk.live
       http:
          paths:
           - path: /api/users/?(.*)
             pathType: Prefix
             backend:
               service:
                 name: alpha-auth-srv
                 port:
                    number: 4000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM