|
| 1 | +--- |
| 2 | +apiVersion: apps/v1 |
| 3 | +kind: Deployment |
| 4 | +metadata: |
| 5 | + name: create-prometheus-tls-certificate |
| 6 | + labels: |
| 7 | + app: create-prometheus-tls-certificate |
| 8 | +spec: |
| 9 | + replicas: 1 |
| 10 | + selector: |
| 11 | + matchLabels: |
| 12 | + app: create-prometheus-tls-certificate |
| 13 | + template: |
| 14 | + metadata: |
| 15 | + labels: |
| 16 | + app: create-prometheus-tls-certificate |
| 17 | + spec: |
| 18 | + serviceAccountName: create-prometheus-tls-certificate-serviceaccount |
| 19 | + containers: |
| 20 | + - name: create-prometheus-tls-certificate |
| 21 | + image: oci.stackable.tech/sdp/tools:1.0.0-stackable0.0.0-dev |
| 22 | + env: |
| 23 | + - name: POD_NAME |
| 24 | + valueFrom: |
| 25 | + fieldRef: |
| 26 | + fieldPath: metadata.name |
| 27 | + - name: POD_NAMESPACE |
| 28 | + valueFrom: |
| 29 | + fieldRef: |
| 30 | + fieldPath: metadata.namespace |
| 31 | + command: |
| 32 | + - bash |
| 33 | + - -euo |
| 34 | + - pipefail |
| 35 | + - -c |
| 36 | + - | |
| 37 | + # "kubectl create secret" fails on existing Secrets, so we "kubectl apply" instead |
| 38 | + kubectl create secret generic prometheus-tls-certificate \ |
| 39 | + --from-file=/prometheus-tls-certificate/ca.crt \ |
| 40 | + --from-file=/prometheus-tls-certificate/tls.crt \ |
| 41 | + --from-file=/prometheus-tls-certificate/tls.key \ |
| 42 | + --dry-run=client -o yaml \ |
| 43 | + | kubectl apply -f - |
| 44 | +
|
| 45 | + echo Sleeping 6 hours before deleting my own Pod |
| 46 | + sleep 21600 # 6 * 60 * 60 |
| 47 | +
|
| 48 | + echo "Deleting our own Pod, so that it gets re-created and secret-operator issues a new certificate (only crash-looping the container is not enough!)" |
| 49 | + kubectl --namespace "$POD_NAMESPACE" delete pod "$POD_NAME" |
| 50 | + exit 0 |
| 51 | + volumeMounts: |
| 52 | + - name: prometheus-tls-certificate |
| 53 | + mountPath: /prometheus-tls-certificate |
| 54 | + volumes: |
| 55 | + - name: prometheus-tls-certificate |
| 56 | + ephemeral: |
| 57 | + volumeClaimTemplate: |
| 58 | + metadata: |
| 59 | + annotations: |
| 60 | + # Highly professional tests have shown that Prometheus is able to handle the |
| 61 | + # certificate rotation :) |
| 62 | + # You can change the certificate lifetime here for easier testing: |
| 63 | + # secrets.stackable.tech/backend.autotls.cert.lifetime: "1d" |
| 64 | + secrets.stackable.tech/class: "tls" |
| 65 | + secrets.stackable.tech/format: "tls-pem" |
| 66 | + secrets.stackable.tech/scope: "service=prometheus" |
| 67 | + spec: |
| 68 | + accessModes: |
| 69 | + - ReadWriteOnce |
| 70 | + resources: |
| 71 | + requests: |
| 72 | + storage: "1" |
| 73 | + storageClassName: secrets.stackable.tech |
| 74 | + volumeMode: Filesystem |
| 75 | + securityContext: |
| 76 | + fsGroup: 1000 |
0 commit comments