From d2e60fe9f099318654c7acfb2e5ef3c57038ff23 Mon Sep 17 00:00:00 2001 From: Erikson Tung Date: Tue, 15 Oct 2019 10:23:56 -0700 Subject: [PATCH] settings: adds new `node-labels`, `node-taints` settings Adds `node-labels` and `node-taints` settings for kubelet. Allows users to label and taint the node through userdata Updates README with descriptions of the new settings --- README.md | 13 +++++++++++++ packages/kubernetes/kubelet-env | 2 ++ packages/kubernetes/kubelet.service | 2 ++ workspaces/api/apiserver/src/model.rs | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 32c7667b37c..0df8aca76c2 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,19 @@ See the [setup guide](INSTALL.md) for *much* more detail on setting up Thar and * `settings.kubernetes.cluster-certificate`: This is the base64-encoded certificate authority of the cluster. * `settings.kubernetes.api-server`: This is the cluster's Kubernetes API endpoint. +The following settings can be optionally set to customize the node labels and taints. +* `settings.kubernetes.node-labels`: [Labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) in the form of key, value pairs added when registering the node in the cluster. +* `settings.kubernetes.node-taints`: [Taints](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) in the form of key, value and effect entries added when registering the node in the cluster. + * Example user data for setting up labels and taints: + ``` + [settings.kubernetes.node-labels] + label1 = "foo" + label2 = "bar" + [settings.kubernetes.node-taints] + dedicated = "experimental:PreferNoSchedule" + special = "true:NoSchedule" + ``` + The following settings are set for you automatically by [pluto](workspaces/api/) based on runtime instance information, but you can override them if you know what you're doing! * `settings.kubernetes.max-pods`: The maximum number of pods that can be scheduled on this node (limited by number of available IPv4 addresses) * `settings.kubernetes.cluster-dns-ip`: The CIDR block of the primary network interface. diff --git a/packages/kubernetes/kubelet-env b/packages/kubernetes/kubelet-env index d89d430b72a..e4eb941b1c2 100644 --- a/packages/kubernetes/kubelet-env +++ b/packages/kubernetes/kubelet-env @@ -1,2 +1,4 @@ NODE_IP={{settings.kubernetes.node-ip}} +NODE_LABELS={{join_map "=" "," "no-fail-if-missing" settings.kubernetes.node-labels}} +NODE_TAINTS={{join_map "=" "," "no-fail-if-missing" settings.kubernetes.node-taints}} POD_INFRA_CONTAINER_IMAGE={{settings.kubernetes.pod-infra-container-image}} diff --git a/packages/kubernetes/kubelet.service b/packages/kubernetes/kubelet.service index 88d0418d80b..ec050e3b35e 100644 --- a/packages/kubernetes/kubelet.service +++ b/packages/kubernetes/kubelet.service @@ -19,6 +19,8 @@ ExecStart=/usr/bin/kubelet \ --cert-dir /var/lib/kubelet/pki \ --volume-plugin-dir /var/lib/kubelet/plugins/volume/exec \ --node-ip ${NODE_IP} \ + --node-labels "${NODE_LABELS}" \ + --register-with-taints "${NODE_TAINTS}" \ --pod-infra-container-image ${POD_INFRA_CONTAINER_IMAGE} Restart=on-failure diff --git a/workspaces/api/apiserver/src/model.rs b/workspaces/api/apiserver/src/model.rs index 9ee2bfff9f4..81b63384439 100644 --- a/workspaces/api/apiserver/src/model.rs +++ b/workspaces/api/apiserver/src/model.rs @@ -55,6 +55,12 @@ pub struct KubernetesSettings { #[serde(skip_serializing_if = "Option::is_none")] pub api_server: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_labels: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + pub node_taints: Option>, + // Dynamic settings. #[serde(skip_serializing_if = "Option::is_none")]