Convert Figma logo to code with AI

fabric8io logokubernetes-client

Java client for Kubernetes & OpenShift

3,382
1,456
3,382
146

Top Related Projects

3,537

Official Java client library for kubernetes

6,694

Official Python client library for kubernetes

1,088

Officially supported dotnet Kubernetes Client library

Quick Overview

Fabric8 Kubernetes Client is a Java library for interacting with Kubernetes and OpenShift clusters. It provides a fluent DSL, allowing developers to easily create, read, update, and delete Kubernetes resources programmatically. The library supports both synchronous and asynchronous operations, making it versatile for various use cases.

Pros

  • Fluent and intuitive API design
  • Supports both Kubernetes and OpenShift
  • Extensive coverage of Kubernetes resources and operations
  • Automatic handling of authentication and connection management

Cons

  • Learning curve for developers new to Kubernetes concepts
  • Large dependency footprint
  • May require frequent updates to keep up with Kubernetes API changes
  • Limited support for some advanced Kubernetes features

Code Examples

Creating a Deployment:

try (KubernetesClient client = new DefaultKubernetesClient()) {
    client.apps().deployments().inNamespace("default")
        .createOrReplace(new DeploymentBuilder()
            .withNewMetadata().withName("nginx-deployment").endMetadata()
            .withNewSpec()
                .withReplicas(3)
                .withNewTemplate()
                    .withNewMetadata().addToLabels("app", "nginx").endMetadata()
                    .withNewSpec()
                        .addNewContainer()
                            .withName("nginx")
                            .withImage("nginx:1.14.2")
                            .addNewPort().withContainerPort(80).endPort()
                        .endContainer()
                    .endSpec()
                .endTemplate()
                .withNewSelector().addToMatchLabels("app", "nginx").endSelector()
            .endSpec()
            .build());
}

Watching Pods:

try (KubernetesClient client = new DefaultKubernetesClient()) {
    client.pods().inNamespace("default").watch(new Watcher<Pod>() {
        @Override
        public void eventReceived(Action action, Pod pod) {
            System.out.println("Pod " + pod.getMetadata().getName() + " " + action);
        }

        @Override
        public void onClose(WatcherException e) {
            System.out.println("Watch closed: " + e.getMessage());
        }
    });
}

Scaling a Deployment:

try (KubernetesClient client = new DefaultKubernetesClient()) {
    client.apps().deployments().inNamespace("default").withName("nginx-deployment")
        .scale(5);
}

Getting Started

To use Fabric8 Kubernetes Client in your project, add the following dependency to your Maven pom.xml:

<dependency>
    <groupId>io.fabric8</groupId>
    <artifactId>kubernetes-client</artifactId>
    <version>5.12.2</version>
</dependency>

For Gradle, add this to your build.gradle:

implementation 'io.fabric8:kubernetes-client:5.12.2'

Then, you can create a KubernetesClient instance and start interacting with your cluster:

import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;

try (KubernetesClient client = new DefaultKubernetesClient()) {
    client.pods().inNamespace("default").list()
        .getItems().forEach(pod ->
            System.out.println(pod.getMetadata().getName())
        );
}

This example lists all pods in the default namespace. Make sure you have the necessary credentials and access to your Kubernetes cluster before running the code.

Competitor Comparisons

3,537

Official Java client library for kubernetes

Pros of kubernetes-client/java

  • Official Kubernetes Java client, ensuring better long-term support and compatibility
  • More comprehensive documentation and examples
  • Closer alignment with Kubernetes API updates and features

Cons of kubernetes-client/java

  • Steeper learning curve due to more complex API structure
  • Less flexibility in terms of customization and extension
  • Potentially slower release cycle for new features

Code Comparison

kubernetes-client/java:

try (KubernetesClient client = new KubernetesClientBuilder().build()) {
    Pod pod = client.pods().inNamespace("default").withName("example-pod").get();
    System.out.println("Pod name: " + pod.getMetadata().getName());
}

kubernetes-client:

try (KubernetesClient client = new DefaultKubernetesClient()) {
    Pod pod = client.pods().inNamespace("default").withName("example-pod").get();
    System.out.println("Pod name: " + pod.getMetadata().getName());
}

Both libraries provide similar functionality for basic Kubernetes operations. The main difference lies in the client initialization and the overall API structure. kubernetes-client/java uses a builder pattern for client creation, while kubernetes-client uses a more straightforward approach. The official client (kubernetes-client/java) may offer more robust type-safety and closer adherence to the Kubernetes API, but kubernetes-client often provides a more user-friendly and flexible experience for developers.

6,694

Official Python client library for kubernetes

Pros of kubernetes-client/python

  • Native Python implementation, making it more intuitive for Python developers
  • Extensive documentation and examples for various use cases
  • Supports both synchronous and asynchronous operations

Cons of kubernetes-client/python

  • Limited to Python ecosystem, unlike the Java-based kubernetes-client
  • May have slower performance compared to the Java implementation
  • Less mature and potentially fewer advanced features

Code Comparison

kubernetes-client/python:

from kubernetes import client, config

config.load_kube_config()
v1 = client.CoreV1Api()
pods = v1.list_pod_for_all_namespaces()

kubernetes-client:

KubernetesClient client = new DefaultKubernetesClient();
List<Pod> pods = client.pods().inAnyNamespace().list().getItems();

Both libraries provide similar functionality for interacting with Kubernetes clusters. The Python client offers a more Pythonic approach, while the Java client leverages Java's strong typing and object-oriented features. The choice between them often depends on the primary programming language used in the project and the specific requirements of the application.

1,088

Officially supported dotnet Kubernetes Client library

Pros of kubernetes-client/csharp

  • Native C# implementation, providing better integration with .NET ecosystems
  • Supports .NET Standard 2.0, allowing for cross-platform development
  • Actively maintained by the official Kubernetes team

Cons of kubernetes-client/csharp

  • Less mature compared to kubernetes-client, with fewer features and examples
  • Limited community support and third-party extensions
  • Steeper learning curve for developers new to Kubernetes API concepts

Code Comparison

kubernetes-client/csharp:

var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
var client = new Kubernetes(config);
var pods = await client.ListNamespacedPodAsync("default");

kubernetes-client:

try (final KubernetesClient client = new DefaultKubernetesClient()) {
    client.pods().inNamespace("default").list().getItems().forEach(
        pod -> System.out.println(pod.getMetadata().getName())
    );
}

Both libraries provide similar functionality for interacting with Kubernetes clusters. The C# client offers a more idiomatic approach for .NET developers, while the Java-based kubernetes-client provides a more established ecosystem with broader language support. The choice between the two depends on the specific project requirements, development environment, and team expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Kubernetes & OpenShift Java Client Join the chat at https://gitter.im/fabric8io/kubernetes-client

This client provides access to the full Kubernetes & OpenShift REST APIs via a fluent DSL.

Build Sonar Scanner Bugs E2E Tests Release Twitter

ModuleMaven CentralJavadoc
kubernetes-clientMaven CentralJavadocs
openshift-clientMaven CentralJavadocs
ExtensionsMaven CentralJavadoc
knative-clientMaven CentralJavadocs
tekton-clientMaven CentralJavadocs
chaosmesh-clientMaven CentralJavadocs
volumesnapshot-clientMaven CentralJavadocs
volcano-clientMaven CentralJavadocs
istio-clientMaven CentralJavadocs
open-cluster-management-clientMaven CentralJavadocs

Contents

Usage

Creating a client

The easiest way to create a client is:

KubernetesClient client = new KubernetesClientBuilder().build();

DefaultOpenShiftClient implements both the KubernetesClient & OpenShiftClient interface so if you need the OpenShift extensions, such as Builds, etc then simply do:

OpenShiftClient osClient = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class);

Configuring the client

This will use settings from different sources in the following order of priority:

  • System properties
  • Environment variables
  • Kube config file
  • Service account token & mounted CA certificate

System properties are preferred over environment variables. The following system properties & environment variables can be used for configuration:

