add node-labeler
This commit is contained in:
parent
69dde5d035
commit
300d39e29e
1 changed files with 58 additions and 0 deletions
58
node-labeler/node-labeler.yaml
Normal file
58
node-labeler/node-labeler.yaml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: node-labeler
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: DaemonSet
|
||||||
|
metadata:
|
||||||
|
name: worker-node-labeler
|
||||||
|
namespace: node-labeler
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
role: worker-node-labeler
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
role: worker-node-labeler
|
||||||
|
spec:
|
||||||
|
tolerations:
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
containers:
|
||||||
|
- name: labeler
|
||||||
|
image: bitnami/kubectl
|
||||||
|
env:
|
||||||
|
- name: NODE_NAME
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: spec.nodeName
|
||||||
|
command: ["/bin/sh", "-c", "while true; do kubectl get node $(NODE_NAME) -o=jsonpath='{.metadata.labels}' | grep -q node-role.kubernetes.io/worker || kubectl label node $(NODE_NAME) node-role.kubernetes.io/worker=; sleep 60; done"]
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
restartPolicy: Always
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: worker-node-labeler-role
|
||||||
|
namespace: node-labeler
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["nodes"]
|
||||||
|
verbs: ["get", "patch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: worker-node-labeler-binding
|
||||||
|
namespace: node-labeler
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: default
|
||||||
|
namespace: node-labeler
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: worker-node-labeler-role
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
Loading…
Reference in a new issue