How to deploy Sourcegraph to GCP with Kubernetes
This is a transcription of the video by Dax and Beatrix listed under the same title.
These instructions assume you have the gcloud sdk installed in your terminal. Use brew install or consult official documentation.
This enablement doc is intended to instruct support team members with steps for creating temporary Sourcegraph kubernetes deployments for temporary testing on our google cloud platform cloud account. If you create a project Please remember to turn it off when you’re done.
Provision cluster on Google cloud platform
- Navigate to the the google cloud provider dashboard and select the engineering projects folder. Then select the cse-k8s project. This is a divergence from the video in which a project space is created from which to provision a cluster.
- With the cse-k8s project space now selected, navigate to the Kubernetes Engine page, and select Clusters. We will now provision a cluster.
- Select create and then the GKE Standard option.
- In the Cluster basics options prefix the default with your name. Other fields can be left as their defaults.
- Select default-pool to modify the nodes of the cluster
- Enable autoscaling and set maximum number to 10
- Select Nodes, for the Machine Type field select e2-standard-16 (16 CPUs and 16 GB memory), the remaining fields may be left as default
- Again under Nodes ensure that Container-Optimized OS with Containerd is selected.
- Once your configuration is complete select Create and wait for your cluster to deploy. (again this can take some time), you can observe the progress by selecting the cluster.
- With the cluster created and selected in the clusters dashboard. Select the Connect button and execute the listed command in your terminal (google cloud sdk must be installed for this step)
The following instructions track along with our official configure and install Sourcegraph kubernetes documentation.
- Follow the configuration docs to set up a fork of Sourcegraph at the version you want.
- Run the following command from our installation docs to give your gcloud user the ability to create roles in Kubernetes
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)
- Configure a storage class and apply it with
kubectl apply -f <filepath>
- With the storage class created and applied you may now create pods with the default
./kubectl-apply-all.shor generate an overlay of your choice to apply, see config docs
- You can now port forward your k8s deployment to localhost with
kubectl port-forward svc/sourcegraph-frontend 3080:30080(note you may need to add
-n ns-sourcegraphto the command)