Using local SSDs dramatically speeds up many of Sourcegraph's services. Even if the cluster's default storage class uses SSDs, it's likely network-mounted rather than local. Read your cloud provider's documentation for mouting local SSDs.
If you mount local SSDs on your nodes:
-
Change the
cache-ssd
volume to point to${SSD_NODE_PATH}/pod-tmp
where${SSD_NODE_PATH}
is the absolute path of the SSD on each node.For example, GCP mounts the first SSD disk to
/mnt/disks/ssd0
, so thecache-ssd
volume would be configured like this:volumes: - hostPath: path: /mnt/disks/ssd0/pod-tmp name: cache-ssd
-
Append the
kubectl apply
command for the providedpod-tmp-gc
DaemonSet tokubectl-apply-all.sh
to periodically clean up files in the SSD on each node. This is necessary because files on the SSDs are not automatically cleaned up if pods crash or are rescheduled which can cause the SSDs to fill up.echo kubectl apply --prune -l deploy=pod-tmp-gc -f configure/ssd --recursive >> kubectl-apply-all.sh
-
Apply your changes to
pod-tmp-gc
and the base deployments to the cluster../kubectl-apply-all.sh
Here is a convenience script:
# This script requires https://github.com/sourcegraph/jy and https://github.com/sourcegraph/yj
SSD_NODE_PATH=/mnt/disks/ssd0 # update this to reflect the absolute path where SSDs are mounted on each node
# Mount the SSDs path in each deployment
find . -name "*Deployment.yaml" -exec sh -c "cat {} | yj | jq '(.spec.template.spec.volumes | select(. != null) | .[] | select(.name == \"cache-ssd\")) |= (del(.emptyDir) + {hostPath: {path: \"$SSD_NODE_PATH/pod-tmp\"}})' | jy -o {}" \;
# Update pod-tmp-gc.DaemonSet.yaml with SSD_NODE_PATH
DS=configure/ssd/pod-tmp-gc.DaemonSet.yaml
cat $DS | yj | jq ".spec.template.spec.volumes = [{name: \"pod-tmp\", hostPath: {path: \"$SSD_NODE_PATH/pod-tmp\"}}]" | jy -o $DS
# Deploy everything
echo kubectl apply --prune -l deploy=pod-tmp-gc -f configure/ssd --recursive >> kubectl-apply-all.sh
./kubectl-apply-all.sh
Note: If you are deploying Sourcegraph to a non-default namespace, you'll have to change the namespace specified in configure/ssd/pod-tmp-gc.ClusterRoleBinding.yaml to the one that you created.