Skip to content

Commit 1584f1b

Browse files
committed
Keep roles needed for running tests out of deployment manifest
1 parent 727f89e commit 1584f1b

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ endif
5050
endif
5151
MANIFESTPATHDEPLOYMENT := manifests/arango-deployment$(MANIFESTSUFFIX).yaml
5252
MANIFESTPATHSTORAGE := manifests/arango-storage$(MANIFESTSUFFIX).yaml
53+
MANIFESTPATHTEST := manifests/arango-test$(MANIFESTSUFFIX).yaml
5354
ifndef DEPLOYMENTNAMESPACE
5455
DEPLOYMENTNAMESPACE := default
5556
endif
@@ -251,6 +252,7 @@ endif
251252
kubectl apply -f manifests/crd.yaml
252253
kubectl apply -f $(MANIFESTPATHSTORAGE)
253254
kubectl apply -f $(MANIFESTPATHDEPLOYMENT)
255+
kubectl apply -f $(MANIFESTPATHTEST)
254256
$(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE)
255257
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ENTERPRISEIMAGE)" $(TESTTIMEOUT) $(TESTLENGTHOPTIONS)
256258
ifneq ($(DEPLOYMENTNAMESPACE), default)
@@ -312,6 +314,7 @@ minikube-start:
312314

313315
.PHONY: delete-operator
314316
delete-operator:
317+
kubectl delete -f $(MANIFESTPATHTEST) --ignore-not-found
315318
kubectl delete -f $(MANIFESTPATHDEPLOYMENT) --ignore-not-found
316319
kubectl delete -f $(MANIFESTPATHSTORAGE) --ignore-not-found
317320

@@ -320,4 +323,5 @@ redeploy-operator: delete-operator manifests
320323
kubectl apply -f manifests/crd.yaml
321324
kubectl apply -f $(MANIFESTPATHSTORAGE)
322325
kubectl apply -f $(MANIFESTPATHDEPLOYMENT)
326+
kubectl apply -f $(MANIFESTPATHTEST)
323327
kubectl get pods

manifests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
arango-deployment-dev.yaml
2-
arango-storage-dev.yaml
2+
arango-storage-dev.yaml
3+
arango-test-dev.yaml

manifests/templates/deployment/rbac.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ rules:
88
- apiGroups: ["database.arangodb.com"]
99
resources: ["arangodeployments"]
1010
verbs: ["*"]
11-
- apiGroups: [""]
12-
resources: ["nodes"]
13-
verbs: ["*"]
1411

1512
---
1613

manifests/templates/test/rbac.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .RBAC -}}
2+
3+
## Cluster role granting access to resources needed by the integration tests.
4+
apiVersion: rbac.authorization.k8s.io/v1beta1
5+
kind: ClusterRole
6+
metadata:
7+
name: {{ .Test.RoleName }}
8+
rules:
9+
- apiGroups: [""]
10+
resources: ["nodes"]
11+
verbs: ["list"]
12+
13+
---
14+
15+
## Bind the cluster role granting access to ArangoLocalStorage resources
16+
## to the default service account of the configured namespace.
17+
apiVersion: rbac.authorization.k8s.io/v1beta1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: {{ .Test.RoleBindingName }}
21+
namespace: {{ .Test.Namespace }}
22+
roleRef:
23+
apiGroup: rbac.authorization.k8s.io
24+
kind: ClusterRole
25+
name: {{ .Test.RoleName }}
26+
subjects:
27+
- kind: ServiceAccount
28+
name: {{ .Test.ServiceAccountName }}
29+
namespace: {{ .Test.Namespace }}
30+
31+
{{- end -}}

tools/manifests/manifest_builder.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ var (
5757
"rbac.yaml",
5858
"deployment.yaml",
5959
}
60+
testTemplateNames = []string{
61+
"rbac.yaml",
62+
}
6063
)
6164

6265
func init() {
@@ -79,6 +82,7 @@ type TemplateOptions struct {
7982
RBAC bool
8083
Deployment ResourceOptions
8184
Storage ResourceOptions
85+
Test CommonOptions
8286
}
8387

8488
type CommonOptions struct {
@@ -123,6 +127,7 @@ func main() {
123127
templateNameSet := map[string][]string{
124128
"deployment": deploymentTemplateNames,
125129
"storage": storageTemplateNames,
130+
"test": testTemplateNames,
126131
}
127132

128133
// Process templates
@@ -160,6 +165,12 @@ func main() {
160165
},
161166
OperatorDeploymentName: "arango-storage-operator",
162167
},
168+
Test: CommonOptions{
169+
Namespace: options.Namespace,
170+
RoleName: "arango-operator-test",
171+
RoleBindingName: "arango-operator-test",
172+
ServiceAccountName: "default",
173+
},
163174
}
164175
for group, templateNames := range templateNameSet {
165176
output := &bytes.Buffer{}

0 commit comments

Comments
 (0)