use of com.marcnuri.yakc.api.apps.v1.AppsV1Api in project yakc by manusa.
the class WipIT method deployment.
@Test
void deployment() throws IOException {
final AppsV1Api api = KC.create(AppsV1Api.class);
final String deploymentName = "java-test";
try {
api.deleteNamespacedDeployment(deploymentName, "default").get();
System.out.println("Deployment created");
} catch (NotFoundException ex) {
System.out.println("Deployment not found, deletion not needed");
}
final Deployment deployment = api.createNamespacedDeployment("default", Deployment.builder().metadata(ObjectMeta.builder().name(deploymentName).build()).spec(DeploymentSpec.builder().replicas(1).selector(LabelSelector.builder().putInMatchLabels("k8s-app", "test-java").build()).template(PodTemplateSpec.builder().metadata(ObjectMeta.builder().name("java-test-pod").putInLabels("k8s-app", "test-java").build()).spec(PodSpec.builder().addToContainers(Container.builder().image("containous/whoami").name("java-test-pod").build()).build()).build()).build()).build()).get();
System.out.println(deployment);
api.patchNamespacedDeployment(deploymentName, "default", Deployment.builder().spec(deployment.getSpec().toBuilder().replicas(2).build()).build()).get();
final PodList selectedPodList = KC.create(CoreV1Api.class).listPodForAllNamespaces(new ListPodForAllNamespaces().labelSelector("k8s-app=test-pod")).get();
System.out.println(selectedPodList);
}
Aggregations