diff --git a/cluster/addons/node-problem-detector/kubelet-user-standalone/npd-binding.yaml b/cluster/addons/node-problem-detector/kubelet-user-standalone/npd-binding.yaml new file mode 100644 index 00000000000..3d34fef427c --- /dev/null +++ b/cluster/addons/node-problem-detector/kubelet-user-standalone/npd-binding.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kubelet-user-npd-binding + labels: + kubernetes.io/cluster-service: "true" + addonmanager.kubernetes.io/mode: Reconcile +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:node-problem-detector +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: User + name: kubelet diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index 748aef03258..a6c5bbb6642 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -1245,6 +1245,12 @@ current-context: service-account-context EOF } +function create-node-problem-detector-kubeconfig-from-kubelet { + echo "Creating node-problem-detector kubeconfig from /var/lib/kubelet/kubeconfig" + mkdir -p /var/lib/node-problem-detector + cp /var/lib/kubelet/kubeconfig /var/lib/node-problem-detector/kubeconfig +} + function create-master-etcd-auth { if [[ -n "${ETCD_CA_CERT:-}" && -n "${ETCD_PEER_KEY:-}" && -n "${ETCD_PEER_CERT:-}" ]]; then local -r auth_dir="/etc/srv/kubernetes" @@ -2425,8 +2431,11 @@ EOF setup-addon-manifests "addons" "node-problem-detector" fi if [[ "${ENABLE_NODE_PROBLEM_DETECTOR:-}" == "standalone" ]]; then - # Setup role binding for standalone node problem detector. - setup-addon-manifests "addons" "node-problem-detector/standalone" "node-problem-detector" + # Setup role binding(s) for standalone node problem detector. + if [[ -n "${NODE_PROBLEM_DETECTOR_TOKEN:-}" ]]; then + setup-addon-manifests "addons" "node-problem-detector/standalone" + fi + setup-addon-manifests "addons" "node-problem-detector/kubelet-user-standalone" "node-problem-detector" fi if echo "${ADMISSION_CONTROL:-}" | grep -q "LimitRanger"; then setup-addon-manifests "admission-controls" "limit-range" "gce" @@ -2781,7 +2790,14 @@ function main() { create-kubeproxy-user-kubeconfig fi if [[ "${ENABLE_NODE_PROBLEM_DETECTOR:-}" == "standalone" ]]; then - create-node-problem-detector-kubeconfig ${KUBERNETES_MASTER_NAME} + if [[ -n "${NODE_PROBLEM_DETECTOR_TOKEN:-}" ]]; then + create-node-problem-detector-kubeconfig ${KUBERNETES_MASTER_NAME} + elif [[ -f "/var/lib/kubelet/kubeconfig" ]]; then + create-node-problem-detector-kubeconfig-from-kubelet + else + echo "Either NODE_PROBLEM_DETECTOR_TOKEN or /var/lib/kubelet/kubeconfig must be set" + exit 1 + fi fi fi