Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 0b2caa7

Browse files
committed
Restrict SealedSecrets RoleBinding to ServiceAccount
The original work by @bartsmykla had the unfortunate effect of granting CREATE / GET and UPDATE to every Deployment in the openfaas-fn namespace including user functions. This commit ties that down to just functions which have a specific ServiceAccount set of sealedsecrets-importer-rw. Tested on DOKS with a sample user function which worked before and got access denied after. Signed-off-by: Alex Ellis <alexellis2@gmail.com>
1 parent 073af82 commit 0b2caa7

3 files changed

Lines changed: 39 additions & 22 deletions

File tree

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,14 @@ kubeseal --fetch-cert > pub-cert.pem
669669

670670
You will need to distribute or share pub-cert.pem so that people can use this with the OpenFaaS CLI `faas-cli cloud seal` command to seal secrets.
671671

672+
* Patch the service account for the `import-secrets` function
673+
674+
This `ServiceAccount` needs to be patched in place so that the function can perform create / get and update on the SealedSecret CRD:
675+
676+
```sh
677+
kubectl patch -n openfaas-fn deploy import-secrets -p '{"spec":{"template":{"spec":{"serviceAccountName":"sealedsecrets-importer-rw"}}}}'
678+
```
679+
672680
### Custom templates
673681

674682
You can add your own custom templates by re-deploying the `git-tar` function in `stack.yml`.

yaml/core/import-secrets-role.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

yaml/core/rbac-import-secrets.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
kind: ClusterRole
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: sealedsecrets-importer
5+
rules:
6+
- apiGroups: ["bitnami.com"]
7+
resources: ["sealedsecrets"]
8+
verbs: ["get", "create", "update"]
9+
---
10+
kind: RoleBinding
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
metadata:
13+
name: manage-sealed-secrets
14+
namespace: openfaas-fn
15+
subjects:
16+
- kind: ServiceAccount
17+
name: sealedsecrets-importer-rw
18+
namespace: openfaas-fn
19+
roleRef:
20+
kind: ClusterRole
21+
name: sealedsecrets-importer
22+
apiGroup: rbac.authorization.k8s.io
23+
---
24+
apiVersion: v1
25+
kind: ServiceAccount
26+
metadata:
27+
name: sealedsecrets-importer-rw
28+
namespace: openfaas-fn
29+
labels:
30+
app: openfaas
31+
#kubectl patch -n openfaas-fn deploy import-secrets -p '{"spec":{"template":{"spec":{"serviceAccountName":"sealedsecrets-importer-rw"}}}}'

0 commit comments

Comments
 (0)