Home > other >  getting error unable to recognize "ingress.yaml": no matches for kind "Ingress"
getting error unable to recognize "ingress.yaml": no matches for kind "Ingress"

Time:03-24

I am taking a helm chart class and the 1st lab creates a pod, service and ingress. I am relatively new to k8s and I am running on minikube. The pod and service get created without issue; however the ingress.yaml file gives the following error:

unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1

I am guessing something is obsolete in the ingress.yaml file but have no idea how to fix it. here's the class repo:

https://github.com/phcollignon/helm3

here's the pod frontend.yaml :

apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend 
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
      - image: phico/frontend:1.0
        imagePullPolicy: Always
        name: frontend
        ports:
        - name: frontend
          containerPort: 4200

here's the frontend_service.yaml :

apiVersion: v1
kind: Service
metadata:
  labels:
    name: frontend
  name: frontend
spec:
  ports:
    - protocol: "TCP"
      port: 80
      targetPort: 4200
  selector:
    app: frontend

Here's the problem file ingress.yaml :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: guestbook-ingress
spec:
  rules:
  - host: frontend.minikube.local
    http:
      paths:
      - path: /
        backend:
          serviceName: frontend
          servicePort: 80
  - host: backend.minikube.local
    http:
      paths:
      - path: /
        backend:
          serviceName: backend
          servicePort: 80%        

Here's minikube version (kubectrl version) :

Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:38:33Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:34:54Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}

Any help is very much appreciated.

I changed the ingress.yaml file to use apiVersion: networking.k8s.io/v1:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: guestbook-ingress
spec:
  rules:
  - host: frontend.minikube.local
    http:
      paths:
      - path: /
        backend:
          service:
            name: frontend
            port:
              number: 80
  - host: backend.minikube.local
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: backend
            port:
              number: 80

now I am getting an error:

error: error parsing ingress.yaml: error converting YAML to JSON: yaml: line 17: mapping values are not allowed in this context

line 17 is the second "paths:" line.

Again, any help appreciated.

CodePudding user response:

Ingress spec apiVersion: extensions/v1beta1 has deprecated. You can update it to apiVersion: networking.k8s.io/v1

Second question:

kind: Ingress
metadata:
  name: guestbook-ingress
spec:
  rules:
  - host: frontend.minikube.local
    http:
      paths:
      - path: /
        pathType: Prefix  
        backend:
          service:
            name: frontend
            port:
              number: 80
  - host: backend.minikube.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: backend
            port:
              number: 80
  • Related