This client provides access to the full Kubernetes &OpenShift REST APIs via a fluent DSL.
Module | Maven Central | Javadoc |
---|---|---|
kubernetes-client | ||
openshift-client |
Extensions | Maven Central | Javadoc |
---|---|---|
knative-client | ||
tekton-client | ||
servicecatalog-client | ||
chaosmesh-client | ||
volumesnapshot-client |
The easiest way to create a client is:
KubernetesClient client = new DefaultKubernetesClient();
DefaultOpenShiftClient
implements both the KubernetesClient
& OpenShiftClient
interface so if you need theOpenShift extensions, such as Build
s, etc then simply do:
OpenShiftClient osClient = new DefaultOpenShiftClient();
This will use settings from different sources in the following order of priority:
System properties are preferred over environment variables. The following system properties & environment variables can be used for configuration:
Property / Environment Variable | Description | Default value |
---|---|---|
kubernetes.disable.autoConfig / KUBERNETES_DISABLE_AUTOCONFIG |
Disable automatic configuration | false |
kubernetes.master / KUBERNETES_MASTER |
Kubernetes master URL | https://kubernetes.default.svc |
kubernetes.api.version / KUBERNETES_API_VERSION |
API version | v1 |
openshift.url / OPENSHIFT_URL |
OpenShift master URL | Kubernetes master URL value |
kubernetes.oapi.version / KUBERNETES_OAPI_VERSION |
OpenShift API version | v1 |
kubernetes.trust.certificates / KUBERNETES_TRUST_CERTIFICATES |
Trust all certificates | false |
kubernetes.disable.hostname.verification / KUBERNETES_DISABLE_HOSTNAME_VERIFICATION |
false |
|
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_ALGO |
Client key encryption algorithm | RSA |
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_TOKEN |
Name of the service account token file | /var/run/secrets/kubernetes.io/serviceaccount/token |
kubernetes.auth.tryKubeConfig / KUBERNETES_AUTH_TRYKUBECONFIG |
Configure client using Kubernetes config | true |
kubeconfig / KUBECONFIG |
Name of the kubernetes config file to read | ~/.kube/config |
kubernetes.auth.tryServiceAccount / KUBERNETES_AUTH_TRYSERVICEACCOUNT |
Configure client from Service account | true |
kubernetes.tryNamespacePath / KUBERNETES_TRYNAMESPACEPATH |
Configure client namespace from Kubernetes service account namespace path | true |
kubernetes.auth.token / KUBERNETES_AUTH_TOKEN |
||
kubernetes.watch.reconnectInterval / KUBERNETES_WATCH_RECONNECTINTERVAL |
Watch reconnect interval in ms | 1000 |
kubernetes.watch.reconnectLimit / KUBERNETES_WATCH_RECONNECTLIMIT |
Number of reconnect attempts (-1 for infinite) | -1 |
kubernetes.connection.timeout / KUBERNETES_CONNECTION_TIMEOUT |
Connection timeout in ms (0 for no timeout) | 10000 |
kubernetes.request.timeout / KUBERNETES_REQUEST_TIMEOUT |
Read timeout in ms | 10000 |
kubernetes.upload.connection.timeout / KUBERNETES_UPLOAD_CONNECTION_TIMEOUT |
Pod upload connection timeout in ms | 10000 |
kubernetes.upload.request.timeout / KUBERNETES_UPLOAD_REQUEST_TIMEOUT |
Pod upload request timeout in ms | 120000 |
kubernetes.request.retry.backoffLimit / KUBERNETES_REQUEST_RETRY_BACKOFFLIMIT |
Number of retry attempts | 0 |
kubernetes.request.retry.backoffInterval / KUBERNETES_REQUEST_RETRY_BACKOFFINTERVAL |
Retry initial backoff interval in ms | 1000 |
kubernetes.rolling.timeout / KUBERNETES_ROLLING_TIMEOUT |
Rolling timeout in ms | 900000 |
kubernetes.logging.interval / KUBERNETES_LOGGING_INTERVAL |
Logging interval in ms | 20000 |
kubernetes.scale.timeout / KUBERNETES_SCALE_TIMEOUT |
Scale timeout in ms | 600000 |
kubernetes.websocket.timeout / KUBERNETES_WEBSOCKET_TIMEOUT |
Websocket timeout in ms | 5000 |
kubernetes.websocket.ping.interval / kubernetes_websocket_ping_interval |
Websocket ping interval in ms | 30000 |
kubernetes.max.concurrent.requests / KUBERNETES_MAX_CONCURRENT_REQUESTS |
64 |
|
kubernetes.max.concurrent.requests.per.host / KUBERNETES_MAX_CONCURRENT_REQUESTS_PER_HOST |
5 |
|
kubernetes.impersonate.username / KUBERNETES_IMPERSONATE_USERNAME |
Impersonate-User HTTP header value |
|
kubernetes.impersonate.group / KUBERNETES_IMPERSONATE_GROUP |
Impersonate-Group HTTP header value |
|
kubernetes.tls.versions / KUBERNETES_TLS_VERSIONS |
TLS versions separated by , |
TLSv1.2 |
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_BACKWARDS_COMPATIBILITY_INTERCEPTOR_DISABLE |
Disable BackwardsCompatibilityInterceptor |
false |
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 DefaultKubernetesClient(config);
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();
Use io.fabric8.kubernetes.api.model.Event
as T for Watcher:
client.events().inAnyNamespace().watch(new Watcher<Event>() {
@Override
public void eventReceived(Action action, Event resource) {
System.out.println("event " + action.name() + " " + resource.toString());
}
@Override
public void onClose(KubernetesClientException cause) {
System.out.println("Watcher close due to " + cause);
}
});
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();
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:
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();
Boolean deleted = client.load('/workspace/pod.yml').delete();
LogWatch handle = client.load('/workspace/pod.yml').watchLog(System.out);
In the same spirit you can use an object created externally (either a reference or using its string representation).
For example:
Pod pod = someThirdPartyCodeThatCreatesAPod();
Boolean deleted = client.resource(pod).delete();
The client supports plug-able adapters. An example adapter is the OpenShift Adapterwhich allows adapting an existing KubernetesClient instance to an OpenShiftClient one.
For example:
KubernetesClient client = new DefaultKubernetesClient();
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 DefaultKubernetesClient();
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.");
}
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.
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:
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();
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<Pod>() {
@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(KubernetesClientException 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));
}
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() {
...
}
}
K8s 1.22.1 | K8s 1.21.1 | K8s 1.20.2 | K8s 1.19.1 | K8s 1.18.0 | K8s 1.17.0 | K8s 1.16.0 | K8s 1.15.3 | K8s 1.14.2 | K8s 1.12.0 | K8s 1.11.0 | K8s 1.10.0 | K8s 1.9.0 | K8s 1.7.0 | K8s 1.6.0 | K8s 1.4.9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
kubernetes-client 5.8.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - | |
kubernetes-client 5.7.3 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.7.2 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.7.1 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.7.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.6.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.5.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.4.1 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.4.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.3.1 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.3.0 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.2.1 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.2.0 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.1.1 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.1.0 | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.0.2 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.0.1 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 5.0.0 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.13.3 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.13.2 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.13.1 | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.13.0 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.12.0 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.11.2 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.11.1 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.11.0 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.10.3 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.10.2 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.10.1 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.10.0 | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.9.2 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.9.1 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.9.0 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.8.0 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.7.2 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.7.1 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.7.0 | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.6.4 | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.6.3 | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.6.2 | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.6.1 | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.6.0 | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.5.2 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.5.1 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.5.0 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.4.2 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.4.1 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.4.0 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.3.1 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.3.0 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.2.2 | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.2.1 | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.2.0 | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.1.3 | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.1.2 | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - |
kubernetes-client 4.1.1 | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | ✓ | - | - | - | |
kubernetes-client 4.1.0 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 4.0.0 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 3.2.0 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 3.1.12 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 3.0.11 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 3.0.10 | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | ✓ | ✓ | - |
kubernetes-client 3.0.3 | - | - | - | - | - | - | - | - | - | - | - | - | - | ✓ | - | - |
kubernetes-client 1.3.92 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | + | + |
Note: This matrix is prepared by running our integration tests on different versions of OpenShift.
OCP 4.5.14 | OCP 4.2.0 | OCP 4.1.0 | OCP 3.11.0 | OCP 3.10.0 | OCP 3.9.0 | OCP 3.7.0 | OCP 3.6.0 | |
---|---|---|---|---|---|---|---|---|
openshift-client 5.8.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.7.3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.7.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.7.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.7.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.6.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.5.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.4.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.4.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.3.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.3.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.2.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.2.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.1.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.1.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.0.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.0.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 5.0.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.13.3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.13.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.13.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.13.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.12.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.11.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.11.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.11.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.10.3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.10.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.10.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.10.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.9.2 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.9.1 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.9.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.8.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.7.2 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.7.1 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.7.0 | - | ✓ | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.6.4 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.6.3 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.6.2 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.6.1 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.6.0 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.5.2 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.5.1 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.5.0 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.4.2 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.4.1 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.4.0 | - | - | ✓ | ✓ | ✓ | ✓ | - | - |
openshift-client 4.3.1 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.3.0 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.2.2 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.2.1 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.2.0 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.1.3 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.1.2 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.1.1 | - | - | - | ✓ | ✓ | ✓ | - | - |
openshift-client 4.1.0 | - | - | - | - | ✓ | ✓ | ✓ | - |
openshift-client 4.0.0 | - | - | - | - | - | ✓ | ✓ | ✓ |
openshift-client 3.2.0 | - | - | - | - | - | ✓ | ✓ | ✓ |
openshift-client 3.1.12 | - | - | - | - | - | ✓ | ✓ | ✓ |
openshift-client 3.0.11 | - | - | - | - | - | ✓ | ✓ | ✓ |
openshift-client 3.0.10 | - | - | - | - | - | ✓ | ✓ | ✓ |
openshift-client 3.0.3 | - | - | - | - | - | - | ✓ | - |
openshift-client 1.3.92 | - | - | - | - | - | - | - | + |
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
batch
and extensions
(Extensions is deprecated)apps
and extensions
(Extensions is deprecated)apps
and extensions
(Extensions is deprecated)apps
and extensions
(Extensions is deprecated)network
and extensions
(Extensions is deprecated)client base DSL
to storage
DSLclient base DSL
and extensions
to only extensions
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.
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
This table provides kubectl
to Kubernetes Java Client mappings. Most of the mappings are quite straightforward and are one lineroperations. However, some might require slightly more code to achieve same result:
kubectl | Fabric8 Kubernetes Client |
---|---|
kubectl config view |
ConfigViewEquivalent.java |
kubectl config get-contexts |
ConfigGetContextsEquivalent.java |
kubectl config current-context |
ConfigGetCurrentContextEquivalent.java |
kubectl config use-context minikube |
ConfigUseContext.java |
kubectl config view -o jsonpath='{.users[*].name}' |
ConfigGetCurrentContextEquivalent.java |
kubectl get pods --all-namespaces |
PodListGlobalEquivalent.java |
kubectl get pods |
PodListEquivalent.java |
kubectl get pods -w |
PodWatchEquivalent.java |
kubectl get pods --sort-by='.metadata.creationTimestamp' |
PodListGlobalEquivalent.java |
kubectl run |
PodRunEquivalent.java |
kubectl create -f test-pod.yaml |
PodCreateYamlEquivalent.java |
kubectl exec my-pod -- ls / |
PodExecEquivalent.java |
kubectl delete pod my-pod |
PodDelete.java |
kubectl delete -f test-pod.yaml |
PodDeleteViaYaml.java |
kubectl cp /foo_dir my-pod:/bar_dir |
UploadDirectoryToPod.java |
kubectl cp my-pod:/tmp/foo /tmp/bar |
DownloadFileFromPod.java |
kubectl cp my-pod:/tmp/foo -c c1 /tmp/bar |
DownloadFileFromMultiContainerPod.java |
kubectl cp /foo_dir my-pod:/tmp/bar_dir |
UploadFileToPod.java |
kubectl logs pod/my-pod |
PodLogsEquivalent.java |
kubectl logs pod/my-pod -f |
PodLogsFollowEquivalent.java |
kubectl logs pod/my-pod -c c1 |
PodLogsMultiContainerEquivalent.java |
kubectl port-forward my-pod 8080:80 |
PortForwardEquivalent.java |
kubectl get pods --selector=version=v1 -o jsonpath='{.items[*].metadata.name}' |
PodListFilterByLabel.java |
kubectl get pods --field-selector=status.phase=Running |
PodListFilterFieldSelector.java |
kubectl get pods --show-labels |
PodShowLabels.java |
kubectl label pods my-pod new-label=awesome |
PodAddLabel.java |
kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWq |
PodAddAnnotation.java |
kubectl get configmap cm1 -o jsonpath='{.data.database}' |
ConfigMapJsonPathEquivalent.java |
kubectl create -f test-svc.yaml |
LoadAndCreateService.java |
kubectl create -f test-deploy.yaml |
LoadAndCreateDeployment.java |
kubectl set image deploy/d1 nginx=nginx:v2 |
RolloutSetImageEquivalent.java |
kubectl scale --replicas=4 deploy/nginx-deployment |
ScaleEquivalent.java |
kubectl rollout restart deploy/d1 |
RolloutRestartEquivalent.java |
kubectl rollout pause deploy/d1 |
RolloutPauseEquivalent.java |
kubectl rollout resume deploy/d1 |
RolloutResumeEquivalent.java |
kubectl rollout undo deploy/d1 |
RolloutUndoEquivalent.java |
kubectl create -f test-crd.yaml |
LoadAndCreateCustomResourceDefinition.java |
kubectl create -f customresource.yaml |
CustomResourceCreateDemo.java |
kubectl create -f customresource.yaml |
CustomResourceCreateDemoTypeless.java |
kubectl get ns |
NamespaceListEquivalent.java |
kubectl apply -f test-resource-list.yml |
CreateOrReplaceResourceList.java |
kubectl get events |
EventsGetEquivalent.java |
kubectl top nodes |
TopEquivalent.java |
kubectl auth can-i create deployment.apps |
CanIEquivalent.java |
蚂蚁金服kubernetes方向招聘 kubernetes的Client库——go-client中提供了如下三种类型的client ClientSet:可以访问集群中所有的原生资源,如pods、deployment等,是最常用的一种 dynamicClient: 可以处理集群中所有的资源,包括crd(自定义资源),另外它的返回是一个map[string]interface{}类型;目前主要用在ga
kubernetes client 相关api kubernetes client java api 地址:https://gitee.com/ploynomail/python/tree/master/kubernetes/docs client-java-api地址:https://javadoc.io/doc/io.kubernetes/client-java-api/12.0.0/inde
使用的k8s client包: <dependency> <groupId>io.fabric8</groupId> <artifactId>kubernetes-client</artifactId> <version>2.6.1</version> <exclusions> <exclusion> <artifactId>slf4j-api</artifactId> <
一、概述 Kubernetes官方维护的Python客户端client-python, 地址:https://github.com/kubernetes-client/python 安装模块 pip3 install kubernetes 环境说明 操作系统:centos 7.6 k8s版本:1.18.1 ip地址:192.168.31.74 主机名:k8s-master 操作系统:c
Kubernetes Clientset Kubernetes Clientset 资源类型 Scheme types.go 文件 zz_generated.deepcopy.go 文件 register.go 文件 注册所有内置资源类型到 Scheme 对象 创建和使用 Kubernetes Clientset 创建支持所有资源类型的全局 Clientset 各资源类型的 Clientset 各
【kubernetes系列学习】client-go学习与实践 release author: ningan123 release time: 2022-08-09 client-go客户端对象 client-go支持RESTClient、ClientSet、DynamicClient、DiscoveryClient四种客户端与Kubernetes Api Server进行交互。 RESTClien
前言 ListerWatcher是Lister和Watcher的结合体,前者负责列举全量对象,后者负责监视(本文将watch翻译为监视)对象的增量变化。为什么要有这个接口?原因很简单,提高访问效率。众所周知,kubernetes所有API对象都存储在etcd中,并只能通过apiserver访问。如果很多客户端频繁的列举全量对象(比如列举所有的Pod),这会造成apiserver不堪重负。那么如果在
前言 client-go 是kubernetes 的go语言客户端简单易用,但需要小心区分kubernetes的API版本。 简单例子 import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/kubernetes" appsv1beta1 "k8s.io/api/apps/v1beta1" met
如何在GO语言中使用Kubernetes API? 使用 client-go 控制原生及拓展的 Kubernetes API | PPT 实录 如何用 client-go 拓展 Kubernetes 的 API Informer 深入浅出kubernetes之client-go的Indexer 深入浅出kubernetes之client-go的DeltaFIFO 深入浅出kubernetes之cl
Kubernetes (通常称为 K8s) 是来自 Google 云平台的开源容器集群管理系统,用于自动部署、扩展和管理容器化(containerized)应用程序。该系统基于 Docker 构建一个容器的调度服务。 Kubernetes 可以自动在一个容器集群中选择一个工作容器供使用。其核心概念是 Container Pod。详细的设计思路请参考这里。 Kubernetes 由 Google 设
我正在使用Ansible、Docker、Jenkins和Kubernetes实现持续集成和持续部署。我已经使用Ansible和kubespray部署创建了一个具有1个主节点和2个工作节点的Kubernetes集群。我有30-40个微服务应用。我需要创建这么多的服务和部署。 我的困惑 当我使用Kubernetes包管理器Kubernetes Helm chart时,我需要在主节点上启动我的图表,还是
扩展应用 通过修改Deployment中副本的数量(replicas),可以动态扩展或收缩应用: 这些自动扩展的容器会自动加入到service中,而收缩回收的容器也会自动从service中删除。 $ kubectl scale --replicas=3 deployment/nginx-app $ kubectl get deploy NAME DESIRED CURRENT
体验Kubernetes最简单的方法是跑一个nginx容器,然后使用kubectl操作该容器。Kubernetes提供了一个类似于docker run的命令kubectl run,可以方便的创建一个容器(实际上创建的是一个由deployment来管理的Pod): $ kubectl run --image=nginx:alpine nginx-app --port=80
我试图在Kubernetes上运行Spark作为调度程序。 当使用从kubernetes集群外部运行时,它可以正常工作。 但是,每当我们尝试从pod中直接运行spark-shell或spark-submit时,它都不会起作用(即使使用从spark文档中执行rbac也不会起作用。我们有授权执行异常: io.fabric8.kubernetes.client.kubernetesclientExcep
部署单元 依赖方式 架构模式 微服务涉及的技术点 服务发现 服务目录 服务列表 配置中心 服务生命周期 变更,升级 服务依赖关系 链路跟踪 限流 降级 熔断 访问控制 为微服务而生的 Kubernetes Kubernetes 架构 Kubernetes Pod - Sidecar 模式 Kubernetes 支持微服务的一些特性 微服务集大成之 istio Kubernetes 架构 一个状态存
本项目包含一个可构建的Nacos Docker Image,旨在利用StatefulSets在Kubernetes上部署Nacos 快速开始 Clone 项目 git clone https://github.com/nacos-group/nacos-k8s.git 简单例子 如果你使用简单方式快速启动,请注意这是没有使用持久化卷的,可能存在数据丢失风险: cd nacos-k8s chmod
Awesome-Kubernetes A curated list for awesome kubernetes sources inspired by @sindresorhus' awesome "Talent wins games, but teamwork and intelligence wins championships." -- Michael Jordan Without the