-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get deployment resource #30
Comments
Do you mean something like the following: final Deployment deployment = new KubernetesClient().create(AppsV1Api.class)
.readNamespacedDeployment("$deploymentName", "$namespace").get();
deployment.getSpec().getReplicas();
deployment.getStatus().getAvailableReplicas();
deployment.getStatus().getReadyReplicas();
deployment.getStatus().getReplicas(); This is already possible. There are type definitions and API definitions for all vanilla Kubernetes types up to 1.19. |
I added a test suite for reference: Please, confirm if this is what you were looking for. |
@manusa Is there any kind of callback feature that allow me to implement a method in case replicas are changed? |
Yes, if you are familiar with RxJava or any other reactive library this should be easy and straightforward with the For example, the following code in the PodIT test blocks the current thread until a pod with a given name is created or a timeout occurs: yakc/tests/src/test/java/com/marcnuri/yakc/PodIT.java Lines 95 to 100 in f89668b
The following code might be useful as a starting-point/scaffold new KubernetesClient().create(AppsV1Api.class).listNamespacedDeployment("$namespace").watch()
.filter(we -> {
// Perform client side filtering
return we.getObject().getMetadata().getName().equals("$myWatchedDeployment");
})
.timeout(
// Add a timeout if you want (Check RxJava operations)
20, TimeUnit.SECONDS)
.subscribe(
// Perform actions for any event produced on the watched resources
deploymentWatchEvent -> {
switch (deploymentWatchEvent.getType()) {
case ADDED:
case MODIFIED: {
if (deploymentWatchEvent.getObject().getStatus().getAvailableReplicas().equals(desiredNumber)) {
// Do something
}
break;
}
case DELETED: {
break;
}
}
},
error -> {
// Do something when the watch connection breaks due to an exception
}
); The following recording shows how I'm doing something similar to what you need in the YAKC - Kubernetes Dashboard example (however things here are more complicated since stuff is happening in the front-end too). What you can see here is the user scaling up and down a deployment. There is an active subscription to Deployment changes, the UI reflects whenever the number of ready replicas matches those requested by the user by setting the ReplicaSet and Deployment green or red. |
Is there a feature planned tp get deployment resource definitions?
I would like to ask for the replicas coont.
The text was updated successfully, but these errors were encountered: