Skip to content

Commit da23d5a

Browse files
committed
Add a pod to properly hide the metrics view
1 parent 9030221 commit da23d5a

File tree

2 files changed

+187
-2
lines changed

2 files changed

+187
-2
lines changed

tests/expected.yaml

+134-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
# Source: mapfish-print/charts/print/templates/pdb.yaml
33
apiVersion: policy/v1
44
kind: PodDisruptionBudget
5+
metadata:
6+
name: example-print-not-allowed
7+
labels:
8+
helm.sh/chart: print
9+
app.kubernetes.io/version: "1.0"
10+
app.kubernetes.io/managed-by: Helm
11+
app.kubernetes.io/name: print
12+
app.kubernetes.io/instance: example
13+
app.kubernetes.io/component: not-allowed
14+
spec:
15+
maxUnavailable: 1
16+
selector:
17+
matchLabels:
18+
app.kubernetes.io/name: print
19+
app.kubernetes.io/instance: example
20+
app.kubernetes.io/component: not-allowed
21+
---
22+
# Source: mapfish-print/charts/print/templates/pdb.yaml
23+
apiVersion: policy/v1
24+
kind: PodDisruptionBudget
525
metadata:
626
name: example-print-print
727
labels:
@@ -51,6 +71,8 @@ data:
5171
CHART_NAME: print
5272
RELEASE_NAME: example
5373
RELEASE_NAMESPACE: default
74+
SERVICE_NOT-ALLOWED_NAME: example-print-not-allowed
75+
SERVICE_NOT-ALLOWED_CONTAINER_NOT-ALLOWED_IMAGE_TAG: "master"
5476
SERVICE_PRINT_NAME: example-print-print
5577
SERVICE_PRINT_CONTAINER_JMX-EXPORTER_IMAGE_TAG: "0.18.0"
5678
SERVICE_PRINT_CONTAINER_PRINT_IMAGE_TAG: "3.30"
@@ -92,6 +114,30 @@ data:
92114
# Source: mapfish-print/charts/print/templates/service.yaml
93115
apiVersion: v1
94116
kind: Service
117+
metadata:
118+
name: example-print-not-allowed
119+
labels:
120+
helm.sh/chart: print
121+
app.kubernetes.io/version: "1.0"
122+
app.kubernetes.io/managed-by: Helm
123+
app.kubernetes.io/name: print
124+
app.kubernetes.io/instance: example
125+
app.kubernetes.io/component: not-allowed
126+
spec:
127+
type: ClusterIP
128+
ports:
129+
- name: http
130+
port: 80
131+
protocol: TCP
132+
targetPort: http
133+
selector:
134+
app.kubernetes.io/name: print
135+
app.kubernetes.io/instance: example
136+
app.kubernetes.io/component: not-allowed
137+
---
138+
# Source: mapfish-print/charts/print/templates/service.yaml
139+
apiVersion: v1
140+
kind: Service
95141
metadata:
96142
name: example-print-print
97143
labels:
@@ -105,7 +151,7 @@ spec:
105151
type: ClusterIP
106152
ports:
107153
- name: http
108-
port: 8080
154+
port: 80
109155
protocol: TCP
110156
targetPort: http
111157
selector:
@@ -116,6 +162,79 @@ spec:
116162
# Source: mapfish-print/charts/print/templates/deployment.yaml
117163
apiVersion: apps/v1
118164
kind: Deployment
165+
metadata:
166+
name: example-print-not-allowed
167+
labels:
168+
helm.sh/chart: print
169+
app.kubernetes.io/version: "1.0"
170+
app.kubernetes.io/managed-by: Helm
171+
app.kubernetes.io/name: print
172+
app.kubernetes.io/instance: example
173+
app.kubernetes.io/component: not-allowed
174+
spec:
175+
revisionHistoryLimit: 3
176+
strategy:
177+
type: RollingUpdate
178+
selector:
179+
matchLabels:
180+
app.kubernetes.io/name: print
181+
app.kubernetes.io/instance: example
182+
app.kubernetes.io/component: not-allowed
183+
template:
184+
metadata:
185+
labels:
186+
app.kubernetes.io/name: print
187+
app.kubernetes.io/instance: example
188+
app.kubernetes.io/component: not-allowed
189+
spec:
190+
imagePullSecrets:
191+
- name: example-print-docker-registry
192+
serviceAccountName: default
193+
securityContext:
194+
{}
195+
containers:
196+
- name: not-allowed
197+
securityContext:
198+
runAsNonRoot: true
199+
runAsUser: 33
200+
image: "camptocamp/maintenance@sha256:7cbddc1e17e422abc9d98781e9194a45f2c76f00dd8e4950c59bfc45f616f4a0"
201+
imagePullPolicy: IfNotPresent
202+
env:
203+
- name: "HEADLINE"
204+
value: Not allowed
205+
- name: "MESSAGE"
206+
value: You are not allowed to see the metrics
207+
- name: "RESPONSE_CODE"
208+
value: 403 Forbidden
209+
- name: "TITLE"
210+
value: Not allowed
211+
terminationMessagePolicy: FallbackToLogsOnError
212+
resources:
213+
limits:
214+
cpu: 0.2
215+
ephemeral-storage: 2Mi
216+
memory: 5Mi
217+
requests:
218+
cpu: 0.1
219+
ephemeral-storage: 1Mi
220+
memory: 500Ki
221+
volumeMounts:
222+
- mountPath: /data
223+
name: data
224+
225+
ports:
226+
- name: http
227+
containerPort: 8080
228+
protocol: TCP
229+
230+
231+
volumes:
232+
- name: data
233+
emptyDir: {}
234+
---
235+
# Source: mapfish-print/charts/print/templates/deployment.yaml
236+
apiVersion: apps/v1
237+
kind: Deployment
119238
metadata:
120239
name: example-print-print
121240
labels:
@@ -351,6 +470,13 @@ spec:
351470
- host: "print.example.com"
352471
http:
353472
paths:
473+
- path: "/metrics"
474+
pathType: Prefix
475+
backend:
476+
service:
477+
name: example-print-not-allowed
478+
port:
479+
number: 80
354480
- path: "/"
355481
pathType: Prefix
356482
backend:
@@ -381,6 +507,13 @@ spec:
381507
- host: "my-technical-url.example.com"
382508
http:
383509
paths:
510+
- path: "/metrics"
511+
pathType: Prefix
512+
backend:
513+
service:
514+
name: example-print-not-allowed
515+
port:
516+
number: 80
384517
- path: "/"
385518
pathType: Prefix
386519
backend:

