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);
}
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);
}
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;
}
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);
}
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 '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)
* @return ApiResponse<V1Node>
* @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);
}
Aggregations