This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
install-kyma.sh
executable file
·159 lines (139 loc) · 6.97 KB
/
install-kyma.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
set -o errexit
SECONDS=0
GARDENER=${GARDENER:-false}
export DOMAIN=${KYMA_DOMAIN:-local.kyma.dev}
export OVERRIDES=global.isLocalEnv=false,global.ingress.domainName=$DOMAIN,global.environment.gardener=$GARDENER,global.domainName=$DOMAIN,global.tlsCrt=ZHVtbXkK
# export REGISTRY_VALUES="dockerRegistry.username=$REGISTRY_USER,dockerRegistry.password=$REGISTRY_PASS,dockerRegistry.enableInternal=false,dockerRegistry.serverAddress=ghcr.io,dockerRegistry.registryAddress=ghcr.io/$REGISTRY_USER"
if [[ -z $REGISTRY_VALUES ]]; then
export REGISTRY_VALUES="dockerRegistry.enableInternal=false,dockerRegistry.serverAddress=registry.localhost:5000,dockerRegistry.registryAddress=registry.localhost:5000"
fi
# Wait until number of background jobs is less than $1, try every $2 second(s)
function waitForJobs() {
while (( (( JOBS_COUNT=$(jobs -p | wc -l) )) > $1 )); do echo "Waiting for $JOBS_COUNT command(s) executed in the background, elapsed time: $(( $SECONDS/60 )) min $(( $SECONDS % 60 )) sec"; jobs >/dev/null ; sleep $2; done
}
function helm_install() {
local release=$1
local chart=$2
local namespace=$3
local retries=3
local result=""
local status=""
if [[ $SKIP_MODULES =~ $release ]];
then
echo "$release skipped"
return 0
fi
while [ $retries -ge 0 ]
do
((retries--))
status=$(helm status $release -n $namespace -ojson 2>/dev/null | jq -r ".info.status" 2>/dev/null) >/dev/null 2>&1
if [[ "$status" == "deployed" ]];
then
break
fi
if [[ "$status" == "pending-install" ]];
then
echo "Deleting $release in status pending-install"
helm uninstall $release -n $namespace
fi
if [[ "$status" == "failed" ]];
then
echo "Deleting $release in status failed"
helm uninstall $release -n $namespace
fi
echo "Installing $1 in the namespace $namespace"
set +e
helm upgrade --wait --force -i $release $chart -n $namespace "${@:4}"
set -e
done
}
set +e
# This file will be created by cert-manager (not needed anymore):
rm resources/core/charts/gateway/templates/kyma-gateway-certs.yaml
set -e
# Create namespaces
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
labels:
istio-injection: enabled
name: kyma-system
---
apiVersion: v1
kind: Namespace
metadata:
labels:
istio-injection: enabled
name: kyma-integration
---
apiVersion: v1
kind: Namespace
metadata:
labels:
istio-injection: enabled
name: knative-eventing
---
apiVersion: v1
kind: Namespace
metadata:
labels:
istio-injection: enabled
name: natss
EOF
# Wait for nodes to be ready before scheduling any workload
while [[ $(kubectl get nodes -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "Waiting for cluster nodes to be ready, elapsed time: $(( $SECONDS/60 )) min $(( $SECONDS % 60 )) sec"; sleep 2; done
if [[ -z $REGISTRY_IP ]]; then
export REGISTRY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' /registry.localhost)
fi
echo "Patching CoreDns with REGISTRY_IP=$REGISTRY_IP"
sed "s/REGISTRY_IP/$REGISTRY_IP/" coredns-patch.tpl >coredns-patch.yaml
kubectl -n kube-system patch cm coredns --patch "$(cat coredns-patch.yaml)"
kubectl apply -f resources/cluster-essentials/files -n kyma-system
helm_install pod-preset resources/cluster-essentials/charts/pod-preset kyma-system &
helm_install ingress-dns-cert ingress-dns-cert istio-system --set global.ingress.domainName=$DOMAIN,global.environment.gardener=$GARDENER &
helm_install dex resources/dex kyma-system --set $OVERRIDES --set resources.requests.cpu=10m &
helm_install ory resources/ory kyma-system --set $OVERRIDES -f resources/ory/profile-evaluation.yaml &
helm_install api-gateway resources/api-gateway kyma-system --set $OVERRIDES --set deployment.resources.requests.cpu=10m &
helm_install rafter resources/rafter kyma-system --set $OVERRIDES -f resources/rafter/profile-evaluation.yaml &
helm_install service-catalog resources/service-catalog kyma-system --set $OVERRIDES -f resources/service-catalog/profile-evaluation.yaml &
helm_install service-catalog-addons resources/service-catalog-addons kyma-system --set $OVERRIDES -f resources/service-catalog-addons/profile-evaluation.yaml &
helm_install helm-broker resources/helm-broker kyma-system --set $OVERRIDES -f resources/helm-broker/profile-evaluation.yaml &
helm_install core resources/core kyma-system --set $OVERRIDES &
helm_install console resources/console kyma-system --set $OVERRIDES -f resources/console/profile-evaluation.yaml --set pamela.enabled=true &
helm_install cluster-users resources/cluster-users kyma-system --set $OVERRIDES &
helm_install serverless resources/serverless kyma-system -f resources/serverless/profile-evaluation.yaml --set $REGISTRY_VALUES,global.ingress.domainName=$DOMAIN &
helm_install logging resources/logging kyma-system --set $OVERRIDES -f resources/logging/profile-evaluation.yaml &
helm_install tracing resources/tracing kyma-system --set $OVERRIDES -f resources/tracing/profile-evaluation.yaml &
helm_install knative-eventing resources/knative-eventing knative-eventing &
helm_install application-connector resources/application-connector kyma-integration --set $OVERRIDES &
helm_install knative-provisioner-natss resources/knative-provisioner-natss knative-eventing &
helm_install nats-streaming resources/nats-streaming natss --set global.natsStreaming.resources.requests.memory=64M,global.natsStreaming.resources.requests.cpu=10m &
helm_install event-sources resources/event-sources kyma-system &
helm_install kiali resources/kiali kyma-system --set global.ingress.domainName=$DOMAIN -f resources/kiali/profile-evaluation.yaml &
helm_install monitoring resources/monitoring kyma-system --set global.ingress.domainName=$DOMAIN -f resources/monitoring/profile-evaluation.yaml &
# Create installer deployment scaled to 0 to get console running:
kubectl apply -f installer-local.yaml &
# Wait for jobs - helm commands executed in the background
waitForJobs 0 5
echo "##############################################################################"
echo "# Kyma installed in $(( $SECONDS/60 )) min $(( $SECONDS % 60 )) sec"
echo "##############################################################################"
echo
# Download the certificate:
kubectl get secret kyma-gateway-certs -n istio-system -o jsonpath='{.data.tls\.crt}' | base64 --decode > kyma.crt
# Import the certificate:
echo "Generated self signed TLS certificate should be trusted in your system. On Mac Os X execute this command:"
echo ""
echo " sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain kyma.crt"
echo ""
echo "This is one time operation (you can skip this step if you did it before)."
if [[ ! $SKIP_MODULES =~ "console" ]];
then
echo ""
echo 'Kyma Console Url:'
echo `kubectl get virtualservice console-web -n kyma-system -o jsonpath='{ .spec.hosts[0] }'`
echo 'User [email protected], password:'
echo `kubectl get secret admin-user -n kyma-system -o jsonpath="{.data.password}" | base64 --decode`
fi