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
CodePudding user response:
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