💻 Tech
To convert your k8s resource YAMLs files to another API version, install the convert
plugin first by following this.
For example, you have ingress-old.yaml
:
---
# Deprecated API version
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-space
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /video-service
pathType: Prefix
backend:
serviceName: ingress-svc
servicePort: 80
When you run k convert -f ingress-old.yaml --output-version=networking.k8s.io/v1 | k create -f -
, it converts this file to use the specified API group version networking.k8s.io/v1
and creates the resource with the converted YAML file read by the create
command from the standard input.
If you run the same convert command and redirect the output to a file (i.e., >
), you will see this YAML file with updated apiVersion
:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
creationTimestamp: null
name: ingress-space
spec:
rules:
- http:
paths:
- backend:
service:
name: ingress-svc
port:
number: 80
path: /video-service
pathType: Prefix
status:
loadBalancer: {}