Managing CS-GKE Kubernetes Instance

Our Kubernetes(K8s) test instance is hosted on Google Kubernetes Engine (GKE) . The instance was setup following the instructions found on Sourcegraph.com. To manage cloud resources and networking you must have access to Sourcegraph Google Cloud.

URL

You can access the instance by visiting https://cse-k8s.sgdev.org/ (note that the URL reflects the old title we used on the team)

Local Configuration

To access the CS-GKE instance and run Kubernetes commands locally, you’ll need to do the following:

  1. Before you begin, please make sure you have gcloud command-line tool and kubectl command-line tool installed on your local machine.
  2. Make sure you are authenticated with the Google Cloud SDK. One option is in your terminal run gcloud auth login. That should bring up a browser window to authenticate your work email.
  3. Generate a kubeconfig entry by running the following command: gcloud container clusters get-credentials beatrix-test --zone us-central1-c --project beatrix-test-overlay
  4. Make sure you can access your cluster with kubectl by running the following command: kubectl config view
  5. You should now have access to the CS-GKE instance and run Kubernetes commands locally via kubectl.

Configuring instance resources

To make changes to the replicas and container resources on this instance, update the resources file in the namespaced overlay. Apply the changes by running ./overlay-generate-cluster.sh namespaced generated-cluster, followed by kubectl apply -n ns-sourcegraph --prune -l deploy=sourcegraph -f generated-cluster --recursive

Upgrading CS-GKE Kubernetes Instance

We are currently deployed using this deploy-sourcegraph-cse-k8s repository. To upgrade the instance:

https://github.com/sourcegraph/deploy-sourcegraph-cse-k8s

  1. Clone the deploy-sourcegraph-cse-k8s repository to your local machine.
  2. cd into the newly cloned directory.
  3. Make sure you are on the main branch: git checkout master
  4. Get the latest version of Sourcegraph from the upstream by running git fetch upstream

    Note: you may need to set the upstream origin on your master branch

 git remote add upstream https://github.com/sourcegraph/deploy-sourcegraph
  1. Merge the latest update from upstream to the release branch: git checkout release
  2. Choose which version you want to deploy from the Sourcegraph release page then run: git merge $NEW_VERSION.
  3. After merging, you’re likely to encounter some merge conflicts. Please resolve them(most of them require clicking on Accept Incoming Change - if you’re using MS Studio as your code editor.
  4. You can then add and commit the changes by running git add . followed by git commit -m "$YOUR_COMMIT_MESSAGE"
  5. You can confirm if the merge was successful, if it was, then run ./overlay-generate-cluster.sh namespaced generated-cluster, followed by kubectl apply -n ns-sourcegraph --prune -l deploy=sourcegraph -f generated-cluster --recursive.
  6. Check the status of the pods to confirm that everything is running properly by executing kubectl get pods -n ns-sourcegraph.
  7. Confirm the new version here
  8. Please don’t forget to git push to our repo to give folks a head up that you made the upgrade!

Video on how upgrading the instance looks like: https://drive.google.com/file/d/1aWsXejG2qeFKGrY5BGzpSabwGuU1gLM3/view

  • Basic functions and commands (e.g. how to view the names of services and get their logs) can be viewed here.