CKS lab failures

I am learning CKS - CLUSTER SETUP AND HARDENING, LABS – INGRESS – 2.

Ingress is failing (404 when accessing URLs) when ingress class is supplied. I tried to reproduce this couple of times and it consistently fails. I understand there are no ingressclasses, but why that is? According to the documentation a default ingress should be supplied if a specific ingress class is not in use. But I see no ingressclass configured.


controlplane ~ ➜ k get ingressclasses.networking.k8s.io -A
No resources found

I compared the lab provided solution with the one I created based on official documentation reference and the only difference I can see is the class not supplied in lab solution. Why that is?


controlplane ~ :heavy_multiplication_x: sdiff provided.yaml created.yaml
— <
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: ingress-wear-watch name: ingress-wear-watch
namespace: app-space <
annotations: annotations:
nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: “false” | namespace: app-space
spec: spec:
> ingressClassName: nginx
rules: rules:

  • http: - http:
    paths: paths:
    • path: /wear - path: /wear
      pathType: Prefix pathType: Prefix
      backend: backend:
      service: service:
      name: wear-service | name: wear-service
      port: | port:
      number: 8080 | number: 8080
    • path: /watch - path: /watch
      pathType: Prefix pathType: Prefix
      backend: backend:
      service: service:
      name: video-service | name: video-service
      port: | port:
      number: 8080 | number: 8080

Please, when pasting terminal content or code

use code blocks

The above is not legible because markdown has reformatted it.

Anyway, as you have seen, there are no ingress classes defined in the cluster. Therefore if you specify one in your ingress resource it will not be found so the ingress will not work.

The ingress controller that is installed in the cluster is the default one and will be selected when no ingressClassName is present.

A cluster only needs to have ingress classes defined if there is more than one ingress controller to choose from.