Skip to content

Commit c28d901

Browse files
davejrtsanderginn
andauthored
executors: deploy executors with helm (#236)
* add helm chart for executors Co-authored-by: Sander Ginn <[email protected]>
1 parent 0682c8d commit c28d901

16 files changed

+830
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v2
2+
name: sourcegraph-executor
3+
description: Chart for installing Sourcegraph executors
4+
icon: https://sourcegraph.com/favicon.ico
5+
type: application
6+
7+
# Chart version, separate from Sourcegraph
8+
version: "4.4.1"
9+
10+
# Version of Sourcegraph release
11+
appVersion: "4.4.1"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!--
2+
DO NOT EDIT README.md directly.
3+
README.md is automatically generated from README.md.gotmpl
4+
-->
5+
6+
# Sourcegraph Exexutor Helm Chart
7+
8+
This chart contains two deployments, Sourcegraph Executors and a private Docker Registry. It is a supplemental chart for the parent [sourcegraph/sourcegraph] Helm Chart if you wish to deploy executors
9+
10+
Use cases:
11+
12+
- Deploy Sourcegraph Executors on Kubernetes
13+
14+
## Requirements
15+
16+
* [Helm 3 CLI](https://helm.sh/docs/intro/install/)
17+
* Kubernetes 1.19 or greater
18+
19+
## Installation
20+
21+
Add the Sourcegraph charts repo to Helm:
22+
23+
```sh
24+
helm repo add sourcegraph https://helm.sourcegraph.com/release
25+
```
26+
27+
## Usage
28+
29+
> The chart has to be installed in the same namespace as the parent [sourcegraph/sourcegraph] chart
30+
31+
## Rendering manifests for kubectl deployment
32+
33+
Manifests rendered using the `helm template` command can be used for direct deployment using `kubectl`.
34+
35+
## Configuration Options
36+
37+
Reference the table below for available configuration parameters and consult [executor] documentation.
38+
39+
In addition to the documented values, the `executor` and `private-docker-registry` services also supports the following values
40+
41+
- `executor.affinity` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
42+
- `executor.nodeSelector` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
43+
- `executor.tolerations` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
44+
- `executor.podSecurityContext` - [learn more](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
45+
- `executor.env` - consult `values.yaml`
46+
47+
- `privateDockerRegistry.affinity` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
48+
- `privateDockerRegistry.nodeSelector` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
49+
- `privateDockerRegistry.tolerations` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
50+
- `privateDockerRegistry.podSecurityContext` - [learn more](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
51+
- `privateDockerRegistry.env` - consult `values.yaml` file
52+
53+
| Key | Type | Default | Description |
54+
|-----|------|---------|-------------|
55+
| dind.image.registry | string | `"index.docker.io"` | |
56+
| dind.image.repository | string | `"docker"` | |
57+
| dind.image.tag | string | `"20.10.22-dind"` | |
58+
| executor.enabled | bool | `true` | |
59+
| executor.env.EXECUTOR_FRONTEND_PASSWORD | object | `{"value":""}` | The shared secret configured in the Sourcegraph instance site config under executors.accessToken. Required. |
60+
| executor.env.EXECUTOR_FRONTEND_URL | object | `{"value":""}` | The external URL of the Sourcegraph instance. Required. |
61+
| executor.env.EXECUTOR_QUEUE_NAME | object | `{"value":""}` | The name of the queue to pull jobs from to. Possible values: batches and codeintel. Required. |
62+
| executor.image.defaultTag | string | `"4.4.1@sha256:ec8bd27e8599694cfb24341c564b0e4e8947f863d98c4f5b1cb6e67dd8697f53"` | |
63+
| executor.image.name | string | `"executor"` | |
64+
| privateDockerRegistry.image.registry | string | `"index.docker.io"` | |
65+
| privateDockerRegistry.image.repository | string | `"docker/regisry"` | |
66+
| privateDockerRegistry.image.tag | int | `2` | |
67+
| sourcegraph.affinity | object | `{}` | Affinity, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
68+
| sourcegraph.image.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Global docker image tag |
69+
| sourcegraph.image.pullPolicy | string | `"IfNotPresent"` | Global docker image pull policy |
70+
| sourcegraph.image.repository | string | `"index.docker.io/sourcegraph"` | Global docker image registry or prefix |
71+
| sourcegraph.image.useGlobalTagAsDefault | bool | `false` | When set to true, sourcegraph.image.defaultTag is used as the default defaultTag for all services, instead of service-specific default defaultTags |
72+
| sourcegraph.imagePullSecrets | list | `[]` | Mount named secrets containing docker credentials |
73+
| sourcegraph.labels | object | `{}` | Add a global label to all resources |
74+
| sourcegraph.nameOverride | string | `""` | Set a custom name for the app.kubernetes.io/name annotation |
75+
| sourcegraph.nodeSelector | object | `{}` | NodeSelector, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) |
76+
| sourcegraph.podAnnotations | object | `{}` | Add extra annotations to attach to all pods |
77+
| sourcegraph.podLabels | object | `{}` | Add extra labels to attach to all pods |
78+
| sourcegraph.tolerations | list | `[]` | Tolerations, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) |
79+
| storageClass.allowedTopologies | object | `{}` | Persistent volumes topology configuration, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/storage-classes/#allowed-topologies) |
80+
| storageClass.create | bool | `false` | Enable creation of storageClass. Defaults to Google Cloud Platform. Disable if you have your own existing storage class |
81+
| storageClass.name | string | `"sourcegraph"` | Name of the storageClass. Use to customize to the existing storage class name |
82+
| storageClass.parameters | object | `{}` | Extra parameters of storageClass, consult your cloud provider persistent storage documentation |
83+
| storageClass.provisioner | string | `"kubernetes.io/gce-pd"` | Name of the storageClass provisioner, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/storage-classes/#provisioner) and consult your cloud provider persistent storage documentation |
84+
| storageClass.type | string | `"pd-ssd"` | Value of `type` key in storageClass `parameters`, consult your cloud provider persistent storage documentation |
85+
86+
## Troubleshooting
87+
88+
See a list of running executor pods
89+
90+
```sh
91+
kubectl get pods -l app=executor
92+
```
93+
94+
Check logs of the executor container
95+
96+
```sh
97+
kubectl logs -l app=executor -c executor
98+
```
99+
100+
[sourcegraph/sourcegraph]: ../sourcegraph/
101+
[sourcegraph/sourcegraph-executor]: ./
102+
[executor]: https://docs.sourcegraph.com/admin/executors
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!--
2+
DO NOT EDIT README.md directly.
3+
README.md is automatically generated from README.md.gotmpl
4+
-->
5+
6+
# Sourcegraph Exexutor Helm Chart
7+
8+
This chart contains two deployments, Sourcegraph Executors and a private Docker Registry. It is a supplemental chart for the parent [sourcegraph/sourcegraph] Helm Chart if you wish to deploy executors
9+
10+
Use cases:
11+
12+
- Deploy Sourcegraph Executors on Kubernetes
13+
14+
## Requirements
15+
16+
* [Helm 3 CLI](https://helm.sh/docs/intro/install/)
17+
* Kubernetes 1.19 or greater
18+
19+
## Installation
20+
21+
Add the Sourcegraph charts repo to Helm:
22+
23+
```sh
24+
helm repo add sourcegraph https://helm.sourcegraph.com/release
25+
```
26+
27+
## Usage
28+
29+
> The chart has to be installed in the same namespace as the parent [sourcegraph/sourcegraph] chart
30+
31+
## Rendering manifests for kubectl deployment
32+
33+
Manifests rendered using the `helm template` command can be used for direct deployment using `kubectl`.
34+
35+
## Configuration Options
36+
37+
Reference the table below for available configuration parameters and consult [executor] documentation.
38+
39+
In addition to the documented values, the `executor` and `private-docker-registry` services also supports the following values
40+
41+
- `executor.affinity` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
42+
- `executor.nodeSelector` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
43+
- `executor.tolerations` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
44+
- `executor.podSecurityContext` - [learn more](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
45+
- `executor.env` - consult `values.yaml`
46+
47+
- `privateDockerRegistry.affinity` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
48+
- `privateDockerRegistry.nodeSelector` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
49+
- `privateDockerRegistry.tolerations` - [learn more](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
50+
- `privateDockerRegistry.podSecurityContext` - [learn more](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
51+
- `privateDockerRegistry.env` - consult `values.yaml` file
52+
53+
{{ template "chart.valuesTable" . }}
54+
55+
## Troubleshooting
56+
57+
See a list of running executor pods
58+
59+
```sh
60+
kubectl get pods -l app=executor
61+
```
62+
63+
Check logs of the executor container
64+
65+
```sh
66+
kubectl logs -l app=executor -c executor
67+
```
68+
69+
[sourcegraph/sourcegraph]: ../sourcegraph/
70+
[sourcegraph/sourcegraph-executor]: ./
71+
[executor]: https://docs.sourcegraph.com/admin/executors
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "sourcegraph.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create chart name and version as used by the chart label.
10+
*/}}
11+
{{- define "sourcegraph.chart" -}}
12+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
13+
{{- end }}
14+
15+
{{/*
16+
Common labels
17+
*/}}
18+
{{- define "sourcegraph.labels" -}}
19+
helm.sh/chart: {{ include "sourcegraph.chart" . }}
20+
{{ include "sourcegraph.selectorLabels" . }}
21+
{{- if .Chart.AppVersion }}
22+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
23+
{{- end }}
24+
app.kubernetes.io/managed-by: {{ .Release.Service }}
25+
{{- if .Values.sourcegraph.labels }}
26+
{{ toYaml .Values.sourcegraph.labels }}
27+
{{- end }}
28+
{{- end }}
29+
30+
{{/*
31+
Selector labels
32+
*/}}
33+
{{- define "sourcegraph.selectorLabels" -}}
34+
app.kubernetes.io/name: {{ include "sourcegraph.name" . }}
35+
app.kubernetes.io/instance: {{ .Release.Name }}
36+
{{- end }}
37+
38+
{{/*
39+
Create the name of the service account to use
40+
*/}}
41+
{{- define "sourcegraph.serviceAccountName" -}}
42+
{{- $top := index . 0 }}
43+
{{- $service := index . 1 }}
44+
{{- default $service (index $top.Values $service "serviceAccount" "name") }}
45+
{{- end }}
46+
47+
{{/*
48+
Create the docker image reference and allow it to be overridden on a per-service basis
49+
Default tags are toggled between a global and service-specific setting by the
50+
useGlobalTagAsDefault configuration
51+
*/}}
52+
{{- define "sourcegraph.image" -}}
53+
{{- $top := index . 0 }}
54+
{{- $service := index . 1 }}
55+
{{- $imageName := (index $top.Values $service "image" "name")}}
56+
{{- $defaultTag := (index $top.Values $service "image" "defaultTag")}}
57+
{{- if $top.Values.sourcegraph.image.useGlobalTagAsDefault }}{{ $defaultTag = (tpl $top.Values.sourcegraph.image.defaultTag $top) }}{{ end }}
58+
59+
{{- $top.Values.sourcegraph.image.repository }}/{{ $imageName }}:{{ default $defaultTag (index $top.Values $service "image" "tag") }}
60+
{{- end }}
61+
62+
{{- define "sourcegraph.nodeSelector" -}}
63+
{{- $top := index . 0 }}
64+
{{- $service := index . 1 }}
65+
{{- $globalNodeSelector := (index $top.Values "sourcegraph" "nodeSelector") }}
66+
{{- $serviceNodeSelector := (index $top.Values $service "nodeSelector") }}
67+
nodeSelector:
68+
{{- if $serviceNodeSelector }}
69+
{{- $serviceNodeSelector | toYaml | trim | nindent 2 }}
70+
{{- else if $globalNodeSelector }}
71+
{{- $globalNodeSelector | toYaml | trim | nindent 2 }}
72+
{{- end }}
73+
{{- end }}
74+
75+
{{- define "sourcegraph.affinity" -}}
76+
{{- $top := index . 0 }}
77+
{{- $service := index . 1 }}
78+
{{- $globalAffinity := (index $top.Values "sourcegraph" "affinity") }}
79+
{{- $serviceAffinity := (index $top.Values $service "affinity") }}
80+
affinity:
81+
{{- if $serviceAffinity }}
82+
{{- tpl ($serviceAffinity | toYaml) $top | trim | nindent 2 }}
83+
{{- else if $globalAffinity }}
84+
{{- tpl ($globalAffinity | toYaml) $top | trim | nindent 2 }}
85+
{{- end }}
86+
{{- end }}
87+
88+
{{- define "sourcegraph.tolerations" -}}
89+
{{- $top := index . 0 }}
90+
{{- $service := index . 1 }}
91+
{{- $globalTolerations := (index $top.Values "sourcegraph" "tolerations") }}
92+
{{- $serviceTolerations := (index $top.Values $service "tolerations") }}
93+
tolerations:
94+
{{- if $serviceTolerations }}
95+
{{- $serviceTolerations | toYaml | trim | nindent 2 }}
96+
{{- else if $globalTolerations }}
97+
{{- $globalTolerations | toYaml | trim | nindent 2 }}
98+
{{- end }}
99+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if .Values.executor.enabled -}}
2+
apiVersion: v1
3+
data:
4+
daemon.json: |
5+
{ "insecure-registries":["private-docker-registry:5000"] }
6+
7+
kind: ConfigMap
8+
metadata:
9+
labels:
10+
app: executor
11+
deploy: sourcegraph
12+
app.kubernetes.io/component: executor
13+
name: docker-config
14+
{{- end }}

0 commit comments

Comments
 (0)