Advertisement
Guest User

Untitled

a guest
Aug 1st, 2018
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -e
  4. set -v
  5.  
  6. # this paste contains the commands run during the "setup GitLab in GKE" video at https://www.youtube.com/watch?v=8vM374-H0zE
  7. # additional information can be found at https://docs.gitlab.com/ee/install/kubernetes/gitlab_chart.html
  8.  
  9. # once configured, you will be able to access your cluster at
  10. # https://gitlab.$CLUSTERNAME.$DOMAINNAME
  11.  
  12. # PROJECTNAME should be your GKE project
  13. # DNSZONE is the name of the zone configuration in Google Cloud DNS
  14.  
  15. export CLUSTERNAME=your-cluster-name
  16. export PROJECTNAME=your-gke-project
  17. export DNSZONE=your-gcloud-dns-zone
  18. export DOMAINNAME=your-domain-name.com
  19.  
  20. # create cluster
  21. gcloud container clusters create $CLUSTERNAME --machine-type "n1-standard-2" --num-nodes "3" --zone "europe-west1-b"
  22.  
  23. # create static ip
  24. gcloud beta compute --project=$PROJECTNAME addresses create $CLUSTERNAME --region=europe-west1 --network-tier=PREMIUM
  25.  
  26. # switch to admin
  27. export ADMINPASS=`gcloud container clusters describe $CLUSTERNAME |grep password: |cut -d ":" -f 2|sed 's/ //'`
  28. kubectl config set-credentials admin/$CLUSTERNAME --username=admin --password=$ADMINPASS
  29. kubectl config set-context gke_${PROJECTNAME}_europe-west1-b_$CLUSTERNAME --user=admin/$CLUSTERNAME
  30. kubectl config use-context gke_${PROJECTNAME}_europe-west1-b_$CLUSTERNAME
  31.  
  32. # make your account an admin
  33. kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)
  34.  
  35. # switch back to self
  36. gcloud beta container clusters get-credentials $CLUSTERNAME --region=europe-west1-b
  37.  
  38. # make tiller service account
  39. kubectl create serviceaccount --namespace kube-system tiller
  40. kubectl create clusterrolebinding tiller-clusterrolebinding --clusterrole cluster-admin --serviceaccount kube-system:tiller
  41.  
  42. # setup helm
  43. helm init --service-account tiller --wait
  44. helm repo add gitlab https://charts.gitlab.io/
  45. helm repo update
  46.  
  47. # get static IP
  48. export STATICIP=`gcloud compute addresses describe $CLUSTERNAME --region europe-west1 |grep address: |cut -d ":" -f 2|sed 's/ //'`
  49.  
  50. # setup DNS
  51. gcloud dns --project=$PROJECTNAME record-sets transaction start --zone=$DNSZONE
  52. gcloud dns --project=$PROJECTNAME record-sets transaction add $STATICIP --name=gitlab.$CLUSTERNAME.$DOMAINNAME. --ttl=300 --type=A --zone=$DNSZONE
  53. gcloud dns --project=$PROJECTNAME record-sets transaction execute --zone=$DNSZONE
  54.  
  55. 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