From d1297b71d89681b19db1d24413bbd24304f3f477 Mon Sep 17 00:00:00 2001 From: "marek.ruszczyk" Date: Wed, 11 Sep 2019 16:49:55 +0200 Subject: [PATCH 1/5] Small fixes, infra and gitter script --- setup_gitter.sh | 19 +++++++++++++++++++ setup_infra.sh | 38 ++++++++++++++++++++++++++++++++++++++ workshop-functions.sh | 12 +++++++++--- 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100755 setup_gitter.sh create mode 100755 setup_infra.sh mode change 100644 => 100755 workshop-functions.sh diff --git a/setup_gitter.sh b/setup_gitter.sh new file mode 100755 index 0000000..6970e1b --- /dev/null +++ b/setup_gitter.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# +export workshopNamespace=workshop +export gitterRoom="ContainerSolutions/warsaw-workshop" + +echo "Import gitter keys from gitter.env" +source gitter.env +echo "Create secrets" +kubectl create secret generic gitter \ + --from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \ + --from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET + +curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \ + | envsubst \ + | kubectl apply -f - + +kubectl patch deployments gitter --patch '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"gitter"}],"containers":[{"$setElementOrder/env":[{"name":"GITTER_ROOM_NAME"},{"name":"DOMAIN"}],"env":[{"name":"GITTER_ROOM_NAME","value":"'${gitterRoom}'"}],"name":"gitter"}]}}}}' + diff --git a/setup_infra.sh b/setup_infra.sh new file mode 100755 index 0000000..b8e1542 --- /dev/null +++ b/setup_infra.sh @@ -0,0 +1,38 @@ +PROJECT_ID=${PROJECT_ID:-"container-solutions-workshops"} +CLUSTER_NAME=${CLUSTER_NAME:-"workshop"} +ZONE=${ZONE:-"europe-west3-b"} + +gcloud beta container \ + --project "${PROJECT_ID}" \ + clusters create "${CLUSTER_NAME}" \ + --zone "${ZONE}" \ + --username "admin" \ + --machine-type "n1-standard-4" \ + --image-type "UBUNTU" \ + --disk-type "pd-standard" \ + --disk-size "100" \ + --metadata disable-legacy-endpoints=true \ + --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \ + --num-nodes "3" \ + --enable-cloud-logging \ + --enable-cloud-monitoring \ + --no-enable-ip-alias \ + --network "projects/container-solutions-workshops/global/networks/default" \ + --addons HorizontalPodAutoscaling \ + --no-enable-autoupgrade \ + --enable-autorepair +#cloud beta container \ +# --project "container-solutions-workshops" \ +# node-pools create "pool-1" \ +# --cluster "workshop" \ +# --machine-type "n1-standard-2" \ +# --image-type "UBUNTU" \ +# --disk-type "pd-standard" \ +# --disk-size "100" \ +# --metadata disable-legacy-endpoints=true \ +# --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \ +# --preemptible \ +# --num-nodes "3" \ +# --no-enable-autoupgrade \ +# --enable-autorepairi \ +# --zone "europe-west3-b" diff --git a/workshop-functions.sh b/workshop-functions.sh old mode 100644 new mode 100755 index e2e2524..5c3140d --- a/workshop-functions.sh +++ b/workshop-functions.sh @@ -32,6 +32,12 @@ rules: - jobs - cronjobs verbs: ["*"] +- apiGroups: ["networking.istio.io"] + resources: + - virtualservices + - gateways + - destinationrules + verbs: ["*"] - apiGroups: ["rbac.authorization.k8s.io"] resources: - roles @@ -105,7 +111,7 @@ namespace() { kubectl label clusterrolebinding crb-cc-${namespace} user=${namespace} kubectl create clusterrolebinding crb-ssh-${namespace} --clusterrole=sshreader --serviceaccount=${workshopNamespace}:sa-${namespace} - kubectl label clusterrolebinding crb-ssh-${namespace} user=${namespace} + kubectl label clusterrolebinding crb-ssh-${namespace} user=${namespace} } enable-namespaces() { @@ -130,7 +136,7 @@ depl() { : ${namespace:? required} : ${gitrepo:? required} : ${sessionSecret:=cloudnative1337} - + local name=${namespace} cat < checking DNS A record (*.${domain}) points to: $ingressip ..." - if [[ $(dig +short "*.${domain}") == $ingressip ]] ; then + if [[ $(dig +short "*.${domain}") == $ingressip ]] ; then echo "DNS setting are ok" else echo "---> set external dns A record (*.${domain}) to: $ingressip" From b3a339168cbb09942f7df58d3cbe770f808b388a Mon Sep 17 00:00:00 2001 From: Marek Ruszczyk Date: Thu, 13 Feb 2020 15:49:28 +0100 Subject: [PATCH 2/5] Added scripts to bootstrap cluster without LB, added persistent storage, added vscode ide container, exposed vscode with ingress --- gitter.env.sample | 6 +++ ingress_istio.yaml | 27 +++++++++++ setup_gitter.sh | 7 ++- setup_infra.sh | 29 +++-------- workshop-functions.sh | 110 ++++++++++++++++++++++++++++++++++++------ 5 files changed, 143 insertions(+), 36 deletions(-) create mode 100644 gitter.env.sample create mode 100644 ingress_istio.yaml diff --git a/gitter.env.sample b/gitter.env.sample new file mode 100644 index 0000000..1774dc2 --- /dev/null +++ b/gitter.env.sample @@ -0,0 +1,6 @@ +#CONSOLE https://developer.gitter.im/apps/new +#REDIRECT URL https://gitter.waw.training.csol.cloud/login/callback + +export GITTER_OAUTH_KEY=xx +export GITTER_OAUTH_SECRET=xx + diff --git a/ingress_istio.yaml b/ingress_istio.yaml new file mode 100644 index 0000000..c2d7dc9 --- /dev/null +++ b/ingress_istio.yaml @@ -0,0 +1,27 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: istio + namespace: istio-system +spec: + rules: + - host: grafana.waw.training.csol.cloud + http: + paths: + - backend: + serviceName: grafana + servicePort: 3000 + - host: prometheus.waw.training.csol.cloud + http: + paths: + - backend: + serviceName: prometheus + servicePort: 9090 + - host: kiali.waw.training.csol.cloud + http: + paths: + - backend: + serviceName: kiali + servicePort: 20001 + + diff --git a/setup_gitter.sh b/setup_gitter.sh index 6970e1b..cba9f54 100755 --- a/setup_gitter.sh +++ b/setup_gitter.sh @@ -1,6 +1,11 @@ #!/bin/bash -# +## +# +# Don't forget to create/update gitter.env file +# and update gitter room +# +## export workshopNamespace=workshop export gitterRoom="ContainerSolutions/warsaw-workshop" diff --git a/setup_infra.sh b/setup_infra.sh index b8e1542..2fb1a5d 100755 --- a/setup_infra.sh +++ b/setup_infra.sh @@ -1,5 +1,5 @@ PROJECT_ID=${PROJECT_ID:-"container-solutions-workshops"} -CLUSTER_NAME=${CLUSTER_NAME:-"workshop"} +CLUSTER_NAME=${CLUSTER_NAME:-"workshop-marek-2"} ZONE=${ZONE:-"europe-west3-b"} gcloud beta container \ @@ -7,32 +7,19 @@ gcloud beta container \ clusters create "${CLUSTER_NAME}" \ --zone "${ZONE}" \ --username "admin" \ - --machine-type "n1-standard-4" \ + --machine-type "n1-standard-2" \ --image-type "UBUNTU" \ --disk-type "pd-standard" \ --disk-size "100" \ --metadata disable-legacy-endpoints=true \ --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \ --num-nodes "3" \ - --enable-cloud-logging \ - --enable-cloud-monitoring \ + --no-enable-cloud-logging \ + --no-enable-cloud-monitoring \ --no-enable-ip-alias \ --network "projects/container-solutions-workshops/global/networks/default" \ - --addons HorizontalPodAutoscaling \ + --addons HorizontalPodAutoscaling,Istio \ --no-enable-autoupgrade \ - --enable-autorepair -#cloud beta container \ -# --project "container-solutions-workshops" \ -# node-pools create "pool-1" \ -# --cluster "workshop" \ -# --machine-type "n1-standard-2" \ -# --image-type "UBUNTU" \ -# --disk-type "pd-standard" \ -# --disk-size "100" \ -# --metadata disable-legacy-endpoints=true \ -# --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \ -# --preemptible \ -# --num-nodes "3" \ -# --no-enable-autoupgrade \ -# --enable-autorepairi \ -# --zone "europe-west3-b" + --enable-autorepair + +gcloud container clusters get-credentials "${CLUSTER_NAME}" --project "${PROJECT_ID}" --zone "${ZONE}" diff --git a/workshop-functions.sh b/workshop-functions.sh index 5c3140d..4587eb7 100755 --- a/workshop-functions.sh +++ b/workshop-functions.sh @@ -18,6 +18,38 @@ metadata: --- kind: Role apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: role-${namespace} + namespace: istio-system + labels: + user: "${namespace}" +rules: +- apiGroups: [""] + resources: + - services + - pods + verbs: + - get + - list +--- +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: rb-${namespace} + namespace: istio-system + labels: + user: "${namespace}" +subjects: +- kind: ServiceAccount + name: sa-${namespace} + namespace: ${workshopNamespace} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: role-${namespace} +--- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: role-${namespace} namespace: ${namespace} @@ -103,6 +135,7 @@ namespace() { kubectl create ns ${namespace} kubectl label ns ${namespace} user=${namespace} + kubectl label ns ${namespace} istio-injection=enabled assign-role-to-ns ${namespace} | kubectl create -f - kubectl create clusterrolebinding crb-${namespace} --clusterrole=lister --serviceaccount=${workshopNamespace}:sa-${namespace} @@ -140,6 +173,21 @@ depl() { local name=${namespace} cat < Date: Mon, 17 Feb 2020 12:17:40 +0100 Subject: [PATCH 3/5] Requested changes: - Removed setup_infra in favor of function in main script - Moved setup_gitter into main script function - Removed istio from resources - Improved docs - Added required env to .profile-example --- .profile-example | 4 +++ gitter.env.sample | 6 ---- infra-setup.md | 18 ++++++----- ingress_istio.yaml | 27 ---------------- self-service.md | 23 +++----------- setup_gitter.sh | 24 --------------- setup_infra.sh | 25 --------------- workshop-functions.sh | 71 ++++++++++++++++++------------------------- 8 files changed, 48 insertions(+), 150 deletions(-) delete mode 100644 gitter.env.sample delete mode 100644 ingress_istio.yaml delete mode 100755 setup_gitter.sh delete mode 100755 setup_infra.sh diff --git a/.profile-example b/.profile-example index b8e7e98..ea40dd6 100644 --- a/.profile-example +++ b/.profile-example @@ -10,3 +10,7 @@ export workshopNamespace=workshop # export sessionSecret=cloudnative1337 # export clusterName=workshop # export gitrepo=https://github.com/ContainerSolutions/timber.git + +## Required for gitter self-serivce portal (get them here: https://developer.gitter.im/apps/new) +# export GITTER_OAUTH_KEY=xx +# export GITTER_OAUTH_SECRET=xxx diff --git a/gitter.env.sample b/gitter.env.sample deleted file mode 100644 index 1774dc2..0000000 --- a/gitter.env.sample +++ /dev/null @@ -1,6 +0,0 @@ -#CONSOLE https://developer.gitter.im/apps/new -#REDIRECT URL https://gitter.waw.training.csol.cloud/login/callback - -export GITTER_OAUTH_KEY=xx -export GITTER_OAUTH_SECRET=xx - diff --git a/infra-setup.md b/infra-setup.md index 042536e..4493275 100644 --- a/infra-setup.md +++ b/infra-setup.md @@ -5,6 +5,13 @@ preinstalled, and authenticated against the CS account. Just use this url: [CloudShell](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/lalyos/k8s-workshop&tutorial=infra-setup.md ) +## Changelog 2020-02-17 + +- Added code-server, exposed via domain on ide.userXX.${domain} +- Migrated gotty shell to shell.userXX.${domain} +- Added function setup-gitter +- Extended timeout from 60s to 3600s for long live proxy connection via ingress (should fix connection dropping while using ingress) + ## ChangeLog 2019-10-25 - cluster creation is moved to a function `start-cluster` @@ -16,7 +23,7 @@ Just use this url: [CloudShell](https://console.cloud.google.com/cloudshell/open - defPoolSize (3) - preemPoolSize (3) - zone (europe-west3-b) -- istio and http lb is switched of by default (speedup start) - see: 403bc36d8c25f6173e04b8fca0d1a0c5a96c1601 +- istio and http lb is switched off by default (speedup start) - see: 403bc36d8c25f6173e04b8fca0d1a0c5a96c1601 ## Configure Project @@ -48,7 +55,7 @@ source workshop-functions.sh ``` Now you can create the GKE cluster. All config will be printed, -and you have a chance to review and cancel. +and you have a chance to review and cancel. This will also automatically import cluster config ``` start-cluster ``` @@ -58,11 +65,6 @@ checking the GKE cluster gcloud container clusters list ``` -get kubectl credentials -``` -gcloud container clusters get-credentials workshop --zone=${zone} -``` - ## Initial setup At the begining you have to create some cluster roles : @@ -115,7 +117,7 @@ dev user0 ``` Please note, the first couple may take more time, as the docker image should be pulled on each node. -To create more user sssions use the following line +To create more user sessions use the following line ``` for u in user{2..15}; do dev $u; done ``` diff --git a/ingress_istio.yaml b/ingress_istio.yaml deleted file mode 100644 index c2d7dc9..0000000 --- a/ingress_istio.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: istio - namespace: istio-system -spec: - rules: - - host: grafana.waw.training.csol.cloud - http: - paths: - - backend: - serviceName: grafana - servicePort: 3000 - - host: prometheus.waw.training.csol.cloud - http: - paths: - - backend: - serviceName: prometheus - servicePort: 9090 - - host: kiali.waw.training.csol.cloud - http: - paths: - - backend: - serviceName: kiali - servicePort: 20001 - - diff --git a/self-service.md b/self-service.md index a93a496..695964d 100644 --- a/self-service.md +++ b/self-service.md @@ -6,7 +6,7 @@ Since we use basic auth now, the urls are simple (like userX.domain.com). Of course now you have to distribute the credentials, but hey you can use the same password for everybody ;) -## Self Service portal - depricated +## Self Service portal v2 (WIP) After creating the user sessions, its hard to distribute/assign the session urls. @@ -14,22 +14,9 @@ There is a small gitter authentication based web app, where participants can get session assigned to them. More details and the process toget GITTER credentials is described: https://github.com/lalyos/gitter-scripter +Run this line to setup gitter, don't forget to update .profile with credentials +```bash +setup-gitter ``` -export GITTER_OAUTH_KEY=xxxxxxx -export GITTER_OAUTH_SECRET=yyyyyyy -kubectl create secret generic gitter \ - --from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \ - --from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET -# todo automate setting of gitter room: -export workshopNamespace=workshop -export domain=k8z.eu -curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \ - | envsubst \ - | kubectl apply -f - - -export gitterRoom=lalyos/earthport -kubectl patch deployments gitter --patch '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"gitter"}],"containers":[{"$setElementOrder/env":[{"name":"GITTER_ROOM_NAME"},{"name":"DOMAIN"}],"env":[{"name":"GITTER_ROOM_NAME","value":"'${gitterRoom}'"}],"name":"gitter"}]}}}}' -``` - -The users can self service at: http://session.k8z.eu +The users can self service at: http://session.${domain} diff --git a/setup_gitter.sh b/setup_gitter.sh deleted file mode 100755 index cba9f54..0000000 --- a/setup_gitter.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -## -# -# Don't forget to create/update gitter.env file -# and update gitter room -# -## -export workshopNamespace=workshop -export gitterRoom="ContainerSolutions/warsaw-workshop" - -echo "Import gitter keys from gitter.env" -source gitter.env -echo "Create secrets" -kubectl create secret generic gitter \ - --from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \ - --from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET - -curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \ - | envsubst \ - | kubectl apply -f - - -kubectl patch deployments gitter --patch '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"gitter"}],"containers":[{"$setElementOrder/env":[{"name":"GITTER_ROOM_NAME"},{"name":"DOMAIN"}],"env":[{"name":"GITTER_ROOM_NAME","value":"'${gitterRoom}'"}],"name":"gitter"}]}}}}' - diff --git a/setup_infra.sh b/setup_infra.sh deleted file mode 100755 index 2fb1a5d..0000000 --- a/setup_infra.sh +++ /dev/null @@ -1,25 +0,0 @@ -PROJECT_ID=${PROJECT_ID:-"container-solutions-workshops"} -CLUSTER_NAME=${CLUSTER_NAME:-"workshop-marek-2"} -ZONE=${ZONE:-"europe-west3-b"} - -gcloud beta container \ - --project "${PROJECT_ID}" \ - clusters create "${CLUSTER_NAME}" \ - --zone "${ZONE}" \ - --username "admin" \ - --machine-type "n1-standard-2" \ - --image-type "UBUNTU" \ - --disk-type "pd-standard" \ - --disk-size "100" \ - --metadata disable-legacy-endpoints=true \ - --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \ - --num-nodes "3" \ - --no-enable-cloud-logging \ - --no-enable-cloud-monitoring \ - --no-enable-ip-alias \ - --network "projects/container-solutions-workshops/global/networks/default" \ - --addons HorizontalPodAutoscaling,Istio \ - --no-enable-autoupgrade \ - --enable-autorepair - -gcloud container clusters get-credentials "${CLUSTER_NAME}" --project "${PROJECT_ID}" --zone "${ZONE}" diff --git a/workshop-functions.sh b/workshop-functions.sh index 4587eb7..1a1ea98 100755 --- a/workshop-functions.sh +++ b/workshop-functions.sh @@ -18,38 +18,6 @@ metadata: --- kind: Role apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: role-${namespace} - namespace: istio-system - labels: - user: "${namespace}" -rules: -- apiGroups: [""] - resources: - - services - - pods - verbs: - - get - - list ---- -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: rb-${namespace} - namespace: istio-system - labels: - user: "${namespace}" -subjects: -- kind: ServiceAccount - name: sa-${namespace} - namespace: ${workshopNamespace} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: role-${namespace} ---- -kind: Role -apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: role-${namespace} namespace: ${namespace} @@ -64,12 +32,6 @@ rules: - jobs - cronjobs verbs: ["*"] -- apiGroups: ["networking.istio.io"] - resources: - - virtualservices - - gateways - - destinationrules - verbs: ["*"] - apiGroups: ["rbac.authorization.k8s.io"] resources: - roles @@ -109,7 +71,7 @@ metadata: subjects: - kind: ServiceAccount name: default - namespace: ${mamespace} + namespace: ${namespace} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role @@ -135,7 +97,6 @@ namespace() { kubectl create ns ${namespace} kubectl label ns ${namespace} user=${namespace} - kubectl label ns ${namespace} istio-injection=enabled assign-role-to-ns ${namespace} | kubectl create -f - kubectl create clusterrolebinding crb-${namespace} --clusterrole=lister --serviceaccount=${workshopNamespace}:sa-${namespace} @@ -543,10 +504,11 @@ start-cluster() { : ${defPoolSize:=3} : ${preemPoolSize:=3} + project_id="container-solutions-workshops" confirm-config gcloud beta container \ - --project "container-solutions-workshops" \ + --project "${project_id}" \ clusters create "${clusterName}" \ --zone "${zone}" \ --username "admin" \ @@ -565,7 +527,7 @@ start-cluster() { --enable-autoupgrade \ --enable-autorepair \ && gcloud beta container \ - --project "container-solutions-workshops" \ + --project "${project_id}" \ node-pools create "pool-1" \ --cluster "${clusterName}" \ --zone "${zone}" \ @@ -580,8 +542,33 @@ start-cluster() { --num-nodes "${preemPoolSize}" \ --no-enable-autoupgrade \ --enable-autorepair + + gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}" + } +setup-gitter() { + + : ${workshopNamespace:? required} + : ${gitterRoom:? required} + : ${GITTER_OAUTH_KEY:? required} + : ${GITTER_OAUTH_SECRET:? required} + + + echo "Import gitter keys from gitter.env" + echo "Create secrets" + kubectl create secret generic gitter \ + --from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \ + --from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET + + curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \ + | envsubst \ + | kubectl apply -f - + + kubectl patch deployments gitter --patch '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"gitter"}],"containers":[{"$setElementOrder/env":[{"name":"GITTER_ROOM_NAME"},{"name":"DOMAIN"}],"env":[{"name":"GITTER_ROOM_NAME","value":"'${gitterRoom}'"}],"name":"gitter"}]}}}}' + +}} + [[ -e .profile ]] && source .profile || true main() { From d08770fa3bcf93d5db5a9f17ad36e8ea2e40795c Mon Sep 17 00:00:00 2001 From: Marek Ruszczyk Date: Mon, 17 Feb 2020 12:27:20 +0100 Subject: [PATCH 4/5] Chained cluster configuratoin getter into cluster creation command --- workshop-functions.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/workshop-functions.sh b/workshop-functions.sh index 1a1ea98..c00bb0a 100755 --- a/workshop-functions.sh +++ b/workshop-functions.sh @@ -541,9 +541,8 @@ start-cluster() { --preemptible \ --num-nodes "${preemPoolSize}" \ --no-enable-autoupgrade \ - --enable-autorepair - - gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}" + --enable-autorepair \ + && gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}" } @@ -554,8 +553,6 @@ setup-gitter() { : ${GITTER_OAUTH_KEY:? required} : ${GITTER_OAUTH_SECRET:? required} - - echo "Import gitter keys from gitter.env" echo "Create secrets" kubectl create secret generic gitter \ --from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \ From 4a8cd945649e3dc1ed0f06bea507088adb11c62e Mon Sep 17 00:00:00 2001 From: Marek Ruszczyk Date: Mon, 17 Feb 2020 14:12:50 +0100 Subject: [PATCH 5/5] Fixed typos in main script --- workshop-functions.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/workshop-functions.sh b/workshop-functions.sh index c00bb0a..d877711 100755 --- a/workshop-functions.sh +++ b/workshop-functions.sh @@ -324,6 +324,7 @@ get-url() { echo "open shell ${sessionUrlNodePort}" echo "open ide ${sessionUrlNodePortIde}" +} switchNs() { actualNs=$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}') @@ -542,7 +543,7 @@ start-cluster() { --num-nodes "${preemPoolSize}" \ --no-enable-autoupgrade \ --enable-autorepair \ - && gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}" + && gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}" } @@ -564,7 +565,7 @@ setup-gitter() { kubectl patch deployments gitter --patch '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"gitter"}],"containers":[{"$setElementOrder/env":[{"name":"GITTER_ROOM_NAME"},{"name":"DOMAIN"}],"env":[{"name":"GITTER_ROOM_NAME","value":"'${gitterRoom}'"}],"name":"gitter"}]}}}}' -}} +} [[ -e .profile ]] && source .profile || true @@ -573,3 +574,4 @@ main() { init init-sshfront } +