Skip to content

Commit 45bf31a

Browse files
Requeted 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
1 parent b3a3391 commit 45bf31a

8 files changed

+48
-150
lines changed

.profile-example

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ export workshopNamespace=workshop
1010
# export sessionSecret=cloudnative1337
1111
# export clusterName=workshop
1212
# export gitrepo=https://github.com/ContainerSolutions/timber.git
13+
14+
## Required for gitter self-serivce portal (get them here: https://developer.gitter.im/apps/new)
15+
# export GITTER_OAUTH_KEY=xx
16+
# export GITTER_OAUTH_SECRET=xxx

gitter.env.sample

-6
This file was deleted.

infra-setup.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ preinstalled, and authenticated against the CS account.
55
Just use this url: [CloudShell](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/lalyos/k8s-workshop&tutorial=infra-setup.md
66
)
77

8+
## Changelog 2020-02-17
9+
10+
- Added code-server, exposed via domain on ide.userXX.${domain}
11+
- Migrated gotty shell to shell.userXX.${domain}
12+
- Added function setup-gitter
13+
- Extended timeout from 60s to 3600s for long live proxy connection via ingress (should fix connection dropping while using ingress)
14+
815
## ChangeLog 2019-10-25
916

1017
- 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
1623
- defPoolSize (3)
1724
- preemPoolSize (3)
1825
- zone (europe-west3-b)
19-
- istio and http lb is switched of by default (speedup start) - see: 403bc36d8c25f6173e04b8fca0d1a0c5a96c1601
26+
- istio and http lb is switched off by default (speedup start) - see: 403bc36d8c25f6173e04b8fca0d1a0c5a96c1601
2027

2128
## Configure Project
2229

@@ -48,7 +55,7 @@ source workshop-functions.sh
4855
```
4956

5057
Now you can create the GKE cluster. All config will be printed,
51-
and you have a chance to review and cancel.
58+
and you have a chance to review and cancel. This will also automatically import cluster config
5259
```
5360
start-cluster
5461
```
@@ -58,11 +65,6 @@ checking the GKE cluster
5865
gcloud container clusters list
5966
```
6067

61-
get kubectl credentials
62-
```
63-
gcloud container clusters get-credentials workshop --zone=${zone}
64-
```
65-
6668
## Initial setup
6769

6870
At the begining you have to create some cluster roles :
@@ -115,7 +117,7 @@ dev user0
115117
```
116118
Please note, the first couple may take more time, as the docker image should be pulled on each node.
117119

118-
To create more user sssions use the following line
120+
To create more user sessions use the following line
119121
```
120122
for u in user{2..15}; do dev $u; done
121123
```

ingress_istio.yaml

-27
This file was deleted.

self-service.md

+5-18
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,17 @@ Since we use basic auth now, the urls are simple (like userX.domain.com).
66
Of course now you have to distribute the credentials, but hey you can use
77
the same password for everybody ;)
88

9-
## Self Service portal - depricated
9+
## Self Service portal v2 (WIP)
1010

1111
After creating the user sessions, its hard to distribute/assign the session urls.
1212

1313
There is a small gitter authentication based web app, where participants can get an unused
1414
session assigned to them.
1515
More details and the process toget GITTER credentials is described: https://github.com/lalyos/gitter-scripter
1616

17+
Run this line to setup gitter, don't forget to update .profile with credentials
18+
```bash
19+
setup-gitter
1720
```
18-
export GITTER_OAUTH_KEY=xxxxxxx
19-
export GITTER_OAUTH_SECRET=yyyyyyy
20-
kubectl create secret generic gitter \
21-
--from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \
22-
--from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET
23-
# todo automate setting of gitter room:
2421

25-
export workshopNamespace=workshop
26-
export domain=k8z.eu
27-
curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \
28-
| envsubst \
29-
| kubectl apply -f -
30-
31-
export gitterRoom=lalyos/earthport
32-
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"}]}}}}'
33-
```
34-
35-
The users can self service at: http://session.k8z.eu
22+
The users can self service at: http://session.${domain}

setup_gitter.sh

-24
This file was deleted.

setup_infra.sh

-25
This file was deleted.

workshop-functions.sh

+29-42
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,6 @@ metadata:
1818
---
1919
kind: Role
2020
apiVersion: rbac.authorization.k8s.io/v1beta1
21-
metadata:
22-
name: role-${namespace}
23-
namespace: istio-system
24-
labels:
25-
user: "${namespace}"
26-
rules:
27-
- apiGroups: [""]
28-
resources:
29-
- services
30-
- pods
31-
verbs:
32-
- get
33-
- list
34-
---
35-
kind: RoleBinding
36-
apiVersion: rbac.authorization.k8s.io/v1beta1
37-
metadata:
38-
name: rb-${namespace}
39-
namespace: istio-system
40-
labels:
41-
user: "${namespace}"
42-
subjects:
43-
- kind: ServiceAccount
44-
name: sa-${namespace}
45-
namespace: ${workshopNamespace}
46-
roleRef:
47-
apiGroup: rbac.authorization.k8s.io
48-
kind: Role
49-
name: role-${namespace}
50-
---
51-
kind: Role
52-
apiVersion: rbac.authorization.k8s.io/v1beta1
5321
metadata:
5422
name: role-${namespace}
5523
namespace: ${namespace}
@@ -64,12 +32,6 @@ rules:
6432
- jobs
6533
- cronjobs
6634
verbs: ["*"]
67-
- apiGroups: ["networking.istio.io"]
68-
resources:
69-
- virtualservices
70-
- gateways
71-
- destinationrules
72-
verbs: ["*"]
7335
- apiGroups: ["rbac.authorization.k8s.io"]
7436
resources:
7537
- roles
@@ -109,7 +71,7 @@ metadata:
10971
subjects:
11072
- kind: ServiceAccount
11173
name: default
112-
namespace: ${mamespace}
74+
namespace: ${namespace}
11375
roleRef:
11476
apiGroup: rbac.authorization.k8s.io
11577
kind: Role
@@ -135,7 +97,6 @@ namespace() {
13597

13698
kubectl create ns ${namespace}
13799
kubectl label ns ${namespace} user=${namespace}
138-
kubectl label ns ${namespace} istio-injection=enabled
139100
assign-role-to-ns ${namespace} | kubectl create -f -
140101

141102
kubectl create clusterrolebinding crb-${namespace} --clusterrole=lister --serviceaccount=${workshopNamespace}:sa-${namespace}
@@ -543,10 +504,11 @@ start-cluster() {
543504
: ${defPoolSize:=3}
544505
: ${preemPoolSize:=3}
545506

507+
project_id="container-solutions-workshops"
546508
confirm-config
547509

548510
gcloud beta container \
549-
--project "container-solutions-workshops" \
511+
--project "${project_id}" \
550512
clusters create "${clusterName}" \
551513
--zone "${zone}" \
552514
--username "admin" \
@@ -565,7 +527,7 @@ start-cluster() {
565527
--enable-autoupgrade \
566528
--enable-autorepair \
567529
&& gcloud beta container \
568-
--project "container-solutions-workshops" \
530+
--project "${project_id}" \
569531
node-pools create "pool-1" \
570532
--cluster "${clusterName}" \
571533
--zone "${zone}" \
@@ -580,8 +542,33 @@ start-cluster() {
580542
--num-nodes "${preemPoolSize}" \
581543
--no-enable-autoupgrade \
582544
--enable-autorepair
545+
546+
gcloud container clusters get-credentials "${clusterName}" --project "${project_id}" --zone "${zone}"
547+
583548
}
584549

550+
setup-gitter() {
551+
552+
: ${workshopNamespace:? required}
553+
: ${gitterRoom:? required}
554+
: ${GITTER_OAUTH_KEY:? required}
555+
: ${GITTER_OAUTH_SECRET:? required}
556+
557+
558+
echo "Import gitter keys from gitter.env"
559+
echo "Create secrets"
560+
kubectl create secret generic gitter \
561+
--from-literal=GITTER_OAUTH_KEY=$GITTER_OAUTH_KEY \
562+
--from-literal=GITTER_OAUTH_SECRET=$GITTER_OAUTH_SECRET
563+
564+
curl -sL https://raw.githubusercontent.com/lalyos/gitter-scripter/master/gitter-template.yaml \
565+
| envsubst \
566+
| kubectl apply -f -
567+
568+
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"}]}}}}'
569+
570+
}}
571+
585572
[[ -e .profile ]] && source .profile || true
586573

587574
main() {

0 commit comments

Comments
 (0)