-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ metadata: | |
rules: | ||
- apiGroups: [""] | ||
resources: ["nodes"] | ||
verbs: ["get"] | ||
verbs: ["get", "patch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ metadata: | |
rules: | ||
- apiGroups: [""] | ||
resources: ["nodes"] | ||
verbs: ["get"] | ||
verbs: ["get", "patch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# Driver Options | ||
|
||
There are a couple of driver options that can be passed as arguments when starting the driver container. | ||
|
||
| Option argument | value sample | default | Description | | ||
|-----------------------------|---------------------------------------------------|-----------------------------------------------------|---------------------| | ||
| endpoint | tcp://127.0.0.1:10000/ | unix:///var/lib/csi/sockets/pluginproxy/csi.sock | The socket on which the driver will listen for CSI RPCs| | ||
| volume-attach-limit | 1,2,3 ... | -1 | Value for the maximum number of volumes attachable per node. If specified, the limit applies to all nodes. If not specified, the value is approximated from the instance type| | ||
| start-up-taint | true | false | If set to `true`, the driver will enable start-up taint support. Node taint with key `node.ebs.csi.aws.com/agent-not-ready` will be removed during the driver start-up | | ||
| extra-tags | key1=value1,key2=value2 | | Tags attached to each dynamically provisioned resource| | ||
| k8s-tag-cluster-id | aws-cluster-id-1 | | ID of the Kubernetes cluster used for tagging provisioned EBS volumes| | ||
| aws-sdk-debug-log | true | false | If set to true, the driver will enable the aws sdk debug log level| | ||
| logging-format | json | text | Sets the log format. Permitted formats: text, json| | ||
| aws-sdk-debug-log | true | false | If set to `true`, the driver will enable the aws sdk debug log level| | ||
| logging-format | json | text | Sets the log format. Permitted formats: `text`, `json`| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package cloud | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
k8sTypes "k8s.io/apimachinery/pkg/types" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
type JSONPatch struct { | ||
OP string `json:"op,omitempty"` | ||
Path string `json:"path,omitempty"` | ||
Value interface{} `json:"value"` | ||
} | ||
|
||
// RemoveNodeTaint patched the node, removes the taint that match NodeTaintKey | ||
func RemoveNodeTaint(k8sAPIClient KubernetesAPIClient, NodeTaintKey string) error { | ||
nodeName := os.Getenv("CSI_NODE_NAME") | ||
if nodeName == "" { | ||
return fmt.Errorf("CSI_NODE_NAME env var not set") | ||
} | ||
|
||
clientset, err := k8sAPIClient() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
node, err := clientset.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var taints []corev1.Taint | ||
hasTaint := false | ||
for _, taint := range node.Spec.Taints { | ||
if taint.Key != NodeTaintKey { | ||
taints = append(taints, taint) | ||
} else { | ||
hasTaint = true | ||
klog.InfoS("Node taint found") | ||
} | ||
} | ||
|
||
if !hasTaint { | ||
return fmt.Errorf("could not find node taint, key: %v, node: %v", NodeTaintKey, nodeName) | ||
} | ||
|
||
createStatusAndNodePatch := []JSONPatch{ | ||
{ | ||
OP: "test", | ||
Path: "/spec/taints", | ||
Value: node.Spec.Taints, | ||
}, | ||
{ | ||
OP: "replace", | ||
Path: "/spec/taints", | ||
Value: taints, | ||
}, | ||
} | ||
|
||
patch, err := json.Marshal(createStatusAndNodePatch) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = clientset.CoreV1().Nodes().Patch(context.TODO(), nodeName, k8sTypes.JSONPatchType, patch, metav1.PatchOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("failed to patch node when removing taint: error %w", err) | ||
} | ||
klog.InfoS("Successfully removed taint", "key", NodeTaintKey, "node", nodeName) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters