Deploying Sourcegraph on Kubernetes is for organizations that need highly scalable and available code search and code navigation.
NOTE: Sourcegraph recommends using Helm to deploy Sourcegraph if possible. This page covers a more manual Kubernetes deployment, using
kubectlto deploy manifests. This is only recommended if Helm cannot be used in your Kubernetes enviroment. See the Helm guide for more information on why Helm is preferable.
Our Kubernetes support has the following requirements:
- Sourcegraph Enterprise license. You can run through these instructions without one, but you must obtain a license for instances of more than 10 users
- A deployed kubernetes cluster. You can do this yourself, or use our terraform configs to quickly deploy a cluster that will support a standard Sourcegraph instance on Google Cloud Platform (GKE) or Amazon Web Services (EKS).
- Minimum Kubernetes version: v1.19 and kubectl v1.19 or later (check kubectl docs for backward and forward compatibility with Kubernetes versions)
- Support for Persistent Volumes (SSDs recommended)
We also recommend some familiarity with the following Kubernetes concepts before proceeding:
Not sure if Kubernetes is the right choice for you? Learn more about the various Sourcegraph installation options.
Before starting, we recommend reading the configuration guide, ensuring you have prepared the items below so that you're ready to start your installation:
- Customization
- Storage class
- Network Access
- PostgreSQL Database
- Scaling services
- Cluster role administrator access
WARNING: If you are deploying on Azure, you must ensure that your cluster is created with support for CSI storage drivers. This can not be enabled after the fact.
Once you are all set up, either install Sourcegraph directly or deploy Sourcegraph to a cloud of your choice.
Sourcegraph for Kubernetes is configured using our sourcegraph/deploy-sourcegraph reference repository. This repository contains everything you need to spin up and configure a Sourcegraph deployment on Kubernetes.
-
After meeting all the requirements, make sure you can access your cluster with
kubectl. -
cdto the forked local copy of the deploy-sourcegraph repository previously set up during configuration. -
Deploy the desired version of Sourcegraph to your cluster by applying the Kubernetes manifests:
./kubectl-apply-all.sh
NOTE: Google Cloud Platform (GCP) users are required to give their user the ability to create roles in Kubernetes (Learn more):
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account) -
Monitor the status of the deployment:
kubectl get pods -o wide --watch
-
After deployment is completed, verify Sourcegraph is running by temporarily making the frontend port accessible:
kubectl port-forward svc/sourcegraph-frontend 3080:30080
-
Open http://localhost:3080 in your browser and you will see a setup page. Congratulations, you have Sourcegraph up and running! 🎉
NOTE: If you previously set up an
ingress-controller, you can now also access your deployment via the ingress.
WARNING: If you intend to set this up as a production instance, we recommend you create the cluster in a VPC or other secure network that restricts unauthenticated access from the public Internet. You can later expose the necessary ports via an Internet Gateway or equivalent mechanism. Note that SG must expose port 443 for outbound traffic to codehosts and to enable telemetry with Sourcegraph.com. Additionally port 22 may be opened to enable git SSH cloning by Sourcegraph. Take care to secure your cluster in a manner that meets your organization's security requirements.
Follow the instructions linked in the table below to provision a Kubernetes cluster for the infrastructure provider of your choice, using the recommended node and list types in the table.
| Provider | Node type | Boot/ephemeral disk size |
|---|---|---|
| Amazon EKS (better than plain EC2) | m5.4xlarge | 100 GB (SSD preferred) |
| AWS EC2 | m5.4xlarge | 100 GB (SSD preferred) |
| Google Kubernetes Engine (GKE) | n1-standard-16 | 100 GB (default) |
| Azure | D16 v3 | 100 GB (SSD preferred) |
| Other | 16 vCPU, 60 GiB memory per node | 100 GB (SSD preferred) |
NOTE: Sourcegraph can run on any Kubernetes cluster, so if your infrastructure provider is not listed, see the "Other" row. Pull requests to add rows for more infrastructure providers are welcome!
WARNING: If you are deploying on Azure, you must ensure that your cluster is created with support for CSI storage drivers. This can not be enabled after the fact.
WARNING: Running Sourcegraph on ARM / ARM64 images is not supported for production deployments.