-
Notifications
You must be signed in to change notification settings - Fork 271
/
Copy pathconfig-watcher-controller.yml
70 lines (69 loc) · 1.92 KB
/
config-watcher-controller.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Service account required for watching to resources
apiVersion: v1
kind: ServiceAccount
metadata:
name: config-watcher-controller
---
# Bind to 'edit' role to allow for watching resources and restarting pods
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: config-watcher-controller
subjects:
- kind: ServiceAccount
name: config-watcher-controller
roleRef:
name: edit
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
---
# Controller with kubeapi-proxy sidecar for easy access to the API server
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
project: k8spatterns
pattern: Controller
role: contoller
name: config-watcher-controller
spec:
replicas: 1
selector:
matchLabels:
app: config-watcher-controller
template:
metadata:
labels:
project: k8spatterns
pattern: Controller
app: config-watcher-controller
role: controller
spec:
# A serviceaccount is needed to watch events
# and to allow for restarting pods. For now its
# associated with the 'edit' role
serviceAccountName: config-watcher-controller
containers:
- name: kubeapi-proxy
image: k8spatterns/kubeapi-proxy
- name: config-watcher
image: k8spatterns/curl-jq
env:
# The operator watches the namespace in which the controller
# itself is installed (by using the Downward API)
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- "sh"
- "/watcher/config-watcher-controller.sh"
# Mount script from a config map for ease of change
volumeMounts:
- mountPath: "/watcher"
name: config-watcher-controller
volumes:
# Volume holding the controller script
- name: config-watcher-controller
configMap:
name: config-watcher-controller