Reputation: 31
i'm trying to programmatically restart a Pod. First I've found some ways of doing this through the oc command line:
oc delete pod postgresql-2-wz989
oc rollout latest dc/postgresql
I think the second way is better because the deployment config name is static and doesn't change like the pod's name.
My question is how to do this using the Java Rest Client? It's not very clear to me how to use this client API.
Thanks in advance.
Upvotes: 1
Views: 2514
Reputation: 31
Taking into account the hint from Graham Dumpleton regarding the use of --loglevel=9
I got to a solution using the java client:
IClient client = new ClientBuilder("https://10.0.75.2:8443")
.withUserName("developer")
.withPassword("developer")
.build();
IProject project = client.getResourceFactory().stub(ResourceKind.PROJECT, "prj4testing");
IDeploymentConfig deploymentConfig = client.getResourceFactory().stub(ResourceKind.DEPLOYMENT_CONFIG, "postgresql", project.getName());
IDeploymentTriggerable capability = deploymentConfig.getCapability(IDeploymentTriggerable.class);
capability.setForce(true);
capability.setLatest(true);
capability.trigger();
I got to this solution through researching the source code from the client. I don't know if there are better ways to achieve this. Any comments are welcome.
Upvotes: 1