Skip to content

Commit 5b501f3

Browse files
authored
Merge pull request #31 from stakater/enhancement/26
Enhancement/26
2 parents 4efc790 + 4d46b5b commit 5b501f3

File tree

7 files changed

+163
-198
lines changed

7 files changed

+163
-198
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For now the ProxyInjector only supports [Keycloak Gatekeeper](https://github.com
2525
The following quickstart let's you set up ProxyInjector:
2626

2727
1. Add configuration to the ProxyInjector
28-
The following arguments can either be added to the proxy injector `config.yaml` in the ConfigMap for centralized configuration,
28+
The following arguments can either be added to the proxy injector `config.yaml` in the ConfigMap/Secret for centralized configuration,
2929
or as annotations on the individual target deployments with a `authproxy.stakater.com/` prefix. In case of both,
3030
the deployment annotation values will override the central configuration.
3131

@@ -40,6 +40,8 @@ The following quickstart let's you set up ProxyInjector:
4040

4141
The rest of the available options can be found at the [Keycloak Gatekeeper documentation](https://www.keycloak.org/docs/latest/securing_apps/index.html#configuration-options)
4242

43+
Note 1: See the section `Using Secrets` below if you do not want to use ConfigMap (because `client-id` and `client-secret` in plain text) and want to use Secrets to hide them.
44+
4345
2. Deploy the controller by running the following command:
4446

4547
For Kubernetes Cluster using kubectl
@@ -58,6 +60,41 @@ The rest of the available options can be found at the [Keycloak Gatekeeper docum
5860
The `authproxy.stakater.com/listen` annotation or the `listen` property in the ProxyInjector ConfigMap should
5961
specify where the proxy sidecar will listen for incoming requests, e.g. "0.0.0.0:80" i.e. local port 80
6062

63+
64+
### Using Secrets
65+
66+
To use secrets:
67+
68+
1. Open [values.yaml](https://github.com/stakater/ProxyInjector/blob/master/deployments/kubernetes/chart/proxyinjector/values.yaml) file by navigating to `deployments/kubernetes/chart/proxyinjector/`
69+
70+
2. Set `mount` equals to `"secret"` and pass the data in the data section at the bottom.
71+
72+
3. Run `helm template . > proxyinjector.yaml`
73+
74+
4. Deploy using the `Deploying` section below.
75+
76+
### Using ConfigMap
77+
78+
To pass user credentials/ API keys in secrets:
79+
80+
1. Open [values.yaml](https://github.com/stakater/ProxyInjector/blob/master/deployments/kubernetes/chart/proxyinjector/values.yaml) file by navigating to `deployments/kubernetes/chart/proxyinjector/`
81+
82+
2. Set `mount` equals to `"configmap"` and pass the data in the data section at the bottom.
83+
84+
3. Run `helm template . > proxyinjector.yaml`
85+
86+
4. Deploy using the `Deploying` section below.
87+
88+
### Deploying
89+
90+
You can deploy the controller in the namespace you want to monitor by running the following kubectl command:
91+
92+
```bash
93+
kubectl apply -f proxyinjector.yaml -n <namespace>
94+
```
95+
96+
*Note*: Before applying `proxyinjector.yaml`, You need to modify the namespace in the `RoleBinding` subjects section to the namespace you want to apply RBAC to.
97+
6198
## Help
6299

63100
### Documentation

deployments/kubernetes/chart/proxyinjector/templates/configmap.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if eq .Values.proxyinjector.mount "configmap" }}
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:
@@ -11,5 +12,5 @@ metadata:
1112
heritage: {{ .Release.Service | quote }}
1213
name: {{ template "proxyinjector-name" . }}
1314
data:
14-
config.yml:
15-
{{ toYaml .Values.proxyinjector.proxyconfig | indent 4 }}
15+
{{ toYaml .Values.proxyinjector.data | indent 2 }}
16+
{{- end }}

deployments/kubernetes/chart/proxyinjector/templates/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ spec:
3939
name: config-volume
4040
serviceAccountName: {{ template "proxyinjector-name" . }}
4141
volumes:
42+
{{- if eq .Values.proxyinjector.mount "secret" }}
43+
- secret:
44+
secretName: {{ template "proxyinjector-name" . }}
45+
{{ else }}
4246
- configMap:
4347
name: {{ template "proxyinjector-name" . }}
48+
{{- end }}
4449
name: config-volume
4550

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if eq .Values.proxyinjector.mount "secret" }}
2+
apiVersion: v1
3+
kind: Secret
4+
type: Opaque
5+
metadata:
6+
labels:
7+
app: {{ template "proxyinjector-name" . }}
8+
version: {{ .Chart.Version }}
9+
group: {{ .Values.proxyinjector.labels.group }}
10+
provider: {{ .Values.proxyinjector.labels.provider }}
11+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
12+
release: {{ .Release.Name | quote }}
13+
heritage: {{ .Release.Service | quote }}
14+
name: {{ template "proxyinjector-name" . }}
15+
data:
16+
{{- range $key, $value := .Values.proxyinjector.data }}
17+
{{ $key }}: {{ $value | b64enc }}
18+
{{- end }}
19+
{{- end }}

deployments/kubernetes/chart/proxyinjector/values.yaml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ kubernetes:
22
host: https://kubernetes.default
33

44
proxyinjector:
5+
mount: "configmap"
56
tolerations: {}
67
labels:
78
provider: stakater
@@ -13,18 +14,20 @@ proxyinjector:
1314
pullPolicy: IfNotPresent
1415
watchGlobally: true
1516
configFilePath: /etc/ProxyInjector
16-
proxyconfig: |-
17-
gatekeeper-image : "keycloak/keycloak-gatekeeper:6.0.1"
18-
enable-default-deny: true
19-
secure-cookie: false
20-
verbose: true
21-
enable-logging: true
22-
cors-origins:
23-
- '*'
24-
cors-methods:
25-
- GET
26-
- POST
27-
resources:
28-
- uri: '/*'
29-
scopes:
30-
- 'good-service'
17+
data:
18+
config.yml: |-
19+
proxyconfig:
20+
gatekeeper-image: "keycloak/keycloak-gatekeeper:6.0.1"
21+
enable-default-deny: true
22+
secure-cookie: false
23+
verbose: true
24+
enable-logging: true
25+
cors-origins:
26+
- '*'
27+
cors-methods:
28+
- GET
29+
- POST
30+
resources:
31+
- uri: '/*'
32+
scopes:
33+
- 'good-service'

0 commit comments

Comments
 (0)