Search in sources :

Example 6 with V1Node

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

the class CoreV1Api method replaceNodeStatusAsync.

/**
 * (asynchronously) replace status of the specified Node
 *
 * @param name name of the Node (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. (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 _callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 * @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 okhttp3.Call replaceNodeStatusAsync(String name, V1Node body, String pretty, String dryRun, String fieldManager, String fieldValidation, final ApiCallback<V1Node> _callback) throws ApiException {
    okhttp3.Call localVarCall = replaceNodeStatusValidateBeforeCall(name, body, pretty, dryRun, fieldManager, fieldValidation, _callback);
    Type localVarReturnType = new TypeToken<V1Node>() {
    }.getType();
    localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
    return localVarCall;
}
Also used : Type(java.lang.reflect.Type) V1Node(io.kubernetes.client.openapi.models.V1Node)

Example 7 with V1Node

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

the class KubectlDrainTest method testDrainNodeNoPods.

@Test
public void testDrainNodeNoPods() throws KubectlException, IOException {
    // /api/v1/pods?fieldSelector=spec.nodeName%3Dkube3
    wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/nodes/node1")).willReturn(aResponse().withStatus(200).withBody("{\"metadata\": { \"name\": \"node1\" } }")));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/pods")).withQueryParam("fieldSelector", equalTo("spec.nodeName=node1")).willReturn(aResponse().withStatus(200).withBody("{}")));
    V1Node node = new KubectlDrain().skipDiscovery().apiClient(apiClient).name("node1").execute();
    wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/nodes/node1")));
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/pods")));
    assertEquals("node1", node.getMetadata().getName());
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) Test(org.junit.Test)

Example 8 with V1Node

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

the class KubectlDrainTest method testDrainNodePods.

@Test
public void testDrainNodePods() throws KubectlException, IOException {
    // /api/v1/pods?fieldSelector=spec.nodeName%3Dkube3
    wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/nodes/node1")).willReturn(aResponse().withStatus(200).withBody("{\"metadata\": { \"name\": \"node1\" } }")));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/pods")).withQueryParam("fieldSelector", equalTo("spec.nodeName=node1")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(POD_LIST_API))))));
    wireMockRule.stubFor(delete(urlPathEqualTo("/api/v1/namespaces/mssql/pods/mssql-75b8b44f6b-znftp")).willReturn(aResponse().withStatus(200).withBody("{}")));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/namespaces/mssql/pods/mssql-75b8b44f6b-znftp")).willReturn(aResponse().withStatus(404).withBody("{}")));
    V1Node node = new KubectlDrain().skipDiscovery().apiClient(apiClient).name("node1").execute();
    wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/nodes/node1")));
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/pods")));
    wireMockRule.verify(1, deleteRequestedFor(urlPathEqualTo("/api/v1/namespaces/mssql/pods/mssql-75b8b44f6b-znftp")));
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/namespaces/mssql/pods/mssql-75b8b44f6b-znftp")));
    assertEquals("node1", node.getMetadata().getName());
    assertEquals(0, findUnmatchedRequests().size());
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) Test(org.junit.Test)

Example 9 with V1Node

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

the class KubectlLabelTest method testKubectlLabelClusterResourceShouldWork.

@Test
public void testKubectlLabelClusterResourceShouldWork() 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 labelledNode = Kubectl.label(V1Node.class).apiClient(apiClient).skipDiscovery().name("foo").addLabel("k1", "v1").addLabel("k2", "v2").execute();
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes/foo")));
    wireMockRule.verify(1, putRequestedFor(urlPathEqualTo("/api/v1/nodes/foo")));
    assertNotNull(labelledNode);
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) Test(org.junit.Test)

Example 10 with V1Node

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

the class KubectlGetTest method testGetAllNodes.

@Test
public void testGetAllNodes() throws KubectlException {
    V1NodeList nodeList = new V1NodeList().items(Arrays.asList(new V1Node().metadata(new V1ObjectMeta().name("foo1")), new V1Node().metadata(new V1ObjectMeta().name("foo2"))));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/nodes")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(nodeList))));
    List<V1Node> nodes = Kubectl.get(V1Node.class).apiClient(apiClient).skipDiscovery().execute();
    wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes")));
    assertEquals(2, nodes.size());
}
Also used : V1Node(io.kubernetes.client.openapi.models.V1Node) V1ObjectMeta(io.kubernetes.client.openapi.models.V1ObjectMeta) V1NodeList(io.kubernetes.client.openapi.models.V1NodeList) Test(org.junit.Test)

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