Search in sources :

Example 1 with TaintsBuilder

use of io.kubernetes.client.util.taints.Taints.TaintsBuilder 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)

Aggregations

CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)1 V1Node (io.kubernetes.client.openapi.models.V1Node)1 TaintsBuilder (io.kubernetes.client.util.taints.Taints.TaintsBuilder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1