values.yaml

+53-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ print:
6262
servicePort: 80
6363
ports:
6464
- name: http
65-
port: 8080
65+
port: 80
6666
protocol: TCP
6767
targetPort: http
6868

@@ -272,3 +272,55 @@ print:
272272
memory: 2Gi
273273
cpu: '2'
274274
ephemeral-storage: 256Mi
275+
276+
not-allowed:
277+
enabled: true
278+
279+
service:
280+
type: ClusterIP
281+
servicePort: 80
282+
ports:
283+
- name: http
284+
port: 80
285+
protocol: TCP
286+
targetPort: http
287+
288+
ingress:
289+
enabled: true
290+
path: /metrics
291+
292+
containers:
293+
not-allowed:
294+
image:
295+
repository: camptocamp/maintenance
296+
tag: master
297+
sha: 7cbddc1e17e422abc9d98781e9194a45f2c76f00dd8e4950c59bfc45f616f4a0 # Managed by update-image-hash script
298+
299+
env:
300+
RESPONSE_CODE:
301+
value: 403 Forbidden
302+
TITLE:
303+
value: Not allowed
304+
HEADLINE:
305+
value: Not allowed
306+
MESSAGE:
307+
value: You are not allowed to see the metrics
308+
ports:
309+
http:
310+
containerPort: 8080
311+
protocol: TCP
312+
volumeMounts:
313+
/data:
314+
name: data
315+
resources:
316+
requests:
317+
ephemeral-storage: 1Mi
318+
memory: 500Ki
319+
cpu: 0.1
320+
limits:
321+
ephemeral-storage: 2Mi
322+
memory: 5Mi
323+
cpu: 0.2
324+
volumes:
325+
data:
326+
emptyDir: {}

0 commit comments

Comments
 (0)