<p>I create my secret in my cluster using this command</p>
<pre><code>kubectl create secret tls server --key server.key --cert server.crt
</code></pre>
<p>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</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
   name: alpha-ingress-srv
   annotations:
     kubernetes.io/ingress.class: &quot;nginx&quot;
     nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
     # nginx.ingress.kubernetes.io/ssl-certificate: &quot;fake-ssl-cert&quot;
     # nginx.ingress.kubernetes.io/ssl-certificate-key: &quot;fake-ssl-cert&quot;
     nginx.ingress.kubernetes.io/ssl-certificate: &quot;server&quot;
     nginx.ingress.kubernetes.io/ssl-certificate-key: &quot;server.key&quot;
spec:
   rules:
     - host: kavishkamk.live
       http:
          paths:
           - path: /api/users/?(.*)
             pathType: Prefix
             backend:
               service:
                 name: alpha-auth-srv
                 port:
                    number: 4000
</code></pre>

Kavishka Madhushan
<p>You just need to add the <code>tls</code> field to your spec:</p>
<pre><code>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
</code></pre>
