...
1help(){
2 echo "MISSING ENVIRONMENT VARIABLES"
3 echo "export API_URL=https://dev1.edge-preprod.dev/api/v2"
4 echo "export API_BANNER=mailmen"
5 echo "export API_ORGANIZATION=edge-dev1-retail-b526aa"
6 echo "export API_USERNAME=<ncr id>"
7 echo "export API_PASSWORD=<edge password>"
8 exit
9}
10
11
12if [ -z "${API_URL}" ]; then
13 API_URL=https://dev1.edge-preprod.dev/api/v2
14fi
15
16if [ -z "${API_BANNER}" ]; then
17 API_BANNER=mailmen
18fi
19
20if [ -z "${API_ORGANIZATION}" ]; then
21 API_ORGANIZATION=edge-dev1-retail-b526aa
22fi
23
24if [ -z "${API_USERNAME}" ]; then
25 echo "API_USERNAME ENV NOT PROVIDED"
26 help
27fi
28
29if [ -z "${API_PASSWORD}" ]; then
30 echo "API_PASSWORD ENV NOT PROVIDED"
31 help
32fi
33
34
35STORE="$API_USERNAME-$(date +"%Y-%m-%d-%H-%M-%S")"
36
37echo "API_URL: $API_URL"
38echo "API_BANNER: $API_BANNER"
39echo "API_ORGANIZATION: $API_ORGANIZATION"
40echo "API_USERNAME: $API_USERNAME"
41echo "STORE_NAME: $STORE"
42
43k3d="$1"
44kubectl="$2"
45tag="$3"
46
47edge connect \
48 --banner="$API_BANNER" \
49 --organization="$API_ORGANIZATION" \
50 --store="$STORE" \
51 --create-site \
52 --kubeconfig="$HOME/.kube/config" \
53 --kubeconfig-context=k3d-ien-0 \
54 --cluster-type=dsds \
55 --api-endpoint="$API_URL" \
56 --username="$API_USERNAME" \
57 --password="$API_PASSWORD"
58
59 if [ $? -ne 0 ]; then
60 echo "could not connect cluster: $CLUSTER_ID"
61 exit
62 fi
63
64# register network services
65 edge networkservice register \
66 --username "$API_USERNAME" \
67 --password "$API_PASSWORD" \
68 --organization "$API_ORGANIZATION" \
69 --store "$STORE" \
70 --banner "$API_BANNER" \
71 --api-endpoint "$API_URL" \
72 --service-type kube-vip \
73 --ipv4 "10.10.11.2"
74 edge networkservice register \
75 --username "$API_USERNAME" \
76 --password "$API_PASSWORD" \
77 --organization "$API_ORGANIZATION" \
78 --store "$STORE" \
79 --banner "$API_BANNER" \
80 --api-endpoint "$API_URL" \
81 --service-type dns \
82 --ipv4 "8.8.8.8"
83 edge networkservice register \
84 --username "$API_USERNAME" \
85 --password "$API_PASSWORD" \
86 --organization "$API_ORGANIZATION" \
87 --store "$STORE" \
88 --banner "$API_BANNER" \
89 --api-endpoint "$API_URL" \
90 --service-type ntp \
91 --ipv6 "0.ubuntu.pool.ntp.org"
92
93# node registration
94CP_MAC_ADDRESS=$(docker network inspect k3d-ien-0 | jq '.[] | .Containers | to_entries[] | select(.value.Name == "k3d-ien-0-server-0")' | jq -r '.value.MacAddress')
95TP1_MAC_ADDRESS=$(docker network inspect k3d-ien-0 | jq '.[] | .Containers | to_entries[] | select(.value.Name == "k3d-ien-1-0")' | jq -r '.value.MacAddress')
96TP2_MAC_ADDRESS=$(docker network inspect k3d-ien-0 | jq '.[] | .Containers | to_entries[] | select(.value.Name == "k3d-ien-2-0")' | jq -r '.value.MacAddress')
97
98edge terminal register \
99 --username "$API_USERNAME" \
100 --password "$API_PASSWORD" \
101 --organization "$API_ORGANIZATION" \
102 --store "$STORE" \
103 --banner "$API_BANNER" \
104 --api-endpoint "$API_URL" \
105 --hostname "k3d-ien-0-server-0" \
106 --role "controlplane" \
107 --class "server" \
108 --lane "0" \
109 --mac "$CP_MAC_ADDRESS" \
110 --discover-disks "all" \
111 --prefix4 "1" \
112 --prefix6 "1" \
113 --dhcp4 "true"
114edge terminal register \
115 --username "$API_USERNAME" \
116 --password "$API_PASSWORD" \
117 --organization "$API_ORGANIZATION" \
118 --store "$STORE" \
119 --banner "$API_BANNER" \
120 --api-endpoint "$API_URL" \
121 --hostname "k3d-ien-1-0" \
122 --role "worker" \
123 --class "touchpoint" \
124 --lane "1" \
125 --mac "$TP1_MAC_ADDRESS" \
126 --discover-disks "all" \
127 --prefix4 "1" \
128 --prefix6 "1" \
129 --dhcp4 "true"
130edge terminal register \
131 --username "$API_USERNAME" \
132 --password "$API_PASSWORD" \
133 --organization "$API_ORGANIZATION" \
134 --store "$STORE" \
135 --banner "$API_BANNER" \
136 --api-endpoint "$API_URL" \
137 --hostname "k3d-ien-2-0" \
138 --role "worker" \
139 --class "touchpoint" \
140 --lane "2" \
141 --mac "$TP2_MAC_ADDRESS" \
142 --discover-disks "all" \
143 --prefix4 "1" \
144 --prefix6 "1" \
145 --dhcp4 "true"
146
147$kubectl -n warehouse-system scale --replicas=0 deployment/lumperctl
148
149if [ $? -ne 0 ]; then
150 echo "LUMPER NOT FOUND"
151 exit
152fi
153
154$kubectl create ns fluent-operator
155$kubectl create ns pxe
156$kubectl create ns vpn
157$kubectl create ns sds
158$kubectl create ns spegel
159$kubectl create ns edge-iam
160$kubectl create ns k8s-gateway
161$kubectl apply -f ../../config/pallets/sds/nodeagent/base/crds
162$kubectl apply -k ../../config/components/edge-iam-v2/crds
163$kubectl apply -f ../../config/components/edge-iam-v2/targets/env/kind/crds # Prometheus
164$kubectl apply -f ../../config/pallets/linkerdctl/linkerd-crds/linkerd-crds.yaml # LinkerD
165$kubectl apply -f ../../third_party/k8s/emissary/crds/emissary-crds.yaml # Emissary
166
167echo "Checking for shipments-sync kustomization"
168while ! $kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=ReconciliationSucceeded Kustomization shipments-sync -n edge-flux &> /dev/null
169do
170 echo "waiting for Kustomization shipments-sync"
171 sleep 2
172done
173
174echo "Checking for chariot-sync kustomization"
175while ! $kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=ReconciliationSucceeded Kustomization chariot-sync -n edge-flux &> /dev/null
176do
177 echo "waiting for Kustomization chariot-sync"
178 sleep 2
179done
180
181echo "Done with kustomizations"
182
183CLUSTER_ID=$($kubectl get Shipment --no-headers -o custom-columns=":metadata.name")
184if [ -z "${CLUSTER_ID}" ]; then
185 echo "SHIPMENT NOT FOUND"
186 exit
187fi
188
189echo "SHIPMENT: $CLUSTER_ID"
190
191kubectl patch Shipment "$CLUSTER_ID" --type=merge -p '{"metadata":{"annotations":{"kustomize.toolkit.fluxcd.io/reconcile":"disabled"}}}'
192
193$kubectl patch Shipment --type=merge -p '{"spec": {"pallets": [{"name":"datasync", "tag": '"\"$tag\""'}]}}' "$CLUSTER_ID"
194$kubectl patch Shipment --type=merge -p '{"spec": {"unpack": {"capabilities": [] }}}' "$CLUSTER_ID"
195
196$kubectl create ns data-sync-couchdb
197
198# prevent invalid characters in password for couchdb
199CLEAN_PASSWORD=$(echo "$API_PASSWORD" | tr -dc '[:alnum:]')
200$kubectl create secret generic couchdb-local-creds -n data-sync-couchdb --from-literal=username="$API_USERNAME" --from-literal=password="$CLEAN_PASSWORD" --from-literal=cookieAuthSecret=cookiemonster
201
202$kubectl -n warehouse-system scale --replicas=1 deployment/lumperctl
View as plain text