Debian Codegraph @

internal/plugins/_mock/kms.yaml

raw
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 name: mock-kmsv2-provider
5 namespace: kube-system
6 labels:
7 tier: control-plane
8 component: mock-kmsv2-provider
9 spec:
10 # hostNetwork: true is required because the plugin is run as a static pod
11 # on the control plane node and needs to run before the CNI plugins are initialized.
12 hostNetwork: true
13 initContainers:
14 - args:
15 - |
16 #!/bin/sh
17 set -e
18 set -x
19
20 # if token exists, skip initialization
21 if [ $(ls -1 /var/lib/softhsm/tokens | wc -l) -ge 1 ]; then
22 echo "Skipping initialization of softhsm"
23 exit 0
24 fi
25
26 mkdir -p /var/lib/softhsm/tokens
27 apk add --update --no-cache ca-certificates jq
28 apk add --no-cache ccid opensc softhsm
29
30 TOKEN_LABEL=$(jq -r '.tokenLabel' /etc/softhsm-config.json)
31 PIN=$(jq -r '.pin' /etc/softhsm-config.json)
32 MODULE_PATH=$(jq -r '.path' /etc/softhsm-config.json)
33
34 softhsm2-util --init-token --free --label $TOKEN_LABEL --pin $PIN --so-pin $PIN
35 pkcs11-tool --module $MODULE_PATH --keygen --key-type aes:32 --pin $PIN --token-label $TOKEN_LABEL --label kms-test
36 command:
37 - /bin/sh
38 - -c
39 image: alpine:latest
40 imagePullPolicy: IfNotPresent
41 name: init-mock-kmsv2-provider
42 volumeMounts:
43 - mountPath: /var/lib/softhsm/tokens
44 name: softhsm-tokens
45 - mountPath: /etc/softhsm-config.json
46 name: softhsm-config
47 containers:
48 - name: mock-kmsv2-provider
49 image: localhost:5000/mock-kms-provider:e2e
50 imagePullPolicy: IfNotPresent
51 volumeMounts:
52 - name: sock
53 mountPath: /tmp
54 - name: softhsm-config
55 mountPath: /etc/softhsm-config.json
56 - name: softhsm-tokens
57 mountPath: /var/lib/softhsm/tokens
58 volumes:
59 - name: sock
60 hostPath:
61 path: /tmp
62 - name: softhsm-config
63 hostPath:
64 path: /etc/softhsm-config.json
65 type: File
66 - name: softhsm-tokens
67 hostPath:
68 path: /var/lib/softhsm/tokens
69 type: DirectoryOrCreate