Skip to content

Commit 7348de2

Browse files
committed
Add support for deploying without using Kubernetes secrets, and to disable RBAC resources
1 parent 9177600 commit 7348de2

File tree

13 files changed

+42
-13
lines changed

13 files changed

+42
-13
lines changed

charts/sourcegraph/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ In addition to the documented values, all services also support the following va
249249
| preciseCodeIntel.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `precise-code-intel-worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
250250
| preciseCodeIntel.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `precise-code-intel-worker` |
251251
| preciseCodeIntel.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
252-
| priorityClasses | list | `[]` | Additional priorityClasses minimise re-scheduling downtime for StatefulSets. Each StatefulSets might use different priority class. learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) Sample class definition: - name: gitserver-class value: 100 preemptionPolicy: Never description: "gitserver priority class" |
252+
| priorityClasses | list | `[]` | Additional priorityClasses minimize re-scheduling downtime for StatefulSets. Each StatefulSets might use different priority class. learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) Sample class definition: - name: gitserver-class value: 100 preemptionPolicy: Never description: "gitserver priority class" |
253253
| prometheus.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":false,"runAsGroup":100,"runAsUser":100}` | Security context for the `prometheus` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
254+
| prometheus.createRoleBinding | bool | `true` | Disable the creation of a RoleBinding object, for customers who block all RBAC resource creation |
254255
| prometheus.enabled | bool | `true` | Enable `prometheus` (recommended) |
255256
| prometheus.existingConfig | string | `""` | Name of existing ConfigMap for `pgsql`. It must contain a `prometheus.yml` key |
256257
| prometheus.image.defaultTag | string | `"6.0.0@sha256:86a315720fd9813d9ef9746d92e637bc20cd9ebd90da78d8cc6906062252891f"` | Docker image tag for the `prometheus` image |
@@ -302,6 +303,7 @@ In addition to the documented values, all services also support the following va
302303
| searcher.storageSize | string | `"26Gi"` | Size of the PVC for searcher pods to store cache data |
303304
| sgTestConnection | object | `{"enabled":true}` | Enable the busybox connection test after deployment |
304305
| sourcegraph.affinity | object | `{}` | Global Affinity, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
306+
| sourcegraph.disableKubernetesSecrets | bool | `false` | Disable the creation of Kubernetes secrets objects |
305307
| sourcegraph.image.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Global docker image tag |
306308
| sourcegraph.image.pullPolicy | string | `"IfNotPresent"` | Global docker image pull policy |
307309
| sourcegraph.image.repository | string | `"index.docker.io/sourcegraph"` | Global docker image registry or prefix |
@@ -313,6 +315,8 @@ In addition to the documented values, all services also support the following va
313315
| sourcegraph.nodeSelector | object | `{}` | Global NodeSelector, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) |
314316
| sourcegraph.podAnnotations | object | `{}` | Add extra annotations to attach to all pods |
315317
| sourcegraph.podLabels | object | `{}` | Add extra labels to attach to all pods |
318+
| sourcegraph.redisCacheEndpoint | string | `""` | Set the value of the REDIS_CACHE_ENDPOINT environment variable on the needed containers, when Kubernetes secrets are disabled |
319+
| sourcegraph.redisStoreEndpoint | string | `""` | Set the value of the REDIS_STORE_ENDPOINT environment variable on the needed containers, when Kubernetes secrets are disabled |
316320
| sourcegraph.revisionHistoryLimit | int | `10` | Global deployment clean up policy, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#clean-up-policy) |
317321
| sourcegraph.serviceLabels | object | `{}` | Add extra labels to all services |
318322
| sourcegraph.tolerations | list | `[]` | Global Tolerations, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) |

charts/sourcegraph/templates/_helpers.tpl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For top-level services, pass in the top-level values:
4545
{{ include "sourcegraph.serviceAccountName" (list . "frontend") }}
4646

4747
frontend:
48-
serivceAccount:
48+
serviceAccount:
4949
create: false
5050

5151
For nested services, pass in the nested values:
@@ -249,6 +249,12 @@ app.kubernetes.io/name: jaeger
249249
{{- end }}
250250

251251
{{- define "sourcegraph.redisConnection" -}}
252+
{{- if .Values.sourcegraph.disableKubernetesSecrets -}}
253+
- name: REDIS_CACHE_ENDPOINT
254+
value: {{ .Values.sourcegraph.redisCacheEndpoint }}
255+
- name: REDIS_STORE_ENDPOINT
256+
value: {{ .Values.sourcegraph.redisStoreEndpoint }}
257+
{{- else -}}
252258
- name: REDIS_CACHE_ENDPOINT
253259
valueFrom:
254260
secretKeyRef:
@@ -259,7 +265,8 @@ app.kubernetes.io/name: jaeger
259265
secretKeyRef:
260266
key: endpoint
261267
name: {{ default .Values.redisStore.name .Values.redisStore.connection.existingSecret }}
262-
{{- end }}
268+
{{- end -}}
269+
{{- end -}}
263270

