Search in sources :

Example 6 with CoreV1Api

use of com.marcnuri.yakc.api.core.v1.CoreV1Api in project yakc by manusa.

the class PodQuickstart method main.

public static void main(String[] args) {
    System.out.println("Complete POD example:\n" + " - Creates a namespace\n" + " - Deletes POD if exists\n" + " - Creates POD\n" + " - Patches POD's labels\n" + " - Updates POD removing annotations and adding another label\n" + "Starting...\n");
    try (KubernetesClient kc = new KubernetesClient()) {
        final CoreV1Api api = kc.create(CoreV1Api.class);
        final Disposable podMonitor = monitorPods(api);
        createNamespace(api);
        deletePodIfExists(api);
        createPod(api);
        final Pod patchedPod = patchPodLabels(api);
        System.out.printf("POD labels patched [%s]%n", patchedPod.getMetadata().getLabels());
        final Pod updatedPod = replacePod(patchedPod, api);
        System.out.printf("POD replaced: annotations removed, labels modified  [%s]%n", updatedPod.getMetadata().getLabels());
        podMonitor.dispose();
        System.out.println("Pod demo concluded successfully!");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) KubernetesClient(com.marcnuri.yakc.KubernetesClient) Pod(com.marcnuri.yakc.model.io.k8s.api.core.v1.Pod) CoreV1Api(com.marcnuri.yakc.api.core.v1.CoreV1Api) IOException(java.io.IOException) NotFoundException(com.marcnuri.yakc.api.NotFoundException)

Aggregations

CoreV1Api (com.marcnuri.yakc.api.core.v1.CoreV1Api)6 KubernetesClient (com.marcnuri.yakc.KubernetesClient)3 IOException (java.io.IOException)3 NotFoundException (com.marcnuri.yakc.api.NotFoundException)2 ApiextensionsV1Api (com.marcnuri.yakc.api.apiextensions.v1.ApiextensionsV1Api)1 DeleteCollectionNamespacedPod (com.marcnuri.yakc.api.core.v1.CoreV1Api.DeleteCollectionNamespacedPod)1 ListNamespacedSecret (com.marcnuri.yakc.api.core.v1.CoreV1Api.ListNamespacedSecret)1 ListNamespacedService (com.marcnuri.yakc.api.core.v1.CoreV1Api.ListNamespacedService)1 ListSecretForAllNamespaces (com.marcnuri.yakc.api.core.v1.CoreV1Api.ListSecretForAllNamespaces)1 ListServiceForAllNamespaces (com.marcnuri.yakc.api.core.v1.CoreV1Api.ListServiceForAllNamespaces)1 ReadNamespacedPodLog (com.marcnuri.yakc.api.core.v1.CoreV1Api.ReadNamespacedPodLog)1 Pod (com.marcnuri.yakc.model.io.k8s.api.core.v1.Pod)1 Disposable (io.reactivex.disposables.Disposable)1 ExecutorService (java.util.concurrent.ExecutorService)1