Install Sourcegraph with minikube
This guide will take you through how to set up a Sourcegraph instance locally with minikube, a tool that lets you run a single-node Kubernetes cluster on your local machine, using our minikube overlay.
Sourcegraph minikube overlay
The Sourcegraph minikube overlay deletes resource declarations and storage classnames to enable running Sourcegraph on minikube locally with less resources, as it normally takes a lot more of resources to run Sourcegraph at a production level. See our docs on creating custom overlays if you would like to customize the overlay.
Prerequisites
Following are the prerequisites for running Sourcegraph with minikube on your local machine.
- kubectl
- minikube
- Docker Desktop
- Enable Kubernetes in Docker Desktop. See the official docs for detailed instruction.
Deploy
1\. Start a minikube cluster
# Docker must be running in the background $ minikube start
2\. Create a clone of our Kubernetes deployment repository: deploy-sourcegraph
$ git clone https://github.com/sourcegraph/deploy-sourcegraph.git
3\. Check out the branch of the version you would like to deploy
# Example: git checkout v4.1.0 $ git checkout $VERSION-NUMBER
4\. Apply the Sourcegraph minikube overlay by running the following command in the root directory of your local copy of the deploy-sourcegraph repository
$ ./overlay-generate-cluster.sh minikube generated-cluster
5\. Create the ns-sourcegraph
namespace
$ kubectl create namespace ns-sourcegraph
6\. Apply the generated manifests from the generated-cluster
directory
$ kubectl -n ns-sourcegraph apply --prune -l deploy=sourcegraph -f generated-cluster --recursive
7\. Make sure all the pods are up and running before moving to the next step
$ kubectl get pods -A

8\. Create a Service object that exposes the deployment
$ kubectl -n ns-sourcegraph expose deployment sourcegraph-frontend --type=NodePort --name sourcegraph --port=3080 --target-port=3080
9\. Get the minikube node IP to access the nodePorts
$ minikube ip
10\. Get the minikube service endpoint
# To get the service endpoint $ minikube service list # To get the service endpoint for Sourcegraph specifically $ minikube service sourcegraph -n ns-sourcegraph # To get the service endpoint URL for Sourcegraph specificlly $ minikube service --url sourcegraph -n ns-sourcegraph # Example return: http://127.0.0.1:32034
If you are on Linux, an URL will then be displayed in the service list if the instance has been deployed successfully
|----------------|-------------------------------|--------------|---------------------------| | NAMESPACE | NAME | TARGET PORT | URL | | ---------------- | ------------------------------- | -------------- | --------------------------- | | default | kubernetes | No node port | | kube-system | kube-dns | No node port | | ns-sourcegraph | backend | No node port | | ns-sourcegraph | codeinsights-db | No node port | | ns-sourcegraph | codeintel-db | No node port | | ns-sourcegraph | github-proxy | No node port | | ns-sourcegraph | gitserver | No node port | | ns-sourcegraph | grafana | No node port | | ns-sourcegraph | indexed-search | No node port | | ns-sourcegraph | indexed-search-indexer | No node port | | ns-sourcegraph | jaeger-collector | No node port | | ns-sourcegraph | jaeger-query | No node port | | ns-sourcegraph | blobstore | No node port | | ns-sourcegraph | pgsql | No node port | | ns-sourcegraph | precise-code-intel-worker | No node port | | ns-sourcegraph | prometheus | No node port | | ns-sourcegraph | query-runner | No node port | | ns-sourcegraph | redis-cache | No node port | | ns-sourcegraph | redis-store | No node port | | ns-sourcegraph | repo-updater | No node port | | ns-sourcegraph | searcher | No node port | | ns-sourcegraph | sourcegraph | 3080 | http://127.0.0.1:32034 | | ns-sourcegraph | sourcegraph-frontend | No node port | | ns-sourcegraph | sourcegraph-frontend-internal | No node port | | ns-sourcegraph | symbols | No node port | | ns-sourcegraph | syntect-server | No node port | | ns-sourcegraph | worker | No node port | | ---------------- | ------------------------------- | -------------- | --------------------------- |
That's it! You can now access the local Sourcegraph instance in browser using the URL or IP address retrieved from the previous steps 🎉

Upgrade
Please refer to the upgrade docs for all Sourcegraph kubernetes instances.
Downgrade
Same instruction as upgrades.
Uninstall
Steps to remove your Sourcegraph minikube instance:
1\. Delete the ns-sourcegraph
namespace
$ kubectl delete namespaces ns-sourcegraph
2\. Stop the minikube cluster
$ minikube stop
Other userful commands
Un-expose sourcegraph
$ kubectl delete service sourcegraph -n ns-sourcegraph
Gets a list of deployed services and cluster IP
$ kubectl get svc -n ns-sourcegraph
Deletes the minikube cluster
$ minikube delete