Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- set -v
- # this paste contains the commands run during the "setup GitLab in GKE" video at https://www.youtube.com/watch?v=8vM374-H0zE
- # additional information can be found at https://docs.gitlab.com/ee/install/kubernetes/gitlab_chart.html
- # once configured, you will be able to access your cluster at
- # https://gitlab.$CLUSTERNAME.$DOMAINNAME
- # PROJECTNAME should be your GKE project
- # DNSZONE is the name of the zone configuration in Google Cloud DNS
- export CLUSTERNAME=your-cluster-name
- export PROJECTNAME=your-gke-project
- export DNSZONE=your-gcloud-dns-zone
- export DOMAINNAME=your-domain-name.com
- # create cluster
- gcloud container clusters create $CLUSTERNAME --machine-type "n1-standard-2" --num-nodes "3" --zone "europe-west1-b"
- # create static ip
- gcloud beta compute --project=$PROJECTNAME addresses create $CLUSTERNAME --region=europe-west1 --network-tier=PREMIUM
- # switch to admin
- export ADMINPASS=`gcloud container clusters describe $CLUSTERNAME |grep password: |cut -d ":" -f 2|sed 's/ //'`
- kubectl config set-credentials admin/$CLUSTERNAME --username=admin --password=$ADMINPASS
- kubectl config set-context gke_${PROJECTNAME}_europe-west1-b_$CLUSTERNAME --user=admin/$CLUSTERNAME
- kubectl config use-context gke_${PROJECTNAME}_europe-west1-b_$CLUSTERNAME
- # make your account an admin
- kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)
- # switch back to self
- gcloud beta container clusters get-credentials $CLUSTERNAME --region=europe-west1-b
- # make tiller service account
- kubectl create serviceaccount --namespace kube-system tiller
- kubectl create clusterrolebinding tiller-clusterrolebinding --clusterrole cluster-admin --serviceaccount kube-system:tiller
- # setup helm
- helm init --service-account tiller --wait
- helm repo add gitlab https://charts.gitlab.io/
- helm repo update
- # get static IP
- export STATICIP=`gcloud compute addresses describe $CLUSTERNAME --region europe-west1 |grep address: |cut -d ":" -f 2|sed 's/ //'`
- # setup DNS
- gcloud dns --project=$PROJECTNAME record-sets transaction start --zone=$DNSZONE
- gcloud dns --project=$PROJECTNAME record-sets transaction add $STATICIP --name=gitlab.$CLUSTERNAME.$DOMAINNAME. --ttl=300 --type=A --zone=$DNSZONE
- gcloud dns --project=$PROJECTNAME record-sets transaction execute --zone=$DNSZONE
- helm upgrade --install gitlab gitlab/gitlab --timeout 600 --set global.hosts.domain=$CLUSTERNAME.$DOMAINNAME --set global.hosts.externalIP=$STATICIP --set certmanager-issuer.email=$(gcloud config get-value account)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement