收到无法识别 "ingress.yaml" 的错误:版本“extensions/v1beta1 中的种类 "Ingress" 没有匹配项

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

我正在获取 helm chart class,第一个实验室创建了一个 pod、服务和入口。我对 k8s 比较陌生,我在 minikube 上 运行。 pod 和服务的创建没有问题;但是 ingress.yaml 文件给出了以下错误:

无法识别“ingress.yaml”:在版本“extensions/v1beta1

中没有匹配类型“Ingress”

我猜 ingress.yaml 文件中的某些内容已过时,但不知道如何修复它。这是 class 回购:

https://github.com/phcollignon/helm3

这是广告连播 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

这是 frontend_service.yaml :

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

这是问题文件 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%        

这里是 minikube 版本(kubectrl 版本):

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"}

非常感谢任何帮助。

我更改了 ingress.yaml 文件以使用 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

现在我收到一个错误:

错误:解析错误ingress.yaml:将 YAML 转换为 JSON 时出错:yaml:第 17 行:此上下文中不允许映射值

第 17 行是第二个“路径:”行。

再次感谢任何帮助。

入口规范 apiVersion: extensions/v1beta1 已弃用。您可以将其更新为 apiVersion: networking.k8s.io/v1

第二个问题:

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