forked from confidential-containers/trustee
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-kbs.sh
More file actions
executable file
·61 lines (49 loc) · 2.06 KB
/
Copy pathdeploy-kbs.sh
File metadata and controls
executable file
·61 lines (49 loc) · 2.06 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Environment variable that defines which directory to use the kustomization file for deployment.
DEPLOYMENT_DIR="${DEPLOYMENT_DIR:-overlays}"
OVERLAYS_DIR="overlays"
NVIDIA_VERIFIER_MODE="${NVIDIA_VERIFIER_MODE:-local}"
k8s_cnf_dir="$(dirname ${BASH_SOURCE[0]})"
if [ "$(uname -m)" == "s390x" ] && [ -n "${IBM_SE_CREDS_DIR:-}" ]; then
# We are using the ibm-se overlay
echo "ibm-se overlay being used as IBM_SE_CREDS_DIR was set"
OVERLAYS_DIR="${OVERLAYS_DIR}/ibm-se"
DEPLOYMENT_DIR="${DEPLOYMENT_DIR}/ibm-se"
export NODE_NAME=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}')
envsubst <"${k8s_cnf_dir}/${OVERLAYS_DIR}/pv.yaml" | kubectl apply -f -
fi
# Fail the script if the key.bin file does not exist.
key_file="${k8s_cnf_dir}/${OVERLAYS_DIR}/key.bin"
[[ -f "${key_file}" ]] || {
echo "key.bin not found at ${k8s_cnf_dir}/${OVERLAYS_DIR}/"
exit 1
}
# Create a file kbs.pem if it does not exist.
kbs_cert="${k8s_cnf_dir}/base/kbs.pem"
[[ -f "${kbs_cert}" ]] || {
openssl genpkey -algorithm ed25519 >"${k8s_cnf_dir}/base/kbs.key"
openssl pkey -in "${k8s_cnf_dir}/base/kbs.key" -pubout -out "${kbs_cert}"
}
# Enable the nvidia remote verifier if requested.
if [[ -n "${NVIDIA_VERIFIER_MODE}" ]]; then
config_file="${k8s_cnf_dir}/base/kbs-config.toml"
# Check if the section already exists
if grep -q '^\[attestation_service\.verifier_config\.nvidia_verifier\]' "${config_file}" 2>/dev/null; then
# Update existing type value
sed -i '/^\[attestation_service\.verifier_config\.nvidia_verifier\]/,/^\[/ {
s/^type = .*/type = "'"${NVIDIA_VERIFIER_MODE}"'"/
}' "${config_file}"
else
# Append new section
cat >> "${config_file}" << EOF
[attestation_service.verifier_config.nvidia_verifier]
type = "${NVIDIA_VERIFIER_MODE}"
EOF
fi
fi
if [[ "${DEPLOYMENT_DIR}" == "nodeport" || "${DEPLOYMENT_DIR}" == "overlays" ]]; then
kubectl apply -k "${k8s_cnf_dir}/${DEPLOYMENT_DIR}"
else
kubectl apply -k "${k8s_cnf_dir}/${DEPLOYMENT_DIR}"
fi