-
Notifications
You must be signed in to change notification settings - Fork 1
/
3-register.sh
executable file
·30 lines (26 loc) · 1.19 KB
/
3-register.sh
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
#!/bin/bash
# set $cluster1 and $cluster2 kubeconfig
echo "Setting clusters kubeconfig $(pwd)/lab_clusters.sh"
source $(pwd)/lab_clusters.sh
function register_spire_entry() {
local kind_config=$1; shift
local spire_server=$1; shift
local spire_agent=$1; shift
local workload_name=$1; shift
local trust_domain=$1; shift
local federates_with_arg=$1; shift
echo "-------------------------"
echo "Registering workload: ${workload_name}"
kubectl exec -it --kubeconfig ${kind_config} \
-n spire "${spire_server}-0" \
-c "${spire_server}" \
-- bin/spire-server entry create \
-registrationUDSPath ../../run/spire/sockets/registration.sock \
-spiffeID "spiffe://${trust_domain}/${workload_name}" \
-parentID "spiffe://${trust_domain}/${spire_agent}" \
-selector "k8s:sa:${workload_name}-service-account" \
${federates_with_arg}
echo "-------------------------"
}
register_spire_entry $cluster1 "spire-server" "spire-agent" "server" "cluster1.com" "-federatesWith spiffe://cluster2.com"
register_spire_entry $cluster2 "spire-server" "spire-agent" "client" "cluster2.com" "-federatesWith spiffe://cluster1.com"