Skip to content

Commit 492c4da

Browse files
committed
fix: add necessary configurations for permissions
1 parent 3db3f4b commit 492c4da

File tree

8 files changed

+81
-18
lines changed

8 files changed

+81
-18
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
55
# my.domain/instascale-1-bundle:$VERSION and my.domain/instascale-1-catalog:$VERSION.
6-
IMAGE_TAG_BASE ?= quay.io/project-codeflare/instascale
6+
IMAGE_TAG_BASE ?= quay.io/project-codeflare/instascale-controller
77

88
ENGINE ?= "podman"
99

@@ -16,7 +16,7 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
1616
endif
1717

1818
# Image URL to use all building/pushing image targets
19-
IMG ?= controller:latest
19+
IMG ?= latest
2020
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
2121
ENVTEST_K8S_VERSION = 1.23
2222

@@ -114,19 +114,23 @@ endif
114114
.PHONY: install
115115
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
116116
$(KUSTOMIZE) build config/default | kubectl apply -f -
117+
$(KUSTOMIZE) build config/configmap | kubectl apply -f -
117118

118119
.PHONY: uninstall
119120
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
120121
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
122+
$(KUSTOMIZE) build config/configmap | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
121123

122124
.PHONY: deploy
123125
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
124126
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
125127
$(KUSTOMIZE) build config/default | kubectl apply -f -
128+
$(KUSTOMIZE) build config/configmap | kubectl apply -f -
126129

127130
.PHONY: undeploy
128131
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
129132
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
133+
$(KUSTOMIZE) build config/configmap | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
130134

131135
## Location to install dependencies to
132136
LOCALBIN ?= $(shell pwd)/bin
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: instascale-config
5+
namespace: kube-system
6+
data:
7+
maxScaleoutAllowed: "15"

config/configmap/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- instascale_configmap.yaml

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
1212
kind: Kustomization
1313
images:
1414
- name: controller
15-
newName: controller
15+
newName: quay.io/project-codeflare/instascale-controller
1616
newTag: latest

config/rbac/instascale_configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: instascale-config
5+
namespace: kube-system
6+
data:
7+
maxScaleoutAllowed: "15"

config/rbac/role.yaml

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ metadata:
55
creationTimestamp: null
66
name: manager-role
77
rules:
8+
- apiGroups:
9+
- ""
10+
resourceNames:
11+
- instascale-config
12+
resources:
13+
- configmaps
14+
- nodes
15+
verbs:
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
23+
- apiGroups:
24+
- ""
25+
resourceNames:
26+
- instascale-ocm-secret
27+
resources:
28+
- secrets
29+
verbs:
30+
- get
31+
- apiGroups:
32+
- apps
33+
resources:
34+
- deployments
35+
verbs:
36+
- get
37+
- list
38+
- watch
839
- apiGroups:
940
- apps
1041
resources:
@@ -23,6 +54,26 @@ rules:
2354
- machineset/status
2455
verbs:
2556
- get
57+
- apiGroups:
58+
- config.openshift.io
59+
resources:
60+
- clusterversions
61+
verbs:
62+
- get
63+
- list
64+
- watch
65+
- apiGroups:
66+
- machine.openshift.io
67+
resources:
68+
- '*'
69+
verbs:
70+
- create
71+
- delete
72+
- get
73+
- list
74+
- patch
75+
- update
76+
- watch
2677
- apiGroups:
2778
- workload.codeflare.dev
2879
resources:
@@ -49,18 +100,3 @@ rules:
49100
- get
50101
- patch
51102
- update
52-
- apiGroups:
53-
- ""
54-
resourceNames:
55-
- instascale-ocm-secret
56-
resources:
57-
- secrets
58-
verbs:
59-
- get
60-
- apiGroups:
61-
- config.openshift.io
62-
resources:
63-
- clusterversions
64-
verbs:
65-
- get
66-
- update

controllers/appwrapper_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ const (
8484
// +kubebuilder:rbac:groups=apps,resources=machineset,verbs=get;list;watch;create;update;patch;delete
8585
// +kubebuilder:rbac:groups=apps,resources=machineset/status,verbs=get
8686

87+
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=list;watch;get
88+
// +kubebuilder:rbac:groups=machine.openshift.io,resources=*,verbs=list;watch;get;create;update;delete;patch
89+
// +kubebuilder:rbac:groups=config.openshift.io,resources=clusterversions,verbs=get;list;watch
90+
8791
// Reconcile is part of the main kubernetes reconciliation loop which aims to
8892
// move the current state of the cluster closer to the desired state.
8993
// TODO(user): Modify the Reconcile function to compare the state specified by

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ var (
4949
setupLog = ctrl.Log.WithName("setup")
5050
)
5151

52+
// +kubebuilder:rbac:groups="",resources=secrets,resourceNames=instascale-ocm-secret,verbs=get
53+
// +kubebuilder:rbac:groups="",resources=nodes;configmaps,resourceNames=instascale-config,verbs=list;watch;get;create;update;delete;patch
54+
5255
func init() {
5356
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5457
utilruntime.Must(configv1.Install(scheme))

0 commit comments

Comments
 (0)