Bulk update all kubernetes deployment API version

4/4/2020

I am using apiversion : apps/v1beta2in most of deployment however Kubernetes cluster version 1.14 it's recommended to use apiversion : apps/v1. Also v1beta2 will be deprecated from Kubernetes 1.16.

Is there any better option to reduce manual work and update all deployment which having version apps/v1beta2 to v1.

Or I can use patch all deployment.

-- Harsh Manvar
google-kubernetes-engine
kubernetes

1 Answer

4/6/2020

Before you apply any changes please make sure that they include any necessary changes to suit the 1.16 version.

Some of the changes are:

Deployment in the extensions/v1beta1, apps/v1beta1, and apps/v1beta2 API versions is no longer served

  • Migrate to use the apps/v1 API version, available since v1.9. Existing persisted data can be retrieved/updated via the new version.
  • Notable changes:
    • spec.rollbackTo is removed
    • spec.selector is now required and immutable after creation; use the existing template labels as the selector for seamless upgrades
    • spec.progressDeadlineSeconds now defaults to 600 seconds (the default in extensions/v1beta1 was no deadline)
    • spec.revisionHistoryLimit now defaults to 10 (the default in apps/v1beta1 was 2, the default in extensions/v1beta1 was to retain all)
    • maxSurge and maxUnavailable now default to 25% (the default in extensions/v1beta1 was 1)

-- Kubernetes.io: API deprecations in 1.16

Please refer to above link to check aforementioned necessary changes.


kubectl patch

There is an official documentation about it: Kubernetes.io: update api object kubectl patch

Unfortunately the kubectl patch did change the YAML definition from the example but it was unable to change the apiVersion.


kubectl convert

There is a tool built into kubectl named kubectl convert which converts existing YAML to suit the 1.16 version. Please take in mind that it will be deprecated soon. Take a look at the article about it: Medium.com: Kubectl convert update api versions automatically


shell script

You could also write a script with the language of your choosing that will change:

  • apiVersion: apps/v1beta2
  • apiVersion: apps/v1beta1

to:

  • apiVersion: apps/v1

You could also take a look on: Github.com: Kustomize

Please let me know if you have any questions to that.

-- Dawid Kruk
Source: StackOverflow