I can get the ReplicaSet if given the replica-set-name
using the api as below:
GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}
But how can I get the ReplicaSet based on the deployment?
Any help is appreciated.
Thank you
I can get the ReplicaSet if given the replica-set-name
using the api as below:
GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}
But how can I get the ReplicaSet based on the deployment?
Any help is appreciated.
Thank you
But how can I get the ReplicaSet based on the deployment?
With quite some gymnastics... If you inspect how kubectl
does it (by executing kubectl -n my-namespace describe deploy my-deployment --v=9
) you will see that it dos the following:
/apis/extensions/v1beta1/namespaces/my-namespace/deployments/my-deployment
. From there it gets labels for replicaset selection. my-key1:my-value1
and my-key2:my-value2
) like so: /apis/extensions/v1beta1/namespaces/my-namespace/replicasets?labelSelector=my-key1%3Dmy-value1%2Cmy-key2%3Dmy-value2
Funny part here begins with extracting multiple labels from deployment output and formatting them for replicaset call, and that is task for grep, awk, jq or even python, depending on your actual use case (from bash, python, some client or whatever...)
© 2022 - 2024 — McMap. All rights reserved.