Skip to content

Commit

Permalink
Fix RBAC for kustomize
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Aug 18, 2020
1 parent 64a4aa7 commit 3482e97
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ Backlog (done):
- [x] Watch new namespaces and create new secrets
- [x] Update the ImagePullSecret list for the default ServiceAccount in each namespace
- [x] Add an exclude annotation for certain namespaces `alexellis.io/registry-creds.ignore`
- [x] Add Docker image for `x86_64`
- [x] Test and update kustomize

Todo:
- [ ] Use `apierrors.IsNotFound(err)` everywhere instead of assuming an error means not found
- [ ] Support alterations/updates to the primary `ClusterPullSecret`
- [ ] Add Docker image for `x86_64`
- [ ] Add multi-arch Docker image for `x86_64` and arm
- [ ] Add helm chart / kustomize
- [ ] Add helm chart
- [ ] Add one-liner with an arkade app - `arkade install registry-creds --username $USERNAME --password $PASSWORD`

## Installation
Expand All @@ -49,6 +50,8 @@ make install
make run
```

> Note, you can also run `make install deploy` to try running in-cluster.
## Usage

To use this operator create a `ClusterPullSecret` CustomResource and apply it to your cluster.
Expand Down
18 changes: 18 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ rules:
- get
- patch
- update
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- serviceaccounts/status
verbs:
- get
- patch
- update
- apiGroups:
- ops.alexellis.io
resources:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: manager-rolebinding
name: registry-creds-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: manager-role
name: registry-creds-role
subjects:
- kind: ServiceAccount
name: default
Expand Down
3 changes: 3 additions & 0 deletions controllers/clusterpullsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type ClusterPullSecretReconciler struct {
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=secrets/status,verbs=get;update;patch

// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;update;patch
// +kubebuilder:rbac:groups=core,resources=serviceaccounts/status,verbs=get;update;patch

func (r *ClusterPullSecretReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
_ = r.Log.WithValues("clusterpullsecret", req.NamespacedName)
Expand Down

0 comments on commit 3482e97

Please sign in to comment.