-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup-k8s.sh
50 lines (39 loc) · 1.47 KB
/
setup-k8s.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
#!/bin/bash
#
# This script is intended to be used for internal testing only, to create the artifacts necessary for
# testing and deploying this code in a sample GKE cluster.
#
set -xe
PROJECT=${PROJECT:-strapdata-factory}
CLUSTER=${CLUSTER:-lab}
ZONE=${ZONE:-europe-west1-b}
NODES=${NODES:-3}
echo "gke: creating cluster"
gcloud container clusters create $CLUSTER \
--zone "$ZONE" \
--project $PROJECT \
--machine-type "n1-standard-2" \
--num-nodes "3"
# --max-nodes "6" \
# --enable-autoscaling
echo "gke: getting credentials"
gcloud container clusters get-credentials $CLUSTER \
--zone $ZONE \
--project $PROJECT
# Configure local auth of docker so that we can use regular
# docker commands to push/pull from our GCR setup.
echo "gke: authenticate to gcr"
gcloud auth configure-docker
# Bootstrap RBAC cluster-admin for your user.
# More info: https://cloud.google.com/kubernetes-engine/docs/how-to/role-based-access-control
echo "gke: bootstrap RBAC"
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin --user $(gcloud config get-value account)
echo "gke: starting proxy"
exec nohup kubectl proxy &
# Create google-specific custom resources in the cluster.
echo "gke: create google app crd"
kubectl apply -f "https://raw.githubusercontent.com/GoogleCloudPlatform/marketplace-k8s-app-tools/master/crd/app-crd.yaml"
echo "gke: cluster created"
# TO DELETE:
# gcloud beta container clusters delete lab --region europe-west1-b