Skip to content

Commit 7e47e20

Browse files
add vault token syncer
1 parent 40c22b4 commit 7e47e20

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: "CronJob"
4+
metadata:
5+
name: "prometheus-vault-token-syncer"
6+
spec:
7+
schedule: "*/6 * * * *"
8+
concurrencyPolicy: Forbid
9+
jobTemplate:
10+
spec:
11+
backoffLimit: 0
12+
template:
13+
spec:
14+
restartPolicy: Never
15+
securityContext:
16+
runAsUser: 23764
17+
runAsGroup: 23764
18+
fsGroup: 23764
19+
runAsNonRoot: true
20+
seccompProfile:
21+
type: RuntimeDefault
22+
serviceAccountName: prometheus-vault-token-syncer
23+
containers:
24+
- name: "prometheus-vault-token-syncer"
25+
image: "ghcr.io/soerenschneider/prometheus-vault-token-syncer:latest"
26+
imagePullPolicy: "IfNotPresent"
27+
env:
28+
- name: "VAULT_MOUNT_PATH"
29+
value: "kubernetes"
30+
- name: "VAULT_ADDR"
31+
value: "https://vault.ha.soeren.cloud"
32+
- name: "VAULT_ROLE"
33+
value: "monitoring"
34+
- name: "SECRET_NAMESPACE"
35+
valueFrom:
36+
fieldRef:
37+
fieldPath: metadata.namespace
38+
securityContext:
39+
runAsUser: 23764
40+
runAsGroup: 23764
41+
runAsNonRoot: true
42+
privileged: false
43+
readOnlyRootFilesystem: true
44+
allowPrivilegeEscalation: false
45+
seccompProfile:
46+
type: RuntimeDefault
47+
capabilities:
48+
drop:
49+
- ALL
50+
resources:
51+
requests:
52+
memory: "64Mi"
53+
cpu: "5m"
54+
limits:
55+
memory: "1Gi"
56+
volumeMounts:
57+
- name: storage
58+
mountPath: /data
59+
volumes:
60+
- name: storage
61+
emptyDir: {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- cronjob.yaml
6+
- rbac.yaml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: prometheus-vault-token-syncer
6+
namespace: monitoring
7+
---
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: Role
10+
metadata:
11+
name: secret-writer
12+
namespace: monitoring
13+
rules:
14+
- apiGroups: [""]
15+
resources: ["secrets"]
16+
verbs: ["create", "update"]
17+
---
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
kind: RoleBinding
20+
metadata:
21+
name: prometheus-vault-token-syncer-binding
22+
namespace: monitoring
23+
subjects:
24+
- kind: ServiceAccount
25+
name: prometheus-vault-token-syncer
26+
namespace: monitoring
27+
roleRef:
28+
kind: Role
29+
name: secret-writer
30+
apiGroup: rbac.authorization.k8s.io
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1alpha1
3+
kind: Component
4+
patches:
5+
- target:
6+
kind: Deployment
7+
name: prometheus
8+
patch: |
9+
- op: add
10+
path: /spec/template/spec/volumes/-
11+
value:
12+
name: tokens
13+
secret:
14+
secretName: prometheus-vault-token
15+
optional: true
16+
- op: add
17+
path: /spec/template/spec/containers/0/volumeMounts/-
18+
value:
19+
name: tokens
20+
mountPath: /etc/tokens
21+
readOnly: true

0 commit comments

Comments
 (0)