-
Notifications
You must be signed in to change notification settings - Fork 0
/
injector.yaml
221 lines (219 loc) · 5.4 KB
/
injector.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
---
apiVersion: v1
kind: Namespace
metadata:
name: service-mesh
---
apiVersion: "v1"
kind: ServiceAccount
metadata:
name: service-mesh-injector
namespace: service-mesh
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: service-mesh-admission
namespace: service-mesh
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: service-mesh-admission
namespace: service-mesh
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: service-mesh-admission
subjects:
- kind: ServiceAccount
name: service-mesh-injector
namespace: service-mesh
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: service-mesh-admission
rules:
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["mutatingwebhookconfigurations"]
verbs: ["get", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: service-mesh-admission
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: service-mesh-admission
subjects:
- kind: ServiceAccount
name: service-mesh-injector
namespace: service-mesh
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-mesh-injector
namespace: service-mesh
spec:
replicas: 2
selector:
matchLabels:
app: service-mesh-injector
template:
metadata:
labels:
app: service-mesh-injector
spec:
containers:
- name: service-mesh-injector
image: diy-sm-injector
imagePullPolicy: IfNotPresent
env:
- name: TLS_CERT_FILE
value: /certs/tls.crt
- name: TLS_KEY_FILE
value: /certs/tls.key
# will be replaced by tilt
- name: IMAGE_TO_DEPLOY_PROXY
value: diy-sm-proxy:latest
# will be replaced by tilt
- name: IMAGE_TO_DEPLOY_PROXY_INIT
value: diy-sm-proxy-init:latest
ports:
- containerPort: 8443
volumeMounts:
- name: webhook-certs
mountPath: /certs
readOnly: true
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65532
seccompProfile:
type: RuntimeDefault
volumes:
- name: webhook-certs
secret:
secretName: service-mesh-injector-certs
---
apiVersion: v1
kind: Service
metadata:
name: service-mesh-injector
namespace: service-mesh
spec:
ports:
- port: 443
targetPort: 8443
selector:
app: service-mesh-injector
---
apiVersion: batch/v1
kind: Job
metadata:
name: injector-admission-create
namespace: service-mesh
spec:
template:
metadata:
name: injector-admission-create
spec:
containers:
- args:
- create
- --host=service-mesh-injector,service-mesh-injector.$(POD_NAMESPACE).svc
- --namespace=$(POD_NAMESPACE)
- --secret-name=service-mesh-injector-certs
- --cert-name=tls.crt
- --key-name=tls.key
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1@sha256:36d05b4077fb8e3d13663702fa337f124675ba8667cbd949c03a8e8ea6fa4366
imagePullPolicy: IfNotPresent
name: create
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65532
seccompProfile:
type: RuntimeDefault
restartPolicy: OnFailure
serviceAccountName: service-mesh-injector
---
apiVersion: batch/v1
kind: Job
metadata:
name: injector-admission-patch
namespace: service-mesh
spec:
template:
metadata:
name: injector-admission-patch
spec:
containers:
- args:
- patch
- --webhook-name=service-mesh-injector-webhook
- --namespace=$(POD_NAMESPACE)
- --patch-validating=false
- --patch-mutating=true
- --secret-name=service-mesh-injector-certs
- --patch-failure-policy=Fail
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1@sha256:36d05b4077fb8e3d13663702fa337f124675ba8667cbd949c03a8e8ea6fa4366
imagePullPolicy: IfNotPresent
name: patch
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65532
seccompProfile:
type: RuntimeDefault
restartPolicy: OnFailure
serviceAccountName: service-mesh-injector
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: service-mesh-injector-webhook
webhooks:
- name: service-mesh-injector.service-mesh.svc
clientConfig:
service:
name: service-mesh-injector
namespace: service-mesh
path: "/inject"
rules:
- operations: ["CREATE"]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
admissionReviewVersions: ["v1"]
sideEffects: None
timeoutSeconds: 5