Search in sources :

Example 1 with DynamicKubernetesObject

use of io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject in project java by kubernetes-client.

the class DynamicClientExample method main.

public static void main(String[] args) throws IOException, ApiException {
    ApiClient apiClient = ClientBuilder.standard().build();
    // retrieving the latest state of the default namespace
    DynamicKubernetesApi dynamicApi = new DynamicKubernetesApi("", "v1", "namespaces", apiClient);
    DynamicKubernetesObject defaultNamespace = dynamicApi.get("default").throwsApiException().getObject();
    // attaching a "foo=bar" label to the default namespace
    defaultNamespace.setMetadata(defaultNamespace.getMetadata().putLabelsItem("foo", "bar"));
    DynamicKubernetesObject updatedDefaultNamespace = dynamicApi.update(defaultNamespace).throwsApiException().getObject();
    System.out.println(updatedDefaultNamespace);
    apiClient.getHttpClient().connectionPool().evictAll();
}
Also used : DynamicKubernetesApi(io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi) DynamicKubernetesObject(io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject) ApiClient(io.kubernetes.client.openapi.ApiClient)

Aggregations

ApiClient (io.kubernetes.client.openapi.ApiClient)1 DynamicKubernetesApi (io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi)1 DynamicKubernetesObject (io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject)1