Hi,
As title. An example would be:
CLI:
$ kubectl set image \
deployment/name \
-n namespace \
some_image:sometag \
--record
$ kubectl rollout history deployment/name
deployments "name"
REVISION CHANGE-CAUSE
1 kubectl set image deployment/name \
-n namespace some_image:sometag --record
2 <none>
API
...
try:
api_response = api_instance.patch_namespaced_deployment(name, namespace, body, pretty=pretty) # <- What should I submit in **kwargs ??
...
How do I do it API with CHANGE-CAUSE?
Got this resolved. Before calling patch_namespaced_deployment, the body should have annotation field kubernetes.io/change-cause. For example,
...
with open("/path/to/your/manifest.yml") as f:
for data in yaml.load_all(f):
if data is not None and data['kind'] == 'Deployment':
dep = data.copy()
k8s_beta = client.ExtensionsV1beta1Api()
dep['metadata']['annotations'] = {
'kubernetes.io/change-cause': 'kubectl set image deployment/{0} {0}={0}:{1} --record'.format("your-deployment-name", "tag-of-your-image")
}
resp = k8s_beta.patch_namespaced_deployment(name="your-deployment-name"],
body=dep, namespace="default")
...
Stole from CNCF @sebgoa CKA course 6.11.a. Deployment Rollbacks.
Most helpful comment
Got this resolved. Before calling
patch_namespaced_deployment, the body should have annotation fieldkubernetes.io/change-cause. For example,Stole from CNCF @sebgoa CKA course
6.11.a. Deployment Rollbacks.