I want to update bunch of ingress.yaml files in my microservices project to use the new kubernetes API version. Currently the ingresses are using apiVersion: extensions/v1beta1
still.
I'm confused with the plugin (kubectl convert
) and the whole new binary (kubectl-convert
)... Which tool should I be using in 2023?
I would like to have a one liner command to update all ingress.yaml
files recursively inside current directory.
Maybe the new tool has some bugs in it? I'm getting this error with the bash script I assumed would work:
find . -name "ingress.yaml" | while read file; do kubectl-convert -f "$file" > "$file"; done
error: no objects passed to convert
I prefer to use kubectl convert
plugin and the following cmd should do the trick for you:
find . -name "ingress.yaml" | while read file; do kubectl convert -f "$file" --output-version networking.k8s.io/v1 > "$file".bak && mv "$file".bak "$file"; done
Tested locally on a set of 3 ingress.yaml file nested within different sub-folders.
I've assumed you're moving from extensions/v1beta1
to networking.k8s.io/v1
.
As is the general practice, make sure to back up your files before running this (or any such) command, in case of any unexpected issues.
Hope this helps.