Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues migrating from v1beta to v1 for kubernetes ingress

In my firm our Kubernetes Cluster was recently updated to 1.22+ and we are using AKS. So I had to change the manifest of our ingress yaml file which was using : networking.k8s.io/v1beta1, to be compliant to the new apiVersion : networking.k8s.io/v1

This is the earlier manifest for the ingress file :

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "amroingress.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    {{- include "amroingress.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          #{{- range .paths }}
          #- path: {{ . }}
          #  backend:
          #    serviceName: {{ $fullName }}
          #    servicePort: {{ $svcPort }}
          #{{- end }}
          - path: /callista/?(.*)
            backend:
              serviceName: amro-amroingress
              servicePort: 8080
    {{- end }}
  {{- end }}

and after my changes it looks like this:

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "amroingress.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
{{- end }}
kind: Ingress
metadata:
  name: {{ include "amroingress.fullname" . }}
  labels:
    {{- include "amroingress.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: /callista/?(.*)
            pathType: Prefix
            backend:
              service:
                name: amro-amroingres
                port: 
                  number: 8080
    {{- end }}
  {{- end }}

But, after I made the changes and tried to deploy using helm, I receive this error: Error: UPGRADE FAILED: current release manifest contains removed kubernetes api(s) for this kubernetes version and it is therefore unable to build the kubernetes objects for performing the diff. error from kubernetes: unable to recognize "": no matches for kind "Ingress" in version "networking.k8s.io/v1beta1"

I am not sure why this error occurs even though the ingress manifest has changed and I have been stuck at this for a few days now. I am new to kubernetes and ingress in general, any help will be massively appreciated.

like image 538
Saurav Saha Avatar asked Oct 28 '25 22:10

Saurav Saha


1 Answers

The API resources on the Control plane are upgreaded but the ones in helm stored manifest (within a Secret resource) are old.

Here is the resolution:

$ helm plugin install https://github.com/helm/helm-mapkubeapis 
$ helm mapkubeapis my-release-name --namespace ns

After this run a helm upgrade again.

like image 123
shariqmaws Avatar answered Nov 01 '25 01:11

shariqmaws