generated from crossplane/provider-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devspace.yaml
308 lines (275 loc) · 10.3 KB
/
devspace.yaml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
version: v2beta1
name: provider-natssecrets
vars:
ca_root:
command: echo $HOME/.devspace/ca/
creds_dir:
command: echo .devspace/creds/
commands:
help: |-
#!/bin/bash
set -e
GREEN='\033[0;32m'
BRED='\033[3;31m'
BGREEN='\033[1;32m'
GREY='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m' # No Color
echo -e "${BGREEN}Usage of ${BRED}edgefarm.core:${NC}"
echo -e "${GREEN} General cluster commands:${NC}"
echo -e "${BOLD} devspace run create-kind-cluster ${GREY}Creates a local running Kubernetes cluster with kind${NC}"
echo -e "${BOLD} devspace run delete-kind-cluster ${GREY}Deletes the local running Kubernetes cluster with kind${NC}"
echo -e "${BOLD} devspace run-pipeline init ${GREY}Deploy some basic resources to the cluster${NC}"
echo -e "${GREEN} EdgeFarm related commands:${NC}"
echo -e "${BOLD} devspace run-pipeline deploy-vault ${GREY}Deploy the vault with NATS secrets plugin${NC}"
echo -e "${BOLD} devspace run-pipeline deploy-crossplane ${GREY}Deploy crossplane and provider-natssecrets${NC}"
echo -e "${BOLD} devspace run-pipeline deploy-nats ${GREY}Deploy the deploy preconfigured a NATS server${NC}"
echo -e "${BOLD} devspace run-pipeline create-custom-nats-account ${GREY}Create a custom NATS account and user${NC}"
check-prerequisites: |-
#!/bin/bash
set -e
# Check if kubectl is installed
if ! command -v kubectl &> /dev/null
then
echo "kubectl could not be found. Please install kubectl."
exit
fi
# Check if mkcert is installed
if ! command -v mkcert &> /dev/null
then
echo "mkcert could not be found. Please install mkcert (https://github.com/FiloSottile/mkcert)."
exit
fi
# Check if jq is installed
if ! command -v jq &> /dev/null
then
echo "jq could not be found. Please install jq (https://stedolan.github.io/jq/)."
exit
fi
# Check if helm is installed
if ! command -v helm &> /dev/null
then
echo "helm could not be found. Please install helm (https://helm.sh/docs/intro/install/)."
exit
fi
# Check if kustomize is installed
if ! command -v kustomize &> /dev/null
then
echo "kustomize could not be found. Please install kustomize (https://kubectl.docs.kubernetes.io/installation/kustomize/)."
exit
fi
# Check if docker is installed
if ! command -v docker &> /dev/null
then
echo "docker could not be found. Please install docker (https://docs.docker.com/get-docker/)."
exit
fi
create-kind-cluster: |-
#!/bin/bash
set -e
devspace run check-prerequisites
# Check if kind is installed
if ! command -v kind &> /dev/null
then
echo "kind could not be found. Please install kind (https://kind.sigs.k8s.io/docs/user/quick-start/#installation)."
exit
fi
kind create cluster --name natssecrets --image kindest/node:v1.24.7 --config dev/kind/config.yaml
kubectl config use-context kind-natssecrets
kubectl config set-context --current --namespace kind-natssecrets
delete-kind-cluster: |-
#!/bin/bash
set -e
kind delete cluster --name natssecrets || true
kubectl config delete-context kind-natssecrets 2>/dev/null || true
kubectl config delete-cluster kind-natssecrets 2>/dev/null || true
kubectl config delete-user admin@kind-natssecrets 2>/dev/null || true
functions:
wait_for_crd: |-
#!/bin/bash
set -e
echo "wait for crd/$1"
until kubectl wait --for=condition=established "crd/$1" --timeout=60s 2>/dev/null; do echo -n "." && sleep 2; done
wait_for_deployment: |-
#!/bin/bash
set -e
echo "wait for deployment/$1 (ns: $2)"
until kubectl wait --for=condition=available deployment/$1 -n $2 --timeout=60s 2>/dev/null; do echo -n "." && sleep 2; done
wait_for_pod: |-
#!/bin/bash
set -e
echo "wait for pod $1 (ns: $2)"
until kubectl wait --for=condition=ready pod -n $2 $1 --timeout=60s 2>/dev/null; do echo -n "." && sleep 2; done
wait_for_ressource: |-
#!/bin/bash
set -e
echo "wait for ressource $1 (ns: $2)"
until kubectl get $1 -n $2 2>/dev/null; do echo -n "." && sleep 2; done;
wait_for_secret_key: |-
#!/bin/bash
set -e
echo "wait for key $3 in secret $1 (ns: $2)"
until [[ $(kubectl get secret/$1 -n $2 -o yaml | grep $3 | wc -l) -ge 1 ]] ; do echo -n "." && sleep 2; done
echo " done"
import_root_ca: |-
# usage: import_root_ca <CAROOT> <secret name> <namespace>
#!/usr/bin/env bash
set -e
set -u
export CAROOT=${1}
if [ "$#" -ne 3 ]; then
echo "Illegal number of parameters"
echo "import_root_ca <CAROOT> <ca_secret_name> <ca_secret_namespace>"
exit 1
fi
if ! [ -d "${CAROOT}" ]; then
echo "Creating self-signed CA ${2}"
mkdir -p ${CAROOT}
mkcert || true
fi
kubectl -n ${3} create secret tls ${2} \
--key=${CAROOT}/rootCA-key.pem \
--cert=${CAROOT}/rootCA.pem \
--dry-run=client --output yaml | kubectl apply -f -
init_ca: |-
# usage init_ca <CAROOT>
#!/usr/bin/env bash
set -e
set -u
export CAROOT=${1}
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
echo "init_ca"
exit 1
fi
echo "installing ${CAROOT}"
mkcert -install || true
pipelines:
init: |-
#!/bin/bash
set -e
devspace run check-prerequisites
# install cert-manager and nginx-ingress
create_deployments cert-manager nginx-ingress
wait_for_deployment cert-manager cert-manager
wait_for_deployment cert-manager-cainjector cert-manager
wait_for_deployment cert-manager-webhook cert-manager
wait_for_crd certificates.cert-manager.io
wait_for_pod "-l app.kubernetes.io/instance=ingress-nginx -l app.kubernetes.io/component=controller" ingress-nginx
# install root certificate for cert-manager
init_ca ${ca_root}
import_root_ca ${ca_root} root-ca cert-manager
create_deployments cert-manager-config
deploy-vault: |-
#!/bin/bash
set -e
devspace run check-prerequisites
COLOR='\033[0;93m'
NC='\033[0m'
create_deployments vault-operator
wait_for_pod "-l app.kubernetes.io/instance=vault-operator" vault
create_deployments vault-config
until kubectl wait --for=condition=ready pods -n vault -l vault_cr=vault --timeout=60s 2>/dev/null; do echo -n "." && sleep 2; done
wait_for_secret_key bank-vaults vault vault-root
echo "vault-root-token: $(kubectl get secrets bank-vaults -n vault -o jsonpath={.data.vault-root} | base64 --decode)"
deploy-crossplane: |-
#!/bin/bash
set -e
devspace run check-prerequisites
# create_deployments crossplane
# wait_for_deployment crossplane crossplane-system
# wait_for_deployment crossplane-rbac-manager crossplane-system
create_deployments provider-natssecrets
kubectl wait --for=condition=installed --for=condition=healthy providers.pkg.crossplane.io provider-natssecrets
# VAULT_TOKEN=$(kubectl get secrets bank-vaults -n vault -o jsonpath={.data.vault-root} | base64 --decode)
# TEMPLATE=$(sed "s/VAULT_TOKEN/$VAULT_TOKEN/g" dev/manifests/resources/providerconfig/providerconfigsecret.yaml.tmpl)
# echo "$TEMPLATE" | kubectl apply -f -
# kubectl apply -f dev/manifests/resources/providerconfig/providerconfig.yaml
# kubectl apply -f dev/manifests/resources/stage1 --recursive
deploy-nats: |-
#!/bin/bash
set -e
OPERATOR_JWT=$(kubectl get secrets myoperator -n crossplane-system -o jsonpath='{.data.jwt}' | base64 -d)
SYS_ACCOUNT_PUBLIC_KEY=$(kubectl get secrets sys -n crossplane-system -o jsonpath='{.data.pub}' | base64 -d)
SYS_ACCOUNT_JWT=$(kubectl get secrets sys -n crossplane-system -o jsonpath='{.data.jwt}' | base64 -d)
TEMPLATE=$(sed "s/OPERATOR_JWT/$OPERATOR_JWT/g" dev/manifests/nats/configmap.yaml.template)
TEMPLATE=$(sed "s/SYS_ACCOUNT_PUBLIC_KEY/$SYS_ACCOUNT_PUBLIC_KEY/g" <<< $TEMPLATE)
TEMPLATE=$(sed "s/SYS_ACCOUNT_JWT/$SYS_ACCOUNT_JWT/g" <<< $TEMPLATE)
echo "$TEMPLATE" > dev/manifests/nats/configmap.yaml
create_deployments nats
wait_for_deployment nats nats
kubectl get operators -o wide
kubectl get accounts -o wide
kubectl get users -o wide
create-custom-nats-account: |-
#!/bin/bash
set -e
kubectl apply -f dev/manifests/resources/stage2 --recursive
mkdir -p ${creds_dir}
kubectl get secrets -n crossplane-system myuser -o jsonpath='{.data.creds}' | base64 -d > ${creds_dir}/creds
kubectl get operators -o wide
kubectl get accounts -o wide
kubectl get users -o wide
purge-nats: |-
#!/bin/bash
set -e
kubectl delete -f dev/manifests/nats/configmap.yaml
kubectl delete -f dev/manifests/nats/deployment.yaml
kubectl delete -f dev/manifests/nats/service.yaml
deployments:
local-path-provisioner:
kubectl:
manifests:
- "https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.22/deploy/local-path-storage.yaml"
namespace: kube-system
cert-manager:
kubectl:
manifests:
- https://github.com/cert-manager/cert-manager/releases/download/v1.9.1/cert-manager.yaml
namespace: cert-manager
cert-manager-config:
kubectl:
manifests:
- dev/manifests/cert-manager/
namespace: cert-manager
nginx-ingress:
kubectl:
manifests:
- https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
namespace: ingress-nginx
vault-operator:
helm:
chart:
name: vault-operator
repo: https://kubernetes-charts.banzaicloud.com
namespace: vault
vault-config:
kubectl:
manifests:
- dev/manifests/vault/
namespace: vault
nats:
kubectl:
manifests:
- dev/manifests/nats/
namespace: nats
crossplane:
helm:
chart:
name: crossplane
repo: https://charts.crossplane.io/stable/
version: "1.11.2"
values:
args:
- --enable-composition-functions
- --debug
xfn:
enabled: true
args:
- --debug
namespace: crossplane-system
provider-natssecrets:
kubectl:
manifests:
- dev/manifests/provider-natssecrets/
namespace: crossplane-system