Skip to content

Commit

Permalink
applied suggested changes from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
lynx-coding committed Oct 26, 2023
1 parent 576c21a commit 05bfb15
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
```yaml
...
data:
index.html: |-
<h1>{{ .headline }}</h1>
secret-config: |-
key1={{ .secret1 }}
key2={{ .secret2 }}
...
```

Expand All @@ -29,7 +30,8 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
```yaml
...
data:
secret-headline: dmFsdWVGcm9tU2VjcmV0
secret1: dmFsdWVGcm9tU2VjcmV0
secret2: Mm5kVmFsdWVGcm9tU2VjcmV0
...
```

Expand All @@ -41,12 +43,6 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
image: ghcr.io/spreadshirt/k8s-multi-secret-to-file:latest
imagePullPolicy: Always
name: secret-init
volumeMounts:
- mountPath: /etc/rendered
name: init-share
- mountPath: /etc/templates/index.html
name: configmap
subPath: index.html
...
```

Expand All @@ -55,11 +51,16 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
```yaml
...
- env:
- name: SECRET_headline
- name: SECRET_secret1
valueFrom:
secretKeyRef:
name: apache-demo
key: secret-headline
key: secret1
- name: SECRET_secret2
valueFrom:
secretKeyRef:
name: apache-demo
key: secret2
...
```

Expand All @@ -83,9 +84,9 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
volumeMounts:
- mountPath: /etc/rendered
name: init-share
- mountPath: /etc/templates/index.html
- mountPath: /etc/templates/path/to/secret/config
name: configmap
subPath: index.html
subPath: secret-config
...
```

Expand All @@ -96,15 +97,16 @@ A working example can be found in `examples/k8s`. The files inside manifests dir
```yaml
...
volumeMounts:
- mountPath: /var/www/html/index.html
- mountPath: /path/to/secret/config
name: init-share
subPath: index.html
subPath: path/to/secret/config
...
```

8. deploy the application and check the rendered file inside the application container

```sh
$ kubectl exec <POD_NAME> -c apache -- cat /var/www/html/index.html
<h1>valueFromSecret</h1>
$ kubectl exec apache-demo-8479b98dd4-82jnn -c apache -- cat /path/to/secret/config
key1=valueFromSecret
key2=2ndValueFromSecret
```
5 changes: 3 additions & 2 deletions examples/k8s/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ kind: ConfigMap
metadata:
name: apache-demo-cfg
data:
index.html: |-
<h1>{{ .headline }}</h1>
secret-config: |-
key1={{ .secret1 }}
key2={{ .secret2 }}
19 changes: 12 additions & 7 deletions examples/k8s/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,34 @@ spec:
spec:
initContainers:
- env:
- name: SECRET_headline
- name: SECRET_secret1
valueFrom:
secretKeyRef:
name: apache-demo
key: secret-headline
key: secret1
- name: SECRET_secret2
valueFrom:
secretKeyRef:
name: apache-demo
key: secret2
image: ghcr.io/spreadshirt/k8s-multi-secret-to-file:latest
imagePullPolicy: Always
name: secret-init
volumeMounts:
- mountPath: /etc/rendered
name: init-share
- mountPath: /etc/templates/index.html
- mountPath: /etc/templates/path/to/secret/config
name: configmap
subPath: index.html
subPath: secret-config
containers:
- name: apache
image: php:8-apache
ports:
- containerPort: 80
volumeMounts:
- mountPath: /var/www/html/index.html
name: init-share
subPath: index.html
- mountPath: /path/to/secret/config
name: init-share
subPath: path/to/secret/config
volumes:
- emptyDir: { }
name: init-share
Expand Down
3 changes: 2 additions & 1 deletion examples/k8s/secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ metadata:
name: apache-demo
namespace: default
data:
secret-headline: dmFsdWVGcm9tU2VjcmV0
secret1: dmFsdWVGcm9tU2VjcmV0
secret2: Mm5kVmFsdWVGcm9tU2VjcmV0

0 comments on commit 05bfb15

Please sign in to comment.