From 6cc6e5d3d9717351269bc78d659e016971099b09 Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Mon, 28 Feb 2022 16:37:23 -0800 Subject: [PATCH 1/2] Add examples for using external redis --- .../examples/external-redis/README.md | 82 ++++++++++++++++++ .../override-separate-configmap.yaml | 86 +++++++++++++++++++ .../external-redis/override-separate.yaml | 86 +++++++++++++++++++ .../override-shared-configmap.yaml | 56 ++++++++++++ .../external-redis/override-shared.yaml | 56 ++++++++++++ 5 files changed, 366 insertions(+) create mode 100644 charts/sourcegraph/examples/external-redis/README.md create mode 100644 charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml create mode 100644 charts/sourcegraph/examples/external-redis/override-separate.yaml create mode 100644 charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml create mode 100644 charts/sourcegraph/examples/external-redis/override-shared.yaml diff --git a/charts/sourcegraph/examples/external-redis/README.md b/charts/sourcegraph/examples/external-redis/README.md new file mode 100644 index 00000000..b65c6c15 --- /dev/null +++ b/charts/sourcegraph/examples/external-redis/README.md @@ -0,0 +1,82 @@ +# Using external Redis instances + +Sourcegraph deployment by default ships two separate Redis instances for different purposes + +- [redis-cache.Deployment.yaml](../../templates/redis/redis-cache.Deployment.yaml) +- [redis-store.Deployment.yaml](../../templates/redis/redis-store.Deployment.yaml) + +When using external Redis instances, you’ll need to specify the corresponding environment variable for each of the following deployments: + +> __IMPORTANT__: This list may not be up-to-date. You should always consult the [offical docs](https://docs.sourcegraph.com/admin/install/kubernetes/configure#configure-custom-redis) for the latest list of dependent services. + +- [sourcegraph-frontend.Deployment.yaml](../../templates/frontend/sourcegraph-frontend.Deployment.yaml) +- [repo-updater.Deployment.yaml](../../templates/repo-updater/repo-updater.Deployment.yaml) +- [gitserver.Deployment.yaml](../../templates/gitserver/gitserver.Deployment.yaml) +- [searcher.Deployment.yaml](../../templates/searcher/searcher.Deployment.yaml) +- [symbols.Deployment.yaml](../../templates/symbols/symbols.Deployment.yaml) +- [worker.Deployment.yaml](../../templates/worker/worker.Deployment.yaml) +## Option 1 - One shared external Redis instance + +Example values override: [override-shared.yaml](./override-shared.yaml), [override-shared-configmap.yaml](./override-shared-configmap.yaml) + +### `REDIS_ENDPOINT` + +The string must either have the format `$HOST:PORT` or follow the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis) (e.g., redis://:mypassword@host:6379/2) + +## Option 2 - Two separate external Redis instances + +Example values override: [override-separate.yaml](./override-separate.yaml), [override-separate-configmap.yaml](./override-separate-configmap.yaml) + +### `REDIS_CACHE_ENDPOINT` + +The string must either have the format `$HOST:PORT` or follow the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis) (e.g., redis://:mypassword@host:6379/2) + +### `REDIS_STORE_ENDPOINT` + +The string must either have the format `$HOST:PORT` or follow the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis) (e.g., redis://:mypassword@host:6379/2) + +## Notes + +You may store these sensitive environment variables in a [Secret](https://kubernetes.io/docs/concepts/configuration/secret/). + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: sourcegraph-external-redis-credentials +data: + # notes: secrets data has to be base64-encoded + REDIS_ENDPOINT: "" +``` + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: sourcegraph-external-redis-credentials +data: + # notes: secrets data has to be base64-encoded + REDIS_CACHE_ENDPOINT: "" + REDIS_STORE_ENDPOINT: "" +``` + +Optionally, if your external Redis instances do not required authentication, you may use a [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: sourcegraph-external-redis-credentials +data: + REDIS_ENDPOINT: "redis://redis.example.com:6379/2" +``` + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: sourcegraph-external-redis-credentials +data: + REDIS_CACHE_ENDPOINT: "redis://redis-cache.example.com:6379/2" + REDIS_STORE_ENDPOINT: "redis://redis-store.example.com:6379/2" +``` diff --git a/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml b/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml new file mode 100644 index 00000000..b24ef962 --- /dev/null +++ b/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml @@ -0,0 +1,86 @@ +# Demonstrate using external redis instance(s) +# Disables deployment of the internal `redis-cache` and `redis-store` deployment + +frontend: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +repoUpdater: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +gitserver: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +searcher: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +symbols: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +worker: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +redisCache: + enabled: false + +redisStore: + enabled: false diff --git a/charts/sourcegraph/examples/external-redis/override-separate.yaml b/charts/sourcegraph/examples/external-redis/override-separate.yaml new file mode 100644 index 00000000..1a659885 --- /dev/null +++ b/charts/sourcegraph/examples/external-redis/override-separate.yaml @@ -0,0 +1,86 @@ +# Demonstrate using external redis instance(s) +# Disables deployment of the internal `redis-cache` and `redis-store` deployment + +frontend: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +repoUpdater: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +gitserver: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +searcher: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +symbols: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +worker: + env: + REDIS_CACHE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_CACHE_ENDPOINT + REDIS_STORE_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_STORE_ENDPOINT + +redisCache: + enabled: false + +redisStore: + enabled: false diff --git a/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml b/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml new file mode 100644 index 00000000..55f7126c --- /dev/null +++ b/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml @@ -0,0 +1,56 @@ +# Demonstrate using external redis instance(s) +# Disables deployment of the internal `redis-cache` and `redis-store` deployment + +frontend: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +repoUpdater: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +gitserver: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +searcher: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +symbols: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +worker: + env: + REDIS_ENDPOINT: + valueFrom: + configMapKeyRef: # Pre-existing configmap, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +redisCache: + enabled: false + +redisStore: + enabled: false diff --git a/charts/sourcegraph/examples/external-redis/override-shared.yaml b/charts/sourcegraph/examples/external-redis/override-shared.yaml new file mode 100644 index 00000000..ce108e3a --- /dev/null +++ b/charts/sourcegraph/examples/external-redis/override-shared.yaml @@ -0,0 +1,56 @@ +# Demonstrate using external redis instance(s) +# Disables deployment of the internal `redis-cache` and `redis-store` deployment + +frontend: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +repoUpdater: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +gitserver: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +searcher: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +symbols: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +worker: + env: + REDIS_ENDPOINT: + valueFrom: + secretKeyRef: # Pre-existing secret, not created by this chart + name: sourcegraph-external-redis-credentials + key: REDIS_ENDPOINT + +redisCache: + enabled: false + +redisStore: + enabled: false From 89b4cac1c36551b928ed333aeb10d02fc2ea0426 Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Wed, 2 Mar 2022 12:28:49 -0800 Subject: [PATCH 2/2] Remove configmap examples --- .../examples/external-redis/README.md | 6 +- .../override-separate-configmap.yaml | 86 ------------------- .../override-shared-configmap.yaml | 56 ------------ 3 files changed, 3 insertions(+), 145 deletions(-) delete mode 100644 charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml delete mode 100644 charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml diff --git a/charts/sourcegraph/examples/external-redis/README.md b/charts/sourcegraph/examples/external-redis/README.md index b65c6c15..101d7fdd 100644 --- a/charts/sourcegraph/examples/external-redis/README.md +++ b/charts/sourcegraph/examples/external-redis/README.md @@ -17,7 +17,7 @@ When using external Redis instances, you’ll need to specify the corresponding - [worker.Deployment.yaml](../../templates/worker/worker.Deployment.yaml) ## Option 1 - One shared external Redis instance -Example values override: [override-shared.yaml](./override-shared.yaml), [override-shared-configmap.yaml](./override-shared-configmap.yaml) +Example values override [override-shared.yaml](./override-shared.yaml) ### `REDIS_ENDPOINT` @@ -25,7 +25,7 @@ The string must either have the format `$HOST:PORT` or follow the [IANA specific ## Option 2 - Two separate external Redis instances -Example values override: [override-separate.yaml](./override-separate.yaml), [override-separate-configmap.yaml](./override-separate-configmap.yaml) +Example values override [override-separate.yaml](./override-separate.yaml) ### `REDIS_CACHE_ENDPOINT` @@ -60,7 +60,7 @@ data: REDIS_STORE_ENDPOINT: "" ``` -Optionally, if your external Redis instances do not required authentication, you may use a [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) +Optionally, if your external Redis instances do not required authentication, you may use a [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/). Learn more about [how to reference ConfigMap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data). ```yaml apiVersion: v1 diff --git a/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml b/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml deleted file mode 100644 index b24ef962..00000000 --- a/charts/sourcegraph/examples/external-redis/override-separate-configmap.yaml +++ /dev/null @@ -1,86 +0,0 @@ -# Demonstrate using external redis instance(s) -# Disables deployment of the internal `redis-cache` and `redis-store` deployment - -frontend: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -repoUpdater: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -gitserver: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -searcher: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -symbols: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -worker: - env: - REDIS_CACHE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_CACHE_ENDPOINT - REDIS_STORE_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_STORE_ENDPOINT - -redisCache: - enabled: false - -redisStore: - enabled: false diff --git a/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml b/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml deleted file mode 100644 index 55f7126c..00000000 --- a/charts/sourcegraph/examples/external-redis/override-shared-configmap.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# Demonstrate using external redis instance(s) -# Disables deployment of the internal `redis-cache` and `redis-store` deployment - -frontend: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -repoUpdater: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -gitserver: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -searcher: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -symbols: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -worker: - env: - REDIS_ENDPOINT: - valueFrom: - configMapKeyRef: # Pre-existing configmap, not created by this chart - name: sourcegraph-external-redis-credentials - key: REDIS_ENDPOINT - -redisCache: - enabled: false - -redisStore: - enabled: false