use of com.marcnuri.yakc.model.io.k8s.api.core.v1.PodList 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);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.PodList in project java by kubernetes-client.
the class ProtoExample method main.
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
ProtoClient pc = new ProtoClient(client);
ObjectOrStatus<PodList> list = pc.list(PodList.newBuilder(), "/api/v1/namespaces/default/pods");
if (list.object.getItemsCount() > 0) {
Pod p = list.object.getItems(0);
System.out.println(p);
}
Namespace namespace = Namespace.newBuilder().setMetadata(ObjectMeta.newBuilder().setName("test").build()).build();
ObjectOrStatus<Namespace> ns = pc.create(namespace, "/api/v1/namespaces", "v1", "Namespace");
System.out.println(ns);
if (ns.object != null) {
namespace = ns.object.toBuilder().setSpec(NamespaceSpec.newBuilder().addFinalizers("test").build()).build();
// This is how you would update an object, but you can't actually
// update namespaces, so this returns a 405
ns = pc.update(namespace, "/api/v1/namespaces/test", "v1", "Namespace");
System.out.println(ns.status);
}
ns = pc.delete(Namespace.newBuilder(), "/api/v1/namespaces/test");
System.out.println(ns);
}
Aggregations