-
Notifications
You must be signed in to change notification settings - Fork 3
/
tap_manageaccess.sh
138 lines (115 loc) · 3.63 KB
/
tap_manageaccess.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Cleanup old secrets if they exist
# Arg 1 = secret name
# Arg 2 = namespace name
function cleanSecret(){
CHECK=$(kubectl get secret -n $2 $1 2>&1)
if [[ $CHECK != *"NotFound"* ]]; then
log "Cleanup old secret"
kubectl delete secret -n $2 $1 >null
fi
}
# Add Pivnet access
# log "Add Pivnet registry credentials"
cleanSecret tap-registry tap-install
tanzu secret registry add tap-registry \
--username $PIVNET_ACCOUNT \
--password $PIVNET_PASSWORD \
--server registry.tanzu.vmware.com \
--namespace tap-install \
--export-to-all-namespaces \
--yes > /dev/null 2>&1
# Add internal registry credentials
log "Add internal registry credentials"
cleanSecret registry-credentials tap-install
tanzu secret registry add registry-credentials \
--username $REGISTRY_ACCOUNT \
--password "$REGISTRY_PASSWORD" \
--server $REGISTRY_HOST \
--namespace tap-install \
--export-to-all-namespaces \
--yes > /dev/null 2>&1
# Add internal registry credentials
log "Add internal registry credentials for local proxy"
cleanSecret lsp-registry-credentials tap-install
tanzu secret registry add lsp-registry-credentials \
--username $REGISTRY_ACCOUNT \
--password "$REGISTRY_PASSWORD" \
--server $REGISTRY_HOST \
--namespace tap-install \
--export-to-all-namespaces \
--yes > /dev/null 2>&1
# Add git repo credentials
log "Add Git Repository credentials"
cleanSecret git-access tap-install
cleanSecret git-access tap-namespace-provisioning
kubectl apply -n tap-install -f - << EOF > /dev/null 2>&1
apiVersion: v1
kind: Secret
metadata:
name: git-access
type: Opaque
stringData:
username: $GITOPS_ACCOUNT
password: $GIT_ACCESS_TOKEN
EOF
# Add ns configs
log "Add NS pinned configs"
# cleanSecret team-secret-store tap-install
# kubectl apply -n tap-install -f - << EOF > /dev/null 2>&1
# apiVersion: v1
# kind: Secret
# metadata:
# name: team-secret-store
# type: Opaque
# stringData:
# content.yaml: |
# alpha:
# username: alphauser
# password: alphapass
# beta:
# username: betaauser
# password: betaapass
# charlie:
# username: charlieuser
# password: charliepass
# delta:
# username: deltauser
# password: deltapass
# EOF
# Add git repo credentials for namespace proviosing
log "Prep namespace provioner values"
cleanSecret git-auth tap-install
cleanSecret git-auth tap-namespace-provisioning
kubectl apply -n tap-install -f - << EOF > /dev/null 2>&1
apiVersion: v1
kind: Secret
metadata:
name: git-auth
type: Opaque
stringData:
content.yaml: |
git:
host: $GITOPS_SERVER
username: $GITOPS_ACCOUNT
password: $GIT_ACCESS_TOKEN
EOF
log "Add namespace provioner overlay"
cleanSecret git-auth-overlay tap-install
cleanSecret git-auth-overlay tap-namespace-provisioning
kubectl apply -n tap-install -f - << EOF > /dev/null 2>&1
apiVersion: v1
kind: Secret
metadata:
name: git-auth-overlay
namespace: tap-install
annotations:
kapp.k14s.io/change-rule: "delete after deleting tap"
stringData:
git-auth-overlay.yaml: |
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"apiVersion": "v1", "kind": "ServiceAccount","metadata":{"name":"default"}}), expects="0+"
---
secrets:
#@overlay/append
- name: git
EOF