Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind “Ingress” in version “extensions/v1beta1″`)

To fix the error error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1 you need to set apiVersion to the networking.k8s.io/v1. From the Kubernetes v1.16 article about deprecated APIs:

  • NetworkPolicy in the extensions/v1beta1 API version is no longer served
    – Migrate to use the networking.k8s.io/v1 API version, available since v1.8. Existing persisted data can be retrieved/updated via the new version.

Now moving to the second issue. You need to add a few annotations and make few changes in your Ingress definition to make dashboard properly exposed on the microk8s cluster:

  • add nginx.ingress.kubernetes.io/rewrite-target: /$2 annotation
  • add nginx.ingress.kubernetes.io/configuration-snippet: | rewrite ^(/dashboard)$ $1/ redirect; annotation
  • change path: /dashboard to path: /dashboard(/|$)(.*)

We need them to properly forward the request to the backend pods – good explanation in this article:

Note: The “nginx.ingress.kubernetes.io/rewrite-target” annotation rewrites the URL before forwarding the request to the backend pods. In /dashboard(/|$)(.*) for path, (.*) stores the dynamic URL that’s generated while accessing the Kubernetes Dashboard. The “nginx.ingress.kubernetes.io/rewrite-target” annotation replaces the captured data in the URL before forwarding the request to the kubernetes-dashboard service. The “nginx.ingress.kubernetes.io/configuration-snippet” annotation rewrites the URL to add a trailing slash (“/”) only if ALB-URL/dashboard is accessed.

Also we need another two changes:

  • add nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" annotation to tell NGINX Ingress to communicate with Dashboard service using HTTPs
  • add kubernetes.io/ingress.class: public annotation to use NGINX Ingress created by microk8s ingress plugin

After implementing everything above, the final YAML file looks like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^(/dashboard)$ $1/ redirect;
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    kubernetes.io/ingress.class: public
  name: dashboard
  namespace: kube-system
spec:
  rules:
  - http:
      paths:
      - path: /dashboard(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: kubernetes-dashboard
            port:
              number: 443

It should work fine. No need to run microk8s proxy command.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)