264271
{{- define "sourcegraph.authChecksum" -}}
265272
{{- $checksum := list .Values.codeInsightsDB.auth -}}

charts/sourcegraph/templates/codeinsights-db/codeinsights-db.Secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if not .Values.codeInsightsDB.auth.existingSecret }}
1+
{{- if and (not .Values.sourcegraph.disableKubernetesSecrets) (not .Values.codeInsightsDB.auth.existingSecret) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/sourcegraph/templates/codeintel-db/codeintel-db.Secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if not .Values.codeIntelDB.auth.existingSecret }}
1+
{{- if and (not .Values.sourcegraph.disableKubernetesSecrets) (not .Values.codeIntelDB.auth.existingSecret) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/sourcegraph/templates/frontend/sourcegraph-frontend.Deployment.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ spec:
5252
- name: migrator
5353
image: {{ include "sourcegraph.image" (list . "migrator") }}
5454
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
55+
{{- if .Values.migrator.command }}
56+
command: {{ .Values.migrator.command }}
57+
{{- end }}
5558
args: {{- default (list "up") .Values.migrator.args | toYaml | nindent 8 }}
5659
env:
57-
{{- if not .Values.migrator.databaseAuthOverrideEnvVars }}
60+
{{- if and (not .Values.migrator.databaseAuthOverrideEnvVars) (not .Values.sourcegraph.disableKubernetesSecrets) }}
5861
{{- include "sourcegraph.databaseAuth" (list . "pgsql" "PG") | nindent 8 }}
5962
{{- include "sourcegraph.databaseAuth" (list . "codeIntelDB" "CODEINTEL_PG") | nindent 8 }}
6063
{{- include "sourcegraph.databaseAuth" (list . "codeInsightsDB" "CODEINSIGHTS_PG") | nindent 8 }}
@@ -78,11 +81,16 @@ spec:
7881
- name: frontend
7982
image: {{ include "sourcegraph.image" (list . "frontend") }}
8083
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
84+
{{- if .Values.frontend.command }}
85+
command: {{ .Values.frontend.command }}
86+
{{- end }}
8187
args: {{- default (list "serve") .Values.frontend.args | toYaml | nindent 8 }}
8288
env:
89+
{{- if not .Values.sourcegraph.disableKubernetesSecrets }}
8390
{{- include "sourcegraph.databaseAuth" (list . "pgsql" "PG") | nindent 8 }}
8491
{{- include "sourcegraph.databaseAuth" (list . "codeIntelDB" "CODEINTEL_PG") | nindent 8 }}
8592
{{- include "sourcegraph.databaseAuth" (list . "codeInsightsDB" "CODEINSIGHTS_PG") | nindent 8 }}
93+
{{- end }}
8694
{{- range $name, $item := .Values.frontend.env}}
8795
- name: {{ $name }}
8896
{{- $item | toYaml | nindent 10 }}

charts/sourcegraph/templates/grafana/grafana.StatefulSet.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ spec:
5252
{{- end }}
5353
terminationMessagePolicy: FallbackToLogsOnError
5454
env:
55+
{{- if not .Values.sourcegraph.disableKubernetesSecrets -}}
5556
{{- include "sourcegraph.databaseAuth" (list . "grafana" "GRAFANA_PGSQL_") | nindent 8 }}
57+
{{- end -}}
5658
{{- range $name, $item := .Values.grafana.env}}
5759
- name: {{ $name }}
5860
{{- $item | toYaml | nindent 10 }}

charts/sourcegraph/templates/grafana/grafana.pgsql.Secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.grafana.auth (not .Values.grafana.auth.existingSecret) }}
1+
{{- if and (not .Values.sourcegraph.disableKubernetesSecrets) .Values.grafana.auth (not .Values.grafana.auth.existingSecret) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/sourcegraph/templates/pgsql/pgsql.Secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if not .Values.pgsql.auth.existingSecret }}
1+
{{- if and (not .Values.sourcegraph.disableKubernetesSecrets) (not .Values.pgsql.auth.existingSecret) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/sourcegraph/templates/prometheus/prometheus.ClusterRoleBinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.prometheus.enabled .Values.prometheus.privileged -}}
1+
{{- if and .Values.prometheus.enabled .Values.prometheus.privileged .Values.prometheus.createRoleBinding -}}
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:

charts/sourcegraph/templates/prometheus/prometheus.RoleBinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.prometheus.enabled (not .Values.prometheus.privileged) -}}
1+
{{- if and .Values.prometheus.enabled (not .Values.prometheus.privileged) .Values.prometheus.createRoleBinding -}}
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: RoleBinding
44
metadata:

0 commit comments

Comments
 (0)