Search in sources :

Example 11 with V1Node

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

the class KubectlGetTest method testGetOneNode.

@Test
public void testGetOneNode() throws KubectlException {
    V1Node node = new V1Node().metadata(new V1ObjectMeta().name("foo1"));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/nodes/foo1")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(node))));
    V1Node getNode = Kubectl.get(V1Node.class).apiClient(apiClient).skipDiscovery().name("foo1").execute();
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes/foo1")));
    assertEquals(node, getNode);
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) V1ObjectMeta(io.kubernetes.client.openapi.models.V1ObjectMeta) Test(org.junit.Test)

Example 12 with V1Node

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

the class KubectlAnnotateTest method testKubectlAnnotateClusterResourceShouldWork.

@Test
public void testKubectlAnnotateClusterResourceShouldWork() throws KubectlException {
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/nodes/foo")).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"foo\"}}")));
    wireMockRule.stubFor(put(urlPathEqualTo("/api/v1/nodes/foo")).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"foo\"}}")));
    V1Node annotatedNode = Kubectl.annotate(V1Node.class).apiClient(apiClient).skipDiscovery().name("foo").addAnnotation("k1", "v1").addAnnotation("k2", "v2").execute();
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes/foo")));
    wireMockRule.verify(1, putRequestedFor(urlPathEqualTo("/api/v1/nodes/foo")));
    assertNotNull(annotatedNode);
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) Test(org.junit.Test)

Example 13 with V1Node

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

the class KubectlDrain method doDrain.

private V1Node doDrain() throws KubectlException, ApiException, IOException {
    CoreV1Api api = new CoreV1Api(apiClient);
    V1Node node = performCordon();
    V1PodList allPods = api.listPodForAllNamespaces(null, null, "spec.nodeName=" + node.getMetadata().getName(), null, null, null, null, null, null, null);
    validatePods(allPods.getItems());
    for (V1Pod pod : allPods.getItems()) {
        deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
    }
    return node;
}
Also used : V1PodList(io.kubernetes.client.openapi.models.V1PodList) V1Node(io.kubernetes.client.openapi.models.V1Node) V1Pod(io.kubernetes.client.openapi.models.V1Pod) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api)

Example 14 with V1Node

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

the class KubectlTaint method executeInternal.

private V1Node executeInternal() throws KubectlException, ApiException, IOException {
    CoreV1Api v1 = new CoreV1Api(apiClient);
    V1Node node = v1.readNode(name, null);
    TaintsBuilder builder = Taints.taints(node);
    for (Map.Entry<String, Pair<String, String>> taint : addingTaints.entrySet()) {
        builder.addTaint(taint.getKey(), taint.getValue().getLeft(), makeEffect(taint.getValue().getRight()));
    }
    for (Map.Entry<String, String> taint : removeTaints.entrySet()) {
        if (taint.getValue() == null) {
            builder.removeTaint(taint.getKey());
        } else {
            builder.removeTaint(taint.getKey(), makeEffect(taint.getValue()));
        }
    }
    return v1.replaceNode(name, node, null, null, null, null);
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) TaintsBuilder(io.kubernetes.client.util.taints.Taints.TaintsBuilder) HashMap(java.util.HashMap) Map(java.util.Map) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Example 15 with V1Node

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

the class CoreV1Api method replaceNodeStatusWithHttpInfo.

/**
 * replace status of the specified Node
 *
 * @param name name of the Node (required)
 * @param body (required)
 * @param pretty If &#39;true&#39;, 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. (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 &#x60;ServerSideFieldValidation&#x60; 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)
 * @return ApiResponse&lt;V1Node&gt;
 * @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<V1Node> replaceNodeStatusWithHttpInfo(String name, V1Node body, String pretty, String dryRun, String fieldManager, String fieldValidation) throws ApiException {
    okhttp3.Call localVarCall = replaceNodeStatusValidateBeforeCall(name, body, pretty, dryRun, fieldManager, fieldValidation, null);
    Type localVarReturnType = new TypeToken<V1Node>() {
    }.getType();
    return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1Node(io.kubernetes.client.openapi.models.V1Node)

Aggregations

V1Node (io.kubernetes.client.openapi.models.V1Node)29 Type (java.lang.reflect.Type)14 Test (org.junit.Test)8 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)4 V1NodeList (io.kubernetes.client.openapi.models.V1NodeList)4 ApiClient (io.kubernetes.client.openapi.ApiClient)3 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)3 Pair (org.apache.commons.lang3.tuple.Pair)3 NodeMetrics (io.kubernetes.client.custom.NodeMetrics)2 PodMetrics (io.kubernetes.client.custom.PodMetrics)2 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)2 Lister (io.kubernetes.client.informer.cache.Lister)2 V1Pod (io.kubernetes.client.openapi.models.V1Pod)2 CallGeneratorParams (io.kubernetes.client.util.CallGeneratorParams)2 ArrayList (java.util.ArrayList)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 JobMasterAPI (edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI)1 Metrics (io.kubernetes.client.Metrics)1 ContainerMetrics (io.kubernetes.client.custom.ContainerMetrics)1 NodeMetricsList (io.kubernetes.client.custom.NodeMetricsList)1