Property / Environment VariableDescriptionDefault value
kubernetes.disable.autoConfig / KUBERNETES_DISABLE_AUTOCONFIGDisable automatic configuration (KubernetesClient would not look in ~/.kube/config, mounted ServiceAccount, environment variables or System properties for Kubernetes cluster information)false
kubernetes.master / KUBERNETES_MASTERKubernetes master URLhttps://kubernetes.default.svc
kubernetes.api.version / KUBERNETES_API_VERSIONAPI versionv1
openshift.url / OPENSHIFT_URLOpenShift master URLKubernetes master URL value
kubernetes.oapi.version / KUBERNETES_OAPI_VERSIONOpenShift API versionv1
kubernetes.trust.certificates / KUBERNETES_TRUST_CERTIFICATESTrust all certificatesfalse
kubernetes.disable.hostname.verification / KUBERNETES_DISABLE_HOSTNAME_VERIFICATIONfalse
kubernetes.certs.ca.file / KUBERNETES_CERTS_CA_FILE
kubernetes.certs.ca.data / KUBERNETES_CERTS_CA_DATA
kubernetes.certs.client.file / KUBERNETES_CERTS_CLIENT_FILE
kubernetes.certs.client.data / KUBERNETES_CERTS_CLIENT_DATA
kubernetes.certs.client.key.file / KUBERNETES_CERTS_CLIENT_KEY_FILE
kubernetes.certs.client.key.data / KUBERNETES_CERTS_CLIENT_KEY_DATA
kubernetes.certs.client.key.algo / KUBERNETES_CERTS_CLIENT_KEY_ALGOClient key encryption algorithmRSA
kubernetes.certs.client.key.passphrase / KUBERNETES_CERTS_CLIENT_KEY_PASSPHRASE
kubernetes.auth.basic.username / KUBERNETES_AUTH_BASIC_USERNAME
kubernetes.auth.basic.password / KUBERNETES_AUTH_BASIC_PASSWORD
kubernetes.auth.serviceAccount.token / KUBERNETES_AUTH_SERVICEACCOUNT_TOKENName of the service account token file/var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes.auth.tryKubeConfig / KUBERNETES_AUTH_TRYKUBECONFIGConfigure client using Kubernetes configtrue
kubeconfig / KUBECONFIGName of the kubernetes config file to read~/.kube/config
kubernetes.auth.tryServiceAccount / KUBERNETES_AUTH_TRYSERVICEACCOUNTConfigure client from Service accounttrue
kubernetes.tryNamespacePath / KUBERNETES_TRYNAMESPACEPATHConfigure client namespace from Kubernetes service account namespace pathtrue
kubernetes.auth.token / KUBERNETES_AUTH_TOKEN
kubernetes.watch.reconnectInterval / KUBERNETES_WATCH_RECONNECTINTERVALWatch reconnect interval in ms1000
kubernetes.watch.reconnectLimit / KUBERNETES_WATCH_RECONNECTLIMITNumber of reconnect attempts (-1 for infinite)-1
kubernetes.connection.timeout / KUBERNETES_CONNECTION_TIMEOUTConnection timeout in ms (0 for no timeout)10000
kubernetes.request.timeout / KUBERNETES_REQUEST_TIMEOUTRead timeout in ms10000
kubernetes.upload.connection.timeout / KUBERNETES_UPLOAD_CONNECTION_TIMEOUTPod upload connection timeout in ms10000
kubernetes.upload.request.timeout / KUBERNETES_UPLOAD_REQUEST_TIMEOUTPod upload request timeout in ms120000
kubernetes.request.retry.backoffLimit / KUBERNETES_REQUEST_RETRY_BACKOFFLIMITNumber of retry attempts (-1 for infinite)10
kubernetes.request.retry.backoffInterval / KUBERNETES_REQUEST_RETRY_BACKOFFINTERVALRetry initial backoff interval in ms100
kubernetes.rolling.timeout / KUBERNETES_ROLLING_TIMEOUTRolling timeout in ms900000
kubernetes.logging.interval / KUBERNETES_LOGGING_INTERVALLogging interval in ms20000
kubernetes.scale.timeout / KUBERNETES_SCALE_TIMEOUTScale timeout in ms600000
kubernetes.websocket.timeout / KUBERNETES_WEBSOCKET_TIMEOUTWebsocket timeout in ms5000
kubernetes.websocket.ping.interval / KUBERNETES_WEBSOCKET_PING_INTERVALWebsocket ping interval in ms30000
kubernetes.max.concurrent.requests / KUBERNETES_MAX_CONCURRENT_REQUESTS64
kubernetes.max.concurrent.requests.per.host / KUBERNETES_MAX_CONCURRENT_REQUESTS_PER_HOST5
kubernetes.impersonate.username / KUBERNETES_IMPERSONATE_USERNAMEImpersonate-User HTTP header value
kubernetes.impersonate.group / KUBERNETES_IMPERSONATE_GROUPImpersonate-Group HTTP header value
kubernetes.tls.versions / KUBERNETES_TLS_VERSIONSTLS versions separated by ,TLSv1.2,TLSv1.3
kubernetes.truststore.file / KUBERNETES_TRUSTSTORE_FILE
kubernetes.truststore.passphrase / KUBERNETES_TRUSTSTORE_PASSPHRASE
kubernetes.keystore.file / KUBERNETES_KEYSTORE_FILE
kubernetes.keystore.passphrase / KUBERNETES_KEYSTORE_PASSPHRASE
kubernetes.backwardsCompatibilityInterceptor.disable / KUBERNETES_BACKWARDSCOMPATIBILITYINTERCEPTOR_DISABLEDisable the BackwardsCompatibilityInterceptortrue
no.proxy / NO_PROXYcomma-separated list of domain extensions proxy should not be used for
http.proxy / HTTP_PROXYURL to the proxy for HTTP requests (See Proxy precedence)
https.proxy / HTTPS_PROXYURL to the proxy for HTTPS requests (See Proxy precedence)

Alternatively you can use the ConfigBuilder to create a config object for the Kubernetes client:

Config config = new ConfigBuilder().withMasterUrl("https://mymaster.com").build();
KubernetesClient client = new KubernetesClientBuilder().withConfig(config).build();

Using the DSL is the same for all resources.

List resources:

NamespaceList myNs = client.namespaces().list();

ServiceList myServices = client.services().list();

ServiceList myNsServices = client.services().inNamespace("default").list();

Get a resource:

Namespace myns = client.namespaces().withName("myns").get();

Service myservice = client.services().inNamespace("default").withName("myservice").get();

Delete:

Namespace myns = client.namespaces().withName("myns").delete();

Service myservice = client.services().inNamespace("default").withName("myservice").delete();

Editing resources uses the inline builders from the Kubernetes Model:

Namespace myns = client.namespaces().withName("myns").edit(n -> new NamespaceBuilder(n)
                   .editMetadata()
                     .addToLabels("a", "label")
                   .endMetadata()
                   .build());

Service myservice = client.services().inNamespace("default").withName("myservice").edit(s -> new ServiceBuilder(s)
                     .editMetadata()
                       .addToLabels("another", "label")
                     .endMetadata()
                     .build());

In the same spirit you can inline builders to create:

Namespace myns = client.namespaces().create(new NamespaceBuilder()
                   .withNewMetadata()
                     .withName("myns")
                     .addToLabels("a", "label")
                   .endMetadata()
                   .build());

Service myservice = client.services().inNamespace("default").create(new ServiceBuilder()
                     .withNewMetadata()
                       .withName("myservice")
                       .addToLabels("another", "label")
                     .endMetadata()
                     .build());

You can also set the apiVersion of the resource like in the case of SecurityContextConstraints :

SecurityContextConstraints scc = new SecurityContextConstraintsBuilder()
		.withApiVersion("v1")
		.withNewMetadata().withName("scc").endMetadata()
		.withAllowPrivilegedContainer(true)
		.withNewRunAsUser()
		.withType("RunAsAny")
		.endRunAsUser()
		.build();

Following events

Use io.fabric8.kubernetes.api.model.Event as T for Watcher:

client.events().inAnyNamespace().watch(new Watcher<>() {

  @Override
  public void eventReceived(Action action, Event resource) {
    System.out.println("event " + action.name() + " " + resource.toString());
  }

  @Override
  public void onClose(WatcherException cause) {
    System.out.println("Watcher close due to " + cause);
  }

});

