Scaling StatefulSet filtered using label selectors
See original GitHub issueIs your enhancement related to a problem? Please describe
I’m trying scale a StatefulSet by selecting it using its labels. For example, kubectl allows following:
$ kubectl scale statefulset -l release=yb,app.kubernetes.io/name=yb-tserver --replicas=4
statefulset.apps/yb-yugabyte-yb-tserver scaled
But when we filter StatefulSets with label selectors, the scale()
method is not there.
Describe the solution you’d like
I’m thinking of something similar like this:
client
.apps()
.statefulSets()
.withLabel("release", "yb")
.withLabel(appLabel, "yb-tserver")
.scale(4);
Describe alternatives you’ve considered
So far I have tried using list()
, and then getting the first StatefulSet out of it. But when I tried to load the StatefulSet into client, the scale()
method was not present. So, I had to use the metadata.name
.
StatefulSet sts =
client
.apps()
.statefulSets()
.withLabel("release", "yb")
.withLabel(appLabel, "yb-tserver")
.list()
.getItems()
.get(0);
// This was not possible (should I create a separate issue for this?)
client.resource(sts).scale(4);
// I had to do this instead
client
.apps()
.statefulSets()
.withName(sts.getMetadata().getName())
.scale(4);
Additional context
When kubectl
finds multiple StatefulSets filtered the label selectors, it just scales all of them.
$ kubectl scale statefulset -l release=yb --replicas=4
statefulset.apps/yb-yugabyte-yb-master scaled
statefulset.apps/yb-yugabyte-yb-tserver scaled
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Labels and Selectors - Kubernetes
LIST and WATCH operations may specify label selectors to filter the sets of objects returned using a query parameter.
Read more >How to use "kubectl -l/--selector" to scale a specific pod in a ...
Follow the below command kubectl scale deployment/bla --replicas=2. Note: You cant scale pods. you can scale replicaSets/Deployments/ ...
Read more >Using Kubectl Scale | Tutorial and Best Practices - ContainIQ
The kubectl scale command is used to change the number of running replicas inside Kubernetes deployment, replica set, replication controller, and stateful set...
Read more >Use a StatefulSet to create a stateful application - Alibaba Cloud
Selector : Click Add to add pod labels. View Applications: Click View Applications and set the namespace and application in the dialog box...
Read more >Filtering Kubernetes Resources using Labels, Annotations ...
You can use labels, annotations, and selectors to manage metadata attached to your Kubernetes objects. Labels and annotations define the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s great, thanks! I have been away for a while, I will send PR for docs/example entry next week. With my PR we can close this issue.
a resources method was added with #3973