Note: This is pre-release software. Existing users of Sourcegraph Data Center should still refer to the installation instructions here: https://about.sourcegraph.com/docs/datacenter/.
The Data Center deployment option for Sourcegraph is for organizations that need highly scalable, highly available code search and intelligence for 10,000s of repositories and users. See pricing, and contact us for more information.
Sourcegraph Data Center is deployed using Kubernetes. Before proceeding with these instructions, provision a Kubernetes cluster on the infrastructure of your choice.
-
Install Tiller (the server-side counterpart to Helm) on your cluster:
# Give Helm privileges to create RBAC resources. kubectl create serviceaccount --namespace kube-system tiller kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller # Add Helm to your cluster using the created service account. helm init --service-account tiller
If installing Tiller is not an option, consult the instructions below for installing without Tiller. If your Kubernetes environment does not permite RBAC, consult the instructions below for installing without RBAC.
Azure AKS doesn't have RBAC Azure/AKS#67
- Create a
values.yaml
file with the following contents:
cluster:
storageClass:
create: {none,aws,gcp,managed-premium}
site: {}
Set the create
field to "aws" or "gcp" if you are using AWS or Google Cloud. Set it to managed-premium
if you're using Azure. Otherwise, set it to "none".
- If you set it to "aws" or "gcp", you also need to set
cluster.storageClass.zone
to the zone in which your cluster resides. - If you set it to "none", you need to create a storage class in your cluster with name "default" that defines the persistent volumes to be auto-provisioned in the cluster (we recommend low-latency SSDs). For more info, see the section below on creating a storage class manually.
-
Install the Helm chart to your cluster:
helm install --name sourcegraph -f values.yaml https://github.com/sourcegraph/datacenter/archive/latest.tar.gz
If you see the error
could not find a ready tiller pod
, wait a minute and try again. -
Confirm that your deployment is launching by running
kubectl get pods
. If pods get stuck inPending
status, runkubectl get pv
to check if the necessary volumes have been provisioned (you should see at least 4). Google Cloud Platform users may need to request an increase in storage quota. -
When the deployment completes, you need to make the main web server accessible over the network to external users. To do so, connect port 30080 (or the value of
httpNodePort
in the site config) on the nodes in the cluster to the Internet. The easiest way to do this is to add a network rule that allows ingress traffic to port 30080 on at least one node (see AWS Security Group rules, Google Cloud Platform Firewall rules). Sourcegraph should then be accessible at$EXTERNAL_ADDR_OF_YOUR_NODE:30080
. For production environments, we recommend using an Internet Gateway (or equivalent) and configuring a load balancer in Kubernetes.
You will now see the Sourcegraph setup page when you visit the address of your instance. If you made your instance accessible on the public Internet, make sure you secure it before adding your private repositories.
Sourcegraph Data Center communicates with the Kubernetes API for service discovery. It also has some janitor DaemonSets which clean up temporary cache data. To do that we need to create RBAC resources. For details, see Helm's Role-based Access Control documentation.
If using RBAC is not an option, you can set "site.rbac": "disabled"
in values.yaml
and run helm init
instead of
helm init --service-account tiller
to install Tiller.
If installing Tiller is not an option, you can locally generate the Kubernetes configuration by running the following:
mkdir -p generated
helm template -f constants.yaml -f values.yaml . --output-dir=generated
kubectl apply -R -f ./generated/sourcegraph/templates
If cluster.storageClass.create
is set to none
, then you will need to create a storage class manually:
- Create a file called
storage-class.yaml
that meets the requirements described in the Kubernetes docs. The name of the storage class should match the name set incluster.storageClass.name
("default" by default). We recommend specifying SSDs as the disk type if possible. - Run
kubectl apply -f storage-class.yaml
. - You should see the storage class appear when you run
kubectl get storageclass
.
After installing the Sourcegraph Helm chart, you should see persistent volume claims (kubectl get pvc
) bound to
volumes provisioned using this storage class.
You can set additional values in values.yaml
to configure your cluster. The default set of configuration values is
defined by the values.yaml
file in this directory.
The configuration structure is split into two top-level fields:
site
defines application-level settings like code host integrations and authentication settings. The full set of options forsite
is described here: https://about.sourcegraph.com/docs/config/settings.cluster
defines settings specific to the configuration of the Kubernetes cluster, like replica counts and CPU/memory allocation. Allcluster
settings are explicitly set invalues.yaml
, so refer to this file if you wish to override any of the default values.
Versions of Sourcegraph Data Center are released as tags in this Git repository. To update to a new version, fetch this
repository and check out the appropriate tag. To conveniently update to new versions of Data Center while additionally
tracking changes to your specific configuration (values.yaml
), we recommend the following procedure:
- Fork this repository.
- Clone your fork and configure the local clone to have an additional remote
upstream
set tohttps://github.com/sourcegraph/datacenter
. - Copy
defaults.yaml
tovalues.yaml
and keep your custom configuration invalues.yaml
. Push changes tomaster
in your fork. - On update:
- Run
git fetch upstream && git rebase upstream/master
. There should never be conflicts, because you have not modified any of the original files. - Run
git checkout $VERSION && git cherry-pick upstream/master...master
to cherry-pick yourvalues.yaml
onto the tagged revision that contains the source files for the new version of Data Center. - Install the
helm-diff
plugin (helm plugin install https://github.com/databus23/helm-diff
). Then runhelm diff -f constants.yaml -f values.yaml sourcegraph .
to display the update diff. - Run
helm update -f constants.yaml -f values.yaml sourcegraph .
. - After updating, run
watch kubectl get pods -o wide
to verify the health of the cluster.
- Run
If you need to make changes to any of the existing files in this repository, please upstream your changes--pull requests are very welcome!
helm history sourcegraph
helm rollback sourcegraph [REVISION]