Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert all kubernetes ingress yamls to use API version networking.k8s.io/v1

Kubernetes Ingress API version networking.k8s.io/v1 has lot of changes in fields wrt extensions/v1beta1 like the following:

* `spec.backend` -> `spec.defaultBackend`
* `serviceName` -> `service.name`
* `servicePort` -> `service.port.name` (for string values)
* `servicePort` -> `service.port.number` (for numeric values)
* `pathType` no longer has a default value in v1; "Exact", "Prefix", or "ImplementationSpecific" must be specified

What is the easiest way to convert all ingress yaml files from extensions/v1beta1 to networking.k8s.io/v1.

Looks like kubectl convert is already deprecated in v1.19.

Kubernetes version:

kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:30:33Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:23:04Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

Error while using kubectl convert:

kubectl convert -f ingress_4_10_1.yaml --output-version  networking.k8s.io/v1
kubectl convert is DEPRECATED and will be removed in a future version.
In order to convert, kubectl apply the object to the cluster, then kubectl get at the desired version.
error: networking.Ingress is not suitable for converting to "networking.k8s.io/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30"

My ingress yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: frontend
  annotations:
   kubernetes.io/ingress.class: "ing-class1"
spec:
  rules:
  - host:  frontend.com
    http:
      paths:
      - path: /web-frontend/frontend.php
        backend:
          serviceName: frontend
          servicePort: 80
like image 967
apoorva kamath Avatar asked Sep 07 '20 07:09

apoorva kamath


People also ask

What network is k8s IO v1?

Ingress [networking.k8s.io/v1] Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.

What is API version in Kubernetes?

Kubernetes apiVersionAn object definition in Kubernetes requires a apiVersion field. When Kubernetes has a release that updates what is available for you to use—changes something in its API—a new apiVersion is created.

Which ingress is used to route traffic from single IP to multiple services?

Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. Using an ingress controller and ingress rules, a single IP address can be used to route traffic to multiple services in a Kubernetes cluster.


Video Answer


2 Answers

It's not that difficult rewrite it by hand, for example:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend
  annotations:
   kubernetes.io/ingress.class: "ing-class1"
spec:
  rules:
  - host: frontend.com
    http:
      paths:
      - backend:
          service:
            name: frontend
            port:
              number: 80
        path: /web-frontend/frontend.php
        pathType: Exact
like image 141
navigaid Avatar answered Oct 17 '22 12:10

navigaid


Found a nice summary of the required changes in in https://cloud.google.com/kubernetes-engine/docs/deprecations/apis-1-22#ingress-v122

Field Change
spec.backend Renamed to spec.defaultBackend.
backend serviceName Renamed to service.name.
servicePort Numeric backend servicePort fields are renamed to service.port.number. String backend servicePort fields are renamed to service.port.name.
pathType Now required for each specified path. The value can be: Prefix, Exact, or ImplementationSpecific. To match the undefined v1beta1 behavior, use ImplementationSpecific.
like image 26
Peter G Avatar answered Oct 17 '22 13:10

Peter G