<p>I've been struggling with my first kubernetes setup, and I can't work out where I've been going wrong. I have a .Net API that I've got working locally, and I can confirm that the Docker image runs without a problem locally. But when deployed into a Kubernetes service I only ever get a 404 from Nginx and that the certificate I have setup is invalid.</p>
<p>I'm hosted in azure, and am building and publishing to the ACR fine, and the deployment is being run by a CICD pipeline and pulling the correct image.</p>
<p>These are the files I have so far:
Deployment.yaml (the placeholders are pulled in by the CICD):</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mywebsite-api-deployment
spec:
  selector:
    matchLabels:
      app: mywebsite-api-pod
  template:
    metadata:
      labels:
        app: mywebsite-api-pod
    spec:
      containers:
      - name: mywebsite-api-container
        image: ${acrLoginServer}/${repository}:${imageTag}
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
        ports:
        - containerPort: 80
        imagePullPolicy: Always
</code></pre>
<p>service.yaml:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mywebsite-api-service
spec:
  selector:
    app: mywebsite-api-pod
  ports:
  - port: 80
    targetPort: 80
  type: ClusterIP
</code></pre>
<p>ingress.yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mywebsite-ingress
spec:
  tls:
  - hosts:
    - api-uat.mywebsite.com
    secretName: mywebsite-tls
  defaultBackend:
    service:
      name: mywebsite-api-service
      port:
        number: 80
  rules:
  - host: api-uat.mywebsite.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: mywebsite-api-service
            port:
              number: 80
</code></pre>
<p>secret:</p>
<pre><code>apiVersion: v1
data:
  tls.crt: /notpasted/
  tls.key: /notpasted/
kind: Secret
metadata:
  creationTimestamp: &quot;2023-06-06T17:47:27Z&quot;
  name: mywebsite-tls
  namespace: default
  resourceVersion: &quot;2795660&quot;
  uid: 
type: kubernetes.io/tls
</code></pre>
<p>The certificate I have is a wildcard, and I've pointed my DNS entry to the correct IP address, so I'm assuming that bit is configured correctly at least.</p>
<p>Any idea where I'm going wrong, the certificate being delivered by k8s is the standard Acme cert, and every request I make is returned with a 404. I'm not using Helm as it seemed overkill for this, but perhaps it's not?</p>
<p>Thank you for any advice.</p>

wombat172a
<p>Found the answer to this myself. I didn't understand how nginx was setup, and that it runs as a pod itself in a different namespace.</p>
<p>From that nginx pod, I could view the logs and identified the following entry:</p>
<pre><code>I0606 17:34:42.990421       8 store.go:425] &quot;Ignoring ingress because of error while validating ingress class&quot; ingress=&quot;default/mywebsite-ingress&quot; error=&quot;ingress does not contain a valid IngressClass&quot;
</code></pre>
<p>I could then run the following command to get the ingressClass name:
<code>kubectl get ingressclass -A -o yaml</code></p>
<pre><code>apiVersion: v1
items:
- apiVersion: networking.k8s.io/v1
  kind: IngressClass
  metadata:
    creationTimestamp: &quot;2023-06-04T11:38:58Z&quot;
    generation: 1
    name: webapprouting.kubernetes.azure.com
    resourceVersion: &quot;2997218&quot;
    uid: 8547e63e-30f7-4dfe-910b-2f7dce8884a3
  spec:
    controller: k8s.io/ingress-nginx
kind: List
metadata:
  resourceVersion: &quot;&quot;
  selfLink: &quot;&quot;
</code></pre>
<p>And that class name I just had to add to my ingress.yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mywebsite-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: webapprouting.kubernetes.azure.com
  tls:
  - hosts
  etc. etc.
</code></pre>
