Search in sources :

Example 81 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.

the class CoreV1Api method patchNamespacedPodEphemeralcontainersWithHttpInfo.

/**
 * partially update ephemeralcontainers of the specified Pod
 *
 * @param name name of the Pod (required)
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param body (required)
 * @param pretty If 'true', then the output is pretty printed. (optional)
 * @param dryRun When present, indicates that modifications should not be persisted. An invalid or
 *     unrecognized dryRun directive will result in an error response and no further processing of
 *     the request. Valid values are: - All: all dry run stages will be processed (optional)
 * @param fieldManager fieldManager is a name associated with the actor or entity that is making
 *     these changes. The value must be less than or 128 characters long, and only contain
 *     printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is
 *     required for apply requests (application/apply-patch) but optional for non-apply patch
 *     types (JsonPatch, MergePatch, StrategicMergePatch). (optional)
 * @param fieldValidation fieldValidation determines how the server should respond to
 *     unknown/duplicate fields in the object in the request. Introduced as alpha in 1.23, older
 *     servers or servers with the `ServerSideFieldValidation` feature disabled will
 *     discard valid values specified in this param and not perform any server side field
 *     validation. Valid values are: - Ignore: ignores unknown/duplicate fields. - Warn: responds
 *     with a warning for each unknown/duplicate field, but successfully serves the request. -
 *     Strict: fails the request on unknown/duplicate fields. (optional)
 * @param force Force is going to \"force\" Apply requests. It means user will
 *     re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply
 *     patch requests. (optional)
 * @return ApiResponse<V1Pod>
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
 *     response body
 * @http.response.details
 *     <table summary="Response Details" border="1">
 * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
 * <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
 * <tr><td> 201 </td><td> Created </td><td>  -  </td></tr>
 * <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
 * </table>
 */
public ApiResponse<V1Pod> patchNamespacedPodEphemeralcontainersWithHttpInfo(String name, String namespace, V1Patch body, String pretty, String dryRun, String fieldManager, String fieldValidation, Boolean force) throws ApiException {
    okhttp3.Call localVarCall = patchNamespacedPodEphemeralcontainersValidateBeforeCall(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, force, null);
    Type localVarReturnType = new TypeToken<V1Pod>() {
    }.getType();
    return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1Pod(io.kubernetes.client.openapi.models.V1Pod)

Example 82 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.

the class FluentExample method main.

public static void main(String[] args) throws IOException, ApiException {
    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);
    CoreV1Api api = new CoreV1Api();
    V1Pod pod = new V1PodBuilder().withNewMetadata().withName("apod").endMetadata().withNewSpec().addNewContainer().withName("www").withImage("nginx").endContainer().endSpec().build();
    api.createNamespacedPod("default", pod, null, null, null, null);
    V1Pod pod2 = new V1Pod().metadata(new V1ObjectMeta().name("anotherpod")).spec(new V1PodSpec().containers(Arrays.asList(new V1Container().name("www").image("nginx"))));
    api.createNamespacedPod("default", pod2, null, null, null, null);
    V1PodList list = api.listNamespacedPod("default", null, null, null, null, null, null, null, null, null, null);
    for (V1Pod item : list.getItems()) {
        System.out.println(item.getMetadata().getName());
    }
}
Also used : V1Container(io.kubernetes.client.openapi.models.V1Container) V1PodList(io.kubernetes.client.openapi.models.V1PodList) V1PodBuilder(io.kubernetes.client.openapi.models.V1PodBuilder) V1ObjectMeta(io.kubernetes.client.openapi.models.V1ObjectMeta) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiClient(io.kubernetes.client.openapi.ApiClient) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api) V1PodSpec(io.kubernetes.client.openapi.models.V1PodSpec)

Example 83 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.

the class InClusterClientExample method main.

