Skip to content

Commit 6a562eb

Browse files
caroltykdcs3spp
andauthored
DX-1282 Load secret data to environment variables (#4493)
* Update tyk-stack-chart with example for how to load secret data to environment variables --------- Co-authored-by: dcs3spp <dcs3spp@users.noreply.github.com>
1 parent 8dfbdf5 commit 6a562eb

File tree

4 files changed

+121
-24
lines changed

4 files changed

+121
-24
lines changed

tyk-docs/content/product-stack/tyk-charts/tyk-control-plane-chart.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ helm show values tyk-helm/tyk-control-plane --devel > values.yaml
100100
You can update any value in your local `values.yaml` file and use `-f [filename]` flag to override default values during installation.
101101
Alternatively, you can use `--set` flag to set it in Tyk installation. See [Using Helm](https://helm.sh/docs/intro/using_helm/) for examples.
102102

103-
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}). Additionally, should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
103+
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}).
104+
105+
### Setting Environment Variables
106+
Should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
104107

105108
Example of setting extra environment variable to gateway:
106109
```yaml
@@ -111,6 +114,32 @@ tyk-gateway:
111114
value: debug
112115
```
113116
117+
An example is listed below for setting extra [environment variable using ConfigMap data](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data), using gateway:
118+
```yaml
119+
tyk-gateway:
120+
gateway:
121+
extraEnvs:
122+
- name: CONFIG_USERNAME
123+
valueFrom:
124+
configMapKeyRef:
125+
name: backend-user
126+
key: backend-username
127+
```
128+
129+
An example is listed below for setting extra [environment variable using secret data](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data), using gateway:
130+
```yaml
131+
tyk-gateway:
132+
gateway:
133+
extraEnvs:
134+
- name: SECRET_USERNAME
135+
valueFrom:
136+
secretKeyRef:
137+
name: backend-user
138+
key: backend-username
139+
```
140+
141+
In the above example, an extra environment variable `SECRET_USERNAME` will be added to the Gateway container, with a value of `backend-username` associated with the secret `backend-user`. It is useful if you want to access secret data from [Tyk Gateway configuration file (tyk.conf) or API definitions]({{<ref "tyk-configuration-reference/kv-store#how-to-access-the-externally-stored-data">}}).
142+
114143
### Set Redis Connection Details (Required)
115144

116145
Tyk uses Redis for distributed rate-limiting and token storage. You may use the [Bitnami chart](https://github.com/bitnami/charts/tree/main/bitnami/redis) or Tyk's [simple-redis](https://artifacthub.io/packages/helm/tyk-helm/simple-redis) to install chart for POC purpose.

tyk-docs/content/product-stack/tyk-charts/tyk-data-plane-chart.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ helm show values tyk-helm/tyk-data-plane > values.yaml
8989
You can update any value in your local `values.yaml` file and use `-f [filename]` flag to override default values during installation.
9090
Alternatively, you can use `--set` flag to set it in Tyk installation.
9191

92-
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}). Additionally, should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
92+
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}).
93+
94+
95+
### Setting Environment Variables
96+
Should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
9397

9498
Example of setting extra environment variable to gateway:
9599
```yaml
@@ -100,6 +104,32 @@ tyk-gateway:
100104
value: debug
101105
```
102106
107+
An example is listed below for setting extra [environment variable using ConfigMap data](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data), using gateway:
108+
```yaml
109+
tyk-gateway:
110+
gateway:
111+
extraEnvs:
112+
- name: CONFIG_USERNAME
113+
valueFrom:
114+
configMapKeyRef:
115+
name: backend-user
116+
key: backend-username
117+
```
118+
119+
An example is listed below for setting extra [environment variable using secret data](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data), using gateway:
120+
```yaml
121+
tyk-gateway:
122+
gateway:
123+
extraEnvs:
124+
- name: SECRET_USERNAME
125+
valueFrom:
126+
secretKeyRef:
127+
name: backend-user
128+
key: backend-username
129+
```
130+
131+
In the above example, an extra environment variable `SECRET_USERNAME` will be added to the Gateway container, with a value of `backend-username` associated with the secret `backend-user`. It is useful if you want to access secret data from [Tyk Gateway configuration file (tyk.conf) or API definitions]({{<ref "tyk-configuration-reference/kv-store#how-to-access-the-externally-stored-data">}}).
132+
103133
### Set Redis Connection Details (Required)
104134

105135
Tyk uses Redis for distributed rate-limiting and token storage. You may use the [Bitnami chart](https://github.com/bitnami/charts/tree/main/bitnami/redis) to install or Tyk's `simple-redis` chart for POC purpose.
@@ -356,16 +386,6 @@ Configure the gateways to load APIs with specific tags only by enabling `tyk-gat
356386
tags: "edge,dc1,product"
357387
```
358388

359-
#### Setting Environment Variable
360-
361-
You can add environment variables for Tyk Gateway under `extraEnvs`. This can be used to override any default settings in the chart, e.g.
362-
363-
```yaml
364-
extraEnvs:
365-
- name: TYK_GW_HASHKEYS
366-
value: "false"
367-
```
368-
369389
For further details for configuring Tyk Gateway, please consult the [Tyk Gateway Configuration Options]({{<ref "tyk-oss-gateway/configuration">}}) guide.
370390

371391
### Pump Configurations

tyk-docs/content/product-stack/tyk-charts/tyk-oss-chart.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ helm show values tyk-helm/tyk-oss > values.yaml
7777
You can update any value in your local `values.yaml` file and use `-f [filename]` flag to override default values during installation.
7878
Alternatively, you can use `--set` flag to set it in Tyk installation.
7979

80-
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}). Additionally, should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
80+
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}).
81+
82+
### Setting Environment Variables
83+
Should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
8184

