-
Notifications
You must be signed in to change notification settings - Fork 39
/
update-operator.yaml
275 lines (275 loc) · 7.63 KB
/
update-operator.yaml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
apiVersion: v1
kind: Namespace
metadata:
name: bottlerocket
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: bottlerocket-update-operator-controller
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch", "update", "patch"]
# Allow the controller to remove Pods running on the Nodes that are updating.
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: bottlerocket-update-operator-controller
subjects:
- kind: ServiceAccount
name: update-operator-controller
namespace: bottlerocket
roleRef:
kind: ClusterRole
name: bottlerocket-update-operator-controller
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: bottlerocket-update-operator-agent
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: bottlerocket-update-operator-agent
subjects:
- kind: ServiceAccount
name: update-operator-agent
namespace: bottlerocket
roleRef:
kind: ClusterRole
name: bottlerocket-update-operator-agent
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: update-operator-controller
namespace: bottlerocket
annotations:
kubernetes.io/service-account.name: update-operator-controller
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: update-operator-agent
namespace: bottlerocket
annotations:
kubernetes.io/service-account.name: update-operator-agent
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: update-operator-controller
namespace: bottlerocket
labels:
update-operator: controller
spec:
replicas: 1
strategy:
rollingUpdate:
maxUnavailable: 100%
selector:
matchLabels:
update-operator: controller
template:
metadata:
namespace: bottlerocket
labels:
update-operator: controller
spec:
serviceAccountName: update-operator-controller
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: bottlerocket.aws/updater-interface-version
operator: Exists
- key: "kubernetes.io/os"
operator: In
values:
- linux
- key: "kubernetes.io/arch"
operator: In
values:
- amd64
- arm64
# Avoid update-operator's Agent Pods if possible.
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 10
podAffinityTerm:
topologyKey: bottlerocket.aws/updater-interface-version
labelSelector:
matchExpressions:
- key: update-operator
operator: In
values: ["agent"]
containers:
- name: controller
image: "public.ecr.aws/bottlerocket/bottlerocket-update-operator:v0.1.4"
imagePullPolicy: Always
args:
- -controller
- -debug
- -nodeName
- $(NODE_NAME)
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
---
# This DaemonSet is for Bottlerocket hosts that support updates through the Bottlerocket API (Bottlerocket OS versions >= v0.4.1)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: update-operator-agent-update-api
namespace: bottlerocket
labels:
update-operator: agent
spec:
selector:
matchLabels:
update-operator: agent
template:
metadata:
labels:
update-operator: agent
spec:
serviceAccountName: update-operator-agent
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "bottlerocket.aws/updater-interface-version"
operator: In
values:
- 2.0.0
- key: "kubernetes.io/os"
operator: In
values:
- linux
- key: "kubernetes.io/arch"
operator: In
values:
- amd64
- arm64
hostPID: true
containers:
- name: agent
image: "public.ecr.aws/bottlerocket/bottlerocket-update-operator:v0.1.4"
imagePullPolicy: Always
args:
- -agent
- -debug
- -nodeName
- $(NODE_NAME)
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
resources:
limits:
memory: 50Mi
requests:
cpu: 10m
memory: 50Mi
volumeMounts:
- name: bottlerocket-api-socket
mountPath: /run/api.sock
securityContext:
seLinuxOptions:
user: system_u
role: system_r
type: super_t
level: s0
volumes:
- name: bottlerocket-api-socket
hostPath:
path: /run/api.sock
type: Socket
---
# This DaemonSet is for Bottlerocket hosts that can only support updates through updog (Bottlerocket OS versions < v0.4.1)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: update-operator-agent-updog
namespace: bottlerocket
labels:
update-operator: agent
spec:
selector:
matchLabels:
update-operator: agent
template:
metadata:
labels:
update-operator: agent
spec:
serviceAccountName: update-operator-agent
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "bottlerocket.aws/updater-interface-version"
operator: In
values:
- 1.0.0
- key: "kubernetes.io/os"
operator: In
values:
- linux
- key: "kubernetes.io/arch"
operator: In
values:
- amd64
- arm64
hostPID: true
containers:
- name: agent
image: "public.ecr.aws/bottlerocket/bottlerocket-update-operator:v0.1.4"
imagePullPolicy: Always
# XXX: tty required to exec binaries that use `simplelog` until https://github.com/bottlerocket-os/bottlerocket/issues/576 is resolved.
tty: true
args:
- -agent
- -debug
- -nodeName
- $(NODE_NAME)
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
# Required for executing OS update operations.
privileged: true
resources:
limits:
memory: 600Mi
requests:
cpu: 100m
memory: 600Mi
volumeMounts:
- name: rootfs
mountPath: /.bottlerocket/rootfs
volumes:
- name: rootfs
hostPath:
path: /
type: Directory