<p>Being new to Kubernetes, I am trying to make a simple .NET Core 3 MVC app run on Kubernetes and reply on port 443 as well as port 80. I have a working Docker-Compose setup which I am trying to port to Kubernetes.</p>

<p>Running Docker Desktop CE with nginx-ingress on Win 10 Pro.</p>

<p>So far it is working on port 80. (<a href="http://mymvc.local" rel="noreferrer">http://mymvc.local</a> on host Win 10 - hosts file redirects mymvc.local to 127.0.0.1)</p>

<p>My MVC app is running behind service mvc on port 5000.</p>

<p>I've made a self-signed certificate for the domain 'mymvc.local', which is working in the Docker-Compose setup.</p>

<p>This is my ingress file</p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: mvc-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  - hosts:
    - mymvc.local
    secretName: mvcsecret-tls
  rules:
    - host: mymvc.local
      http:
        paths:
        - path: /
          backend:
            serviceName: mvc
            servicePort: 5000
</code></pre>

<p>This is my secrets file (keys abbreviated):</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mvcsecret-tls
data:
  tls.crt: MIIDdzCCAl+gAwIBAgIUIok60uPHId5kve+/bZAw/ZGftIcwDQYJKoZIhvcNAQELBQAwKTELMAkGBxGjAYBgN...
  tls.key: MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDPGN6yq9yzxvDL8fEUJChqlnaTQW6bQX+H0...
type: kubernetes.io/tls
</code></pre>

<p>kubectl describes the ingress as follows:</p>

<pre><code>Name:             mvc-ingress
Namespace:        default
Address:          localhost
Default backend:  default-http-backend:80 (&lt;none&gt;)
TLS:
  mvcsecret-tls terminates mymvc.local
Rules:
  Host            Path  Backends
  ----            ----  --------
  mymvc.local
                  /   mvc:5000 (10.1.0.27:5000)
Annotations:
  kubernetes.io/ingress.class:                  nginx
  nginx.ingress.kubernetes.io/ssl-passthrough:  true
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  11m   nginx-ingress-controller  Ingress default/mvc-ingress
  Normal  UPDATE  11m   nginx-ingress-controller  Ingress default/mvc-ingress
</code></pre>

<p>In my Docker-Compose setup, I have an Nginx reverse proxy redirecting 80 and 443 to my MVC service, but I figured that is the role of ingress on Kubernetes?</p>

<p>My service YAML:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mvc
  labels:
    app: mymvc
spec:
  ports:
  - name: "mvc"
    port: 5000
    targetPort: 5000
  selector:
    app: mymvc
  type: ClusterIP
</code></pre>

<p><strong>EDIT:</strong>
Adding 'nginx.ingress.kubernetes.io/rewrite-target: /' to ingress annotations males the https forward work, but the certificate presented is the 'Kubernetes Ingress Controller Fake Certificate' - not my self-signed one.</p>

<p>The solution turned out to be the addition of a second kind of certificate.</p>

<p>Instead of using the secrets file above (where I pasted the contents of my certificates files), I issued kubectl to use my certificate files directly:</p>

<pre><code>kubectl create secret tls mvcsecret-tls --key MyCert.key --cert MyCert.crt
kubectl create secret generic tls-rootca --from-file=RootCA.pem
</code></pre>
