forked from nats-io/k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·33 lines (22 loc) · 1.18 KB
/
setup.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
#!/bin/sh
set -eu
NATS_K8S_VERSION=${DEFAULT_NATS_K8S_VERSION:=https://raw.githubusercontent.com/vitta-health/nats-io-k8s/master}
NATS_BOOTSTRAP_YML=${DEFAULT_NATS_BOOTSTRAP_YML:=$NATS_K8S_VERSION/setup/bootstrap-policy.yml}
NATS_SETUP_IMAGE=${DEFAULT_NATS_SETUP_IMAGE:=gilsonsouzah/nats-setup:1.0.5}
kubectl config set-context --current --namespace=nats
# Create namespace
kubectl create namespace nats
# Apply policy required to be able to create the resources.
kubectl apply -n nats -f "$NATS_BOOTSTRAP_YML"
# Run nats-setup container containing the latest set of manifests.
kubectl run nats-setup --generator=run-pod/v1 --image-pull-policy=Always --serviceaccount=nats-setup --image=$NATS_SETUP_IMAGE --restart=Never
# Wait for the setup container to start or bail.
kubectl wait --for=condition=Ready pod/nats-setup --timeout=30s
# Pass the custom parameters to the nats-setup container image.
kubectl exec nats-setup -- nats-setup.sh "$@"
# Get a local copy of the nsc directory with the accounts.
kubectl cp nats-setup:/nsc nsc
# Remove the required policy for setup purposes.
kubectl delete -f "$NATS_BOOTSTRAP_YML"
# Remove the setup pod.
kubectl delete pod nats-setup --grace-period=0 --force