Skip to content

Instantly share code, notes, and snippets.

@a0s
Last active November 26, 2025 15:46
Show Gist options
  • Select an option

  • Save a0s/5edf94604f0a4b0d76ba070dee5a6f4d to your computer and use it in GitHub Desktop.

Select an option

Save a0s/5edf94604f0a4b0d76ba070dee5a6f4d to your computer and use it in GitHub Desktop.
Remove control-plane:NoSchedule taint with daemonset
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: remove-control-plane-taint
namespace: kube-system
spec:
selector:
matchLabels:
name: remove-control-plane-taint
template:
metadata:
labels:
name: remove-control-plane-taint
spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: remove-taint
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
while true; do
OUTPUT=$$(kubectl taint nodes $${NODE_NAME} node-role.kubernetes.io/control-plane:NoSchedule- 2>&1)
EXIT_CODE=$$?
if [ $$EXIT_CODE -eq 0 ]; then
echo "Taint removed successfully, entering infinite sleep"
sleep infinity
elif echo "$$OUTPUT" | grep -q "not found"; then
echo "Taint already removed, entering infinite sleep"
sleep infinity
else
sleep 10
fi
done
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
hostNetwork: true
serviceAccountName: remove-taint-sa
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: remove-taint-sa
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: remove-taint-role
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: remove-taint-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: remove-taint-role
subjects:
- kind: ServiceAccount
name: remove-taint-sa
namespace: kube-system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment