You can configure Sourcegraph with k3s to use an HTTP proxy, using these two options:
-
Configure the K3s systemd service.
- Manually add HTTP_PROXY and HTTPS_PROXY environment variables.
Configure the K3s systemd service
This option involves configuring the K3s systemd service to use the HTTP proxy. This configuration will apply to all outgoing connections from K3s and its embedded containerd and kubelet, including connections made by the Sourcegraph application.
1. Create a systemd override for the K3s service by creating the file /etc/systemd/system/k3s.service.d/override.conf
with the following content:
[Service] Environment=CONTAINERD_HTTPS_PROXY=http://1xx.xx.2.254:xxxx
Replace http://1xx.xx.2.254:xxxx
with the URL and port of your HTTP proxy.
2. Reload the systemd daemon:
sudo systemctl daemon-reload
3. Restart the K3s service:
sudo systemctl restart k3s
Manually add HTTP_PROXY and HTTPS_PROXY environment variables
This option involves manually adding the HTTP_PROXY and HTTPS_PROXY environment variables to the Sourcegraph frontend, gitserver, and other deployments.
1. Edit the deployment YAML files for the Sourcegraph components you want to configure (e.g., sourcegraph-frontend
, sourcegraph-gitserver
) and add the following lines under the spec.template.spec.containers.env
section:
- name: HTTP_PROXY
value: http://proxy.example.com:3128
- name: HTTPS_PROXY
value: http://proxy.example.com:3128
Replace http://proxy.example.com:3128
with the URL and port of your HTTP proxy.
2. Save and apply the changes to the deployment:
kubectl apply -f deployment.yaml
If your code host is behind an HTTP proxy, you may need to configure the gitconfig
file. Follow the instructions in the Sourcegraph documentation.