public static void main(String[] args) throws IOException, ApiException {
    // loading the in-cluster config, including:
    // 1. service-account CA
    // 2. service-account bearer-token
    // 3. service-account namespace
    // 4. master endpoints(ip, port) from pre-set environment variables
    ApiClient client = ClientBuilder.cluster().build();
    // if you prefer not to refresh service account token, please use:
    // ApiClient client = ClientBuilder.oldCluster().build();
    // set the global default api-client to the in-cluster one from above
    Configuration.setDefaultApiClient(client);
    // the CoreV1Api loads default api-client from global configuration.
    CoreV1Api api = new CoreV1Api();
    // invokes the CoreV1Api client
    V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null);
    for (V1Pod item : list.getItems()) {
        System.out.println(item.getMetadata().getName());
    }
}
Also used : V1PodList(io.kubernetes.client.openapi.models.V1PodList) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiClient(io.kubernetes.client.openapi.ApiClient) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api)

Example 84 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.

the class KubectlTop method topPods.

private List<Pair<ApiType, MetricsType>> topPods(CoreV1Api api, ApiClient apiClient, String metricName) throws KubectlException, ApiException, IOException {
    V1PodList pods = api.listNamespacedPod(namespace, null, null, null, null, null, null, null, null, null, null);
    PodMetricsList metrics = new Metrics(apiClient).getPodMetrics(namespace);
    List<V1Pod> items = pods.getItems();
    Collections.sort(items, new Comparator<V1Pod>() {

        @Override
        public int compare(V1Pod arg0, V1Pod arg1) {
            double m0 = podMetricSum(findPodMetric(arg0.getMetadata().getName(), metrics), metricName);
            double m1 = podMetricSum(findPodMetric(arg1.getMetadata().getName(), metrics), metricName);
            // sort high to low
            return Double.compare(m0, m1) * -1;
        }
    });
    List<Pair<ApiType, MetricsType>> result = new ArrayList<>();
    for (V1Pod pod : items) {
        result.add(new ImmutablePair<>((ApiType) pod, (MetricsType) findPodMetric(pod, metrics)));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) V1PodList(io.kubernetes.client.openapi.models.V1PodList) Metrics(io.kubernetes.client.Metrics) NodeMetrics(io.kubernetes.client.custom.NodeMetrics) PodMetrics(io.kubernetes.client.custom.PodMetrics) ContainerMetrics(io.kubernetes.client.custom.ContainerMetrics) PodMetricsList(io.kubernetes.client.custom.PodMetricsList) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Example 85 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.

the class LogsExample method main.

public static void main(String[] args) throws IOException, ApiException, InterruptedException {
    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);
    CoreV1Api coreApi = new CoreV1Api(client);
    PodLogs logs = new PodLogs();
    V1Pod pod = coreApi.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null, null).getItems().get(0);
    InputStream is = logs.streamNamespacedPodLog(pod);
    Streams.copy(is, System.out);
}
Also used : PodLogs(io.kubernetes.client.PodLogs) InputStream(java.io.InputStream) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiClient(io.kubernetes.client.openapi.ApiClient) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api)

Aggregations

V1Pod (io.kubernetes.client.openapi.models.V1Pod)96 Test (org.junit.Test)55 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)38 V1PodList (io.kubernetes.client.openapi.models.V1PodList)31 Type (java.lang.reflect.Type)22 ApiException (io.kubernetes.client.openapi.ApiException)17 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)17 V1ListMeta (io.kubernetes.client.openapi.models.V1ListMeta)15 ApiClient (io.kubernetes.client.openapi.ApiClient)12 V1Status (io.kubernetes.client.openapi.models.V1Status)9 Watch (io.kubernetes.client.util.Watch)9 CallGeneratorParams (io.kubernetes.client.util.CallGeneratorParams)8 JSON (io.kubernetes.client.openapi.JSON)7 V1PodSpec (io.kubernetes.client.openapi.models.V1PodSpec)7 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)5 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)4 V1Patch (io.kubernetes.client.custom.V1Patch)4 V1PodBuilder (io.kubernetes.client.openapi.models.V1PodBuilder)4