-
Notifications
You must be signed in to change notification settings - Fork 1
/
psmdb-transfer-managed-config.sh
executable file
·63 lines (53 loc) · 1.86 KB
/
psmdb-transfer-managed-config.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
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
62
63
#!/usr/bin/env bash
# Transfer ssl certificates and users from one cluster to another
transfer-managed-config() {
local managed=$1
local unmanaged=$2
local skipCertManager=$3
if [[ -z $managed ]] || [[ -z $unmanaged ]]; then
echo "Usage: transfer-managed-config <managed-cr-name> <unmanaged-cr-name> <skip-cert-manager>"
return 1
fi
if [[ -z "$skipCertManager" ]]; then
echo "---"
kubectl get issuer $managed-psmdb-ca -o yaml |
yq eval 'del(.status) |
del(.metadata) |
.metadata.name="'$unmanaged-psmdb-ca'"'
fi
echo "---"
kubectl get secret $managed-ssl-internal -o yaml |
yq eval 'del(.metadata) |
del(.status) |
.metadata.name="'$unmanaged-ssl-internal'"'
echo "---"
kubectl get secret $managed-ssl -o yaml |
yq eval 'del(.metadata) |
del(.status) |
.metadata.name="'$unmanaged-ssl'"'
if [[ -z "$skipCertManager" ]]; then
echo "---"
kubectl get certificate $managed-ssl -o yaml |
yq eval 'del(.metadata) |
del(.status) |
.metadata.name="'$unmanaged-ssl'" |
.spec.issuerRef.name="'$unmanaged-psmdb-ca'" |
.spec.secretName="'$unmanaged-ssl'"'
echo "---"
kubectl get certificate $managed-ssl-internal -o yaml |
yq eval 'del(.metadata) |
del(.status) |
.metadata.name="'$unmanaged-ssl-internal'" |
.spec.issuerRef.name="'$unmanaged-psmdb-ca'" |
.spec.secretName="'$unmanaged-ssl-internal'"'
fi
echo "---"
kubectl get secret $managed-secrets -o yaml |
yq eval 'del(.metadata) |
.metadata.name="'$unmanaged-secrets'"'
echo "---"
kubectl get secret internal-$managed-users -o yaml |
yq eval 'del(.metadata) |
.metadata.name="'internal-$unmanaged-users'"'
}
transfer-managed-config $@