8285
Example of setting extra environment variable to gateway:
8386
```yaml
@@ -88,6 +91,32 @@ tyk-gateway:
8891
value: debug
8992
```
9093
94+
An example is listed below for setting extra [environment variable using ConfigMap data](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data), using gateway:
95+
```yaml
96+
tyk-gateway:
97+
gateway:
98+
extraEnvs:
99+
- name: CONFIG_USERNAME
100+
valueFrom:
101+
configMapKeyRef:
102+
name: backend-user
103+
key: backend-username
104+
```
105+
106+
An example is listed below for setting extra [environment variable using secret data](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data), using gateway:
107+
```yaml
108+
tyk-gateway:
109+
gateway:
110+
extraEnvs:
111+
- name: SECRET_USERNAME
112+
valueFrom:
113+
secretKeyRef:
114+
name: backend-user
115+
key: backend-username
116+
```
117+
118+
In the above example, an extra environment variable `SECRET_USERNAME` will be added to the Gateway container, with a value of `backend-username` associated with the secret `backend-user`. It is useful if you want to access secret data from [Tyk Gateway configuration file (tyk.conf) or API definitions]({{<ref "tyk-configuration-reference/kv-store#how-to-access-the-externally-stored-data">}}).
119+
91120
### Set Redis Connection Details (Required)
92121

93122
Tyk uses Redis for distributed rate-limiting and token storage. You may use the [Bitnami chart](https://github.com/bitnami/charts/tree/main/bitnami/redis) to install or Tyk's `simple-redis` chart for POC purpose.
@@ -320,16 +349,6 @@ You can configure persistent volume for APIs, Policies, and middlewares using `e
320349
mountPath: /mnt/tyk-gateway/middleware
321350
```
322351

323-
#### Setting Environment Variables
324-
325-
You can add environment variables for Tyk Gateway under `extraEnvs`. This can be used to override any default settings in the chart, e.g.
326-
327-
```yaml
328-
extraEnvs:
329-
- name: TYK_GW_HASHKEYS
330-
value: "false"
331-
```
332-
333352
For further details for configuring Tyk Gateway, consult the [Tyk Gateway Configuration Options]({{<ref "tyk-oss-gateway/configuration">}}) guide.
334353

335354
### Pump Configurations

tyk-docs/content/product-stack/tyk-charts/tyk-stack-chart.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ helm show values tyk-helm/tyk-stack > values.yaml
9494
You can update any value in your local `values.yaml` file and use `-f [filename]` flag to override default values during installation.
9595
Alternatively, you can use `--set` flag to set it in Tyk installation. See [Using Helm](https://helm.sh/docs/intro/using_helm/) for examples.
9696

97-
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}). Additionally, should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
97+
To configure Tyk components, users can utilize both config files and [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/). Notably, environment variables take precedence over config files. To maintain simplicity and consistency, the Tyk Helm Charts deploy components with an empty config file while setting container environment variables based on user-defined [values](https://helm.sh/docs/chart_best_practices/values/). This approach ensures seamless integration with Kubernetes practices, allowing for efficient management of configurations. For a comprehensive overview of available configurations, please refer to the [configuration documentation]({{<ref "tyk-environment-variables">}}).
98+
99+
### Setting Environment Variables
100+
Should any environment variables not be set by the Helm Chart, users can easily add them under the `extraEnvs` section within the charts for further customization. Values set under `extraEnvs` would take precedence over all configurations.
98101

99102
Example of setting extra environment variable to gateway:
100103
```yaml
@@ -105,6 +108,32 @@ tyk-gateway:
105108
value: debug
106109
```
107110
111+
An example is listed below for setting extra [environment variable using ConfigMap data](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data), using gateway:
112+
```yaml
113+
tyk-gateway:
114+
gateway:
115+
extraEnvs:
116+
- name: CONFIG_USERNAME
117+
valueFrom:
118+
configMapKeyRef:
119+
name: backend-user
120+
key: backend-username
121+
```
122+
123+
An example is listed below for setting extra [environment variable using secret data](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data), using gateway:
124+
```yaml
125+
tyk-gateway:
126+
gateway:
127+
extraEnvs:
128+
- name: SECRET_USERNAME
129+
valueFrom:
130+
secretKeyRef:
131+
name: backend-user
132+
key: backend-username
133+
```
134+
135+
In the above example, an extra environment variable `SECRET_USERNAME` will be added to the Gateway container, with a value of `backend-username` associated with the secret `backend-user`. It is useful if you want to access secret data from [Tyk Gateway configuration file (tyk.conf) or API definitions]({{<ref "tyk-configuration-reference/kv-store#how-to-access-the-externally-stored-data">}}).
136+
108137
### Set Redis Connection Details (Required)
109138

110139
Tyk uses Redis for distributed rate-limiting and token storage. You may use the Bitnami chart to install or Tyk's `simple-redis` chart for POC purpose.

0 commit comments

Comments
 (0)