Working with extensions

The kubernetes API defines a bunch of extensions like daemonSets, jobs, ingresses and so forth which are all usable in the extensions() DSL:

e.g. to list the jobs...

jobs = client.batch().jobs().list();

Loading resources from external sources

There are cases where you want to read a resource from an external source, rather than defining it using the clients DSL. For those cases the client allows you to load the resource from:

  • A file (Supports both java.io.File and java.lang.String)
  • A url
  • An input stream

Once the resource is loaded, you can treat it as you would, had you created it yourself.

For example lets read a pod, from a yml file and work with it:

Pod refreshed = client.load('/path/to/a/pod.yml').fromServer().get();
client.load('/workspace/pod.yml').delete();
LogWatch handle = client.load('/workspace/pod.yml').watchLog(System.out);

Passing a reference of a resource to the client

In the same spirit you can use an object created externally (either a reference or using its string representation).

For example:

Pod pod = someThirdPartyCodeThatCreatesAPod();
client.resource(pod).delete();

Adapting the client

The client supports plug-able adapters. An example adapter is the OpenShift Adapter which allows adapting an existing KubernetesClient instance to an OpenShiftClient one.

For example:

KubernetesClient client = new KubernetesClientBuilder().build();

OpenShiftClient oClient = client.adapt(OpenShiftClient.class);

The client also support the isAdaptable() method which checks if the adaptation is possible and returns true if it does.

KubernetesClient client = new KubernetesClientBuilder().build();
if (client.isAdaptable(OpenShiftClient.class)) {
    OpenShiftClient oClient = client.adapt(OpenShiftClient.class);
} else {
    throw new Exception("Adapting to OpenShiftClient not support. Check if adapter is present, and that env provides /oapi root path.");
}

Adapting and close

Note that when using adapt() both the adaptee and the target will share the same resources (underlying http client, thread pools etc). This means that close() is not required to be used on every single instance created via adapt. Calling close() on any of the adapt() managed instances or the original instance, will properly clean up all the resources and thus none of the instances will be usable any longer.

Mocking Kubernetes

Along with the client this project also provides a kubernetes mock server that you can use for testing purposes. The mock server is based on https://github.com/square/okhttp/tree/master/mockwebserver but is empowered by the DSL and features provided by https://github.com/fabric8io/mockwebserver.

The Mock Web Server has two modes of operation:

  • Expectations mode
  • CRUD mode

Expectations mode

It's the typical mode where you first set which are the expected http requests and which should be the responses for each request. More details on usage can be found at: https://github.com/fabric8io/mockwebserver

This mode has been extensively used for testing the client itself. Make sure you check kubernetes-test.

To add a Kubernetes server to your test:

@Rule
public KubernetesServer server = new KubernetesServer();

CRUD mode

Defining every single request and response can become tiresome. Given that in most cases the mock webserver is used to perform simple crud based operations, a crud mode has been added. When using the crud mode, the mock web server will store, read, update and delete kubernetes resources using an in memory map and will appear as a real api server.

To add a Kubernetes Server in crud mode to your test:

@Rule
public KubernetesServer server = new KubernetesServer(true, true);

Then you can use the server like:

@Test
public void testInCrudMode() {
    KubernetesClient client = server.getClient();
    final CountDownLatch deleteLatch = new CountDownLatch(1);
    final CountDownLatch closeLatch = new CountDownLatch(1);

    //CREATE
    client.pods().inNamespace("ns1").create(new PodBuilder().withNewMetadata().withName("pod1").endMetadata().build());

    //READ
    podList = client.pods().inNamespace("ns1").list();
    assertNotNull(podList);
    assertEquals(1, podList.getItems().size());

    //WATCH
    Watch watch = client.pods().inNamespace("ns1").withName("pod1").watch(new Watcher<>() {
        @Override
        public void eventReceived(Action action, Pod resource) {
            switch (action) {
                case DELETED:
                    deleteLatch.countDown();
                    break;
                default:
                    throw new AssertionFailedError(action.toString().concat(" isn't recognised."));
            }
        }

        @Override
        public void onClose(WatcherException cause) {
            closeLatch.countDown();
        }
    });

    //DELETE
    client.pods().inNamespace("ns1").withName("pod1").delete();

    //READ AGAIN
    podList = client.pods().inNamespace("ns1").list();
    assertNotNull(podList);
    assertEquals(0, podList.getItems().size());

    assertTrue(deleteLatch.await(1, TimeUnit.MINUTES));
    watch.close();
    assertTrue(closeLatch.await(1, TimeUnit.MINUTES));
}

JUnit5 support through extension

You can use KubernetesClient mocking mechanism with JUnit5. Since it doesn't support @Rule and @ClassRule there is dedicated annotation @EnableKubernetesMockClient. If you would like to create instance of mocked KubernetesClient for each test (JUnit4 @Rule) you need to declare instance of KubernetesClient as shown below.

@EnableKubernetesMockClient
class ExampleTest {

    KubernetesClient client;

    @Test
    public void testInStandardMode() {
            ...
    }
}

In case you would like to define static instance of mocked server per all the test (JUnit4 @ClassRule) you need to declare instance of KubernetesClient as shown below. You can also enable crudMode by using annotation field crud.

@EnableKubernetesMockClient(crud = true)
class ExampleTest {

    static KubernetesClient client;

    @Test
    public void testInCrudMode() {
            // ...
    }
}

Testing Against real Kubernetes API Server with Kube API Test

In order to test against real Kubernetes API the project provides a lightweight approach, thus starting up Kubernetes API Server and etcd binaries.

@EnableKubeAPIServer
class KubeAPITestSample {

  static KubernetesClient client;
  
  @Test
  void testWithClient() {
    // test using the client against real K8S API Server   
  }
}

For details see docs for Kube API Test.

Compatibility

Kubernetes

Starting from v5.5, the Kubernetes Client should be compatible with any supported Kubernetes cluster version. We provide DSL methods (for example client.pods(), client.namespaces(), and so on) for the most commonly used Kubernetes resources. If the resource you're looking for is not available through the DSL, you can always use the generic client.resource() method to interact with it. You can also open a new issue to request the addition of a new resource to the DSL.

We provide Kubernetes Java model types (for example Pod) and their corresponding builders (for example PodBuilder) for every vanilla Kubernetes resource (and some extensions). If you don't find a specific resource, and you think that it should be part of the Kubernetes Client, please open a new issue.

OpenShift

Starting from v5.5, the OpenShift Client should be compatible with any OpenShift cluster version currently supported by Red Hat. The Fabric8 Kubernetes Client is one of the few Kubernetes Java clients that provides full support for any supported OpenShift cluster version. If you find any incompatibility or something missing, please open a new issue.

Major Changes in Kubernetes Client 4.0.0

All the resource objects used here will be according to OpenShift 3.9.0 and Kubernetes 1.9.0. All the resource objects will give all the fields according to OpenShift 3.9.0 and Kubernetes 1.9.0

  • SecurityContextConstraints has been moved to OpenShift client from Kubernetes Client
  • Job dsl is in both batch and extensions(Extensions is deprecated)
  • DaemonSet dsl is in both apps and extensions(Extensions is deprecated)
  • Deployment dsl is in both apps and extensions(Extensions is deprecated)
  • ReplicaSet dsl is in both apps and extensions(Extensions is deprecated)
  • NetworkPolicy dsl is in both network and extensions(Extensions is deprecated)
  • Storage Class moved from client base DSL to storage DSL
  • PodSecurityPolicies moved from client base DSL and extensions to only extensions
  • ThirdPartyResource has been removed.

Who uses Kubernetes & OpenShift Java client?

Extensions:

Frameworks/Libraries/Tools:

CI Plugins:

Build Tools:

Platforms:

Proprietary Platforms:

As our community grows, we would like to track keep track of our users. Please send a PR with your organization/community name.

Tests we run for every new Pull Request

There are the links of the Github Actions and Jenkins for the tests which run for every new Pull Request. You can view all the recent builds also.

To get the updates about the releases, you can join https://groups.google.com/forum/embed/?place=forum/fabric8-devclients

Kubectl Java Equivalents

This table provides kubectl to Kubernetes Java Client mappings. Most of the mappings are quite straightforward and are one liner operations. However, some might require slightly more code to achieve same result:

kubectlFabric8 Kubernetes Client
kubectl config viewConfigViewEquivalent.java
kubectl config get-contextsConfigGetContextsEquivalent.java
kubectl config current-contextConfigGetCurrentContextEquivalent.java
kubectl config use-context minikubeConfigUseContext.java
kubectl config view -o jsonpath='{.users[*].name}'ConfigGetCurrentContextEquivalent.java
kubectl get pods --all-namespacesPodListGlobalEquivalent.java
kubectl get podsPodListEquivalent.java
kubectl get pods -wPodWatchEquivalent.java
kubectl get pods --sort-by='.metadata.creationTimestamp'PodListGlobalEquivalent.java
kubectl runPodRunEquivalent.java
kubectl create -f test-pod.yamlPodCreateYamlEquivalent.java
kubectl exec my-pod -- ls /PodExecEquivalent.java
kubectl attach my-podPodAttachEquivalent.java
kubectl delete pod my-podPodDelete.java
kubectl delete -f test-pod.yamlPodDeleteViaYaml.java
kubectl cp /foo_dir my-pod:/bar_dirUploadDirectoryToPod.java
kubectl cp my-pod:/tmp/foo /tmp/barDownloadFileFromPod.java
kubectl cp my-pod:/tmp/foo -c c1 /tmp/barDownloadFileFromMultiContainerPod.java
kubectl cp /foo_dir my-pod:/tmp/bar_dirUploadFileToPod.java
kubectl logs pod/my-podPodLogsEquivalent.java
kubectl logs pod/my-pod -fPodLogsFollowEquivalent.java
kubectl logs pod/my-pod -c c1PodLogsMultiContainerEquivalent.java
kubectl port-forward my-pod 8080:80PortForwardEquivalent.java
kubectl get pods --selector=version=v1 -o jsonpath='{.items[*].metadata.name}'PodListFilterByLabel.java
kubectl get pods --field-selector=status.phase=RunningPodListFilterFieldSelector.java
kubectl get pods --show-labelsPodShowLabels.java
kubectl label pods my-pod new-label=awesomePodAddLabel.java
kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWqPodAddAnnotation.java
kubectl get configmap cm1 -o jsonpath='{.data.database}'ConfigMapJsonPathEquivalent.java
kubectl create -f test-svc.yamlLoadAndCreateService.java
kubectl create -f test-deploy.yamlLoadAndCreateDeployment.java
kubectl set image deploy/d1 nginx=nginx:v2RolloutSetImageEquivalent.java
kubectl scale --replicas=4 deploy/nginx-deploymentScaleEquivalent.java
kubectl scale statefulset --selector=app=my-database --replicas=4ScaleWithLabelsEquivalent.java
kubectl rollout restart deploy/d1RolloutRestartEquivalent.java
kubectl rollout pause deploy/d1RolloutPauseEquivalent.java
kubectl rollout resume deploy/d1RolloutResumeEquivalent.java
kubectl rollout undo deploy/d1RolloutUndoEquivalent.java
kubectl create -f test-crd.yamlLoadAndCreateCustomResourceDefinition.java
kubectl create -f customresource.yamlCustomResourceCreateDemo.java
kubectl create -f customresource.yamlCustomResourceCreateDemoTypeless.java
kubectl get nsNamespaceListEquivalent.java
kubectl create namespace testNamespaceCreateEquivalent.java
kubectl apply -f test-resource-list.ymlCreateOrReplaceResourceList.java
kubectl get eventsEventsGetEquivalent.java
kubectl top nodesTopEquivalent.java
kubectl auth can-i create deployment.appsCanIEquivalent.java
kubectl create -f test-csr-v1.ymlCertificateSigningRequestCreateYamlEquivalent.java
kubectl certificate approve my-certCertificateSigningRequestApproveYamlEquivalent.java
kubectl certificate deny my-certCertificateSigningRequestDenyYamlEquivalent.java
kubectl create -f quota.yaml --namespace=defaultCreateResourceQuotaInNamespaceYamlEquivalent.java