Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: DENA-828 - bases for k6-operator #356

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions k6-operator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DEFAULT_GOAL := get-upstream

CHART_VERSION=3.8.0
APP_VERSION=0.0.16


.PHONY: get-upstream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this repo, we usually call upstream to the files/manifests that we pull unchanged, so I don't like calling it upstream here, since the produced manifests have already been templated by our values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would be the preference? gen-manifests or something similar?

get-upstream:
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm template k6-operator --namespace dev-enablement -f values.yaml grafana/k6-operator --version $(CHART_VERSION) > /tmp/k6-operator.yaml

yq 'select(.kind=="CustomResourceDefinition" and .metadata.name=="k6s.k6.io")' /tmp/k6-operator.yaml > cluster/upstream/k6.yaml
yq 'select(.kind=="CustomResourceDefinition" and .metadata.name=="privateloadzones.k6.io")' /tmp/k6-operator.yaml > cluster/upstream/plz.yaml
yq 'select(.kind=="CustomResourceDefinition" and .metadata.name=="testruns.k6.io")' /tmp/k6-operator.yaml > cluster/upstream/testrun.yaml
yq 'select(.kind=="ClusterRole")' /tmp/k6-operator.yaml > cluster/upstream/clusterRole.yaml
yq 'select(.kind=="ClusterRoleBinding")' /tmp/k6-operator.yaml > cluster/upstream/clusterRoleBinding.yaml

yq 'select(.kind=="ServiceAccount")' /tmp/k6-operator.yaml > upstream/controller/serviceaccount.yaml
yq 'select(.kind=="Role")' /tmp/k6-operator.yaml > upstream/controller/role.yaml
yq 'select(.kind=="RoleBinding")' /tmp/k6-operator.yaml > upstream/controller/roleBinding.yaml
yq 'select(.kind=="Service")' /tmp/k6-operator.yaml > upstream/controller/service.yaml
yq 'select(.kind=="Deployment")' /tmp/k6-operator.yaml > upstream/controller/deployment.yaml
8 changes: 8 additions & 0 deletions k6-operator/cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- upstream/k6.yaml
- upstream/plz.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz is not a well known acronym, I'd keep the full name of the resource

- upstream/testrun.yaml
- upstream/clusterRole.yaml
- upstream/clusterRoleBinding.yaml
241 changes: 241 additions & 0 deletions k6-operator/cluster/upstream/clusterRole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# Source: k6-operator/templates/clusterRole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: k6-operator-manager-role
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite a powerful role, including reading all secrets, and full control over all the cluster deployments. Ideally we'll have this be a "role" instead of a "clusterrole" and bind it to opt-in namespaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the ClusterRole that comes out-of-the-box. is the suggestion to move this to the controller package and transform to role and for now deploy to dev-enablement?

are there attributes between ClusterRole and Role transferable? wondering if it is a matter of just location and replacing values for kind and adding .metadata.namespace

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes to everything xD. I think they should be pretty transferable, iirc the only difference is that clusterrole affects to the whole cluster, while the role only affects the namespace where it's deployed. However sometimes the software verifies that it has superpowers and refuses to run if it doesn't, so it may not work

labels:
app.kubernetes.io/component: controller
helm.sh/chart: k6-operator-3.8.0
app.kubernetes.io/name: k6-operator
app.kubernetes.io/instance: k6-operator
app.kubernetes.io/version: "0.0.16"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: k6-operator
annotations:
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- update
- apiGroups:
- ""
resources:
- pods
- pods/log
verbs:
- get
- list
- watch
- apiGroups:
- k6.io
resources:
- k6s
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- k6.io
resources:
- k6s/finalizers
- k6s/status
verbs:
- get
- patch
- update
- apiGroups:
- k6.io
resources:
- privateloadzones
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- k6.io
resources:
- privateloadzones/finalizers
verbs:
- get
- patch
- update
- apiGroups:
- k6.io
resources:
- privateloadzones/status
verbs:
- get
- patch
- update
- apiGroups:
- k6.io
resources:
- testruns
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- k6.io
resources:
- testruns/finalizers
- testruns/status
verbs:
- get
- patch
- update
---
# Source: k6-operator/templates/clusterRole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: k6-operator-metrics-reader
labels:
helm.sh/chart: k6-operator-3.8.0
app.kubernetes.io/name: k6-operator
app.kubernetes.io/instance: k6-operator
app.kubernetes.io/version: "0.0.16"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: k6-operator
annotations:
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
---
# Source: k6-operator/templates/clusterRole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: k6-operator-proxy-role
labels:
helm.sh/chart: k6-operator-3.8.0
app.kubernetes.io/name: k6-operator
app.kubernetes.io/instance: k6-operator
app.kubernetes.io/version: "0.0.16"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: k6-operator
annotations:
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
---
# Source: k6-operator/templates/clusterRole.yaml
# permissions for end users to edit privateloadzones.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privateloadzone-editor-role
rules:
- apiGroups:
- k6.io
resources:
- privateloadzones
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- k6.io
resources:
- privateloadzones/status
verbs:
- get
---
# Source: k6-operator/templates/clusterRole.yaml
# permissions for end users to view privateloadzones.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privateloadzone-viewer-role
rules:
- apiGroups:
- k6.io
resources:
- privateloadzones
verbs:
- get
- list
- watch
- apiGroups:
- k6.io
resources:
- privateloadzones/status
verbs:
- get
38 changes: 38 additions & 0 deletions k6-operator/cluster/upstream/clusterRoleBinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Source: k6-operator/templates/clusterRoleBinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: k6-operator-manager-rolebinding
labels:
app.kubernetes.io/component: controller
helm.sh/chart: k6-operator-3.8.0
app.kubernetes.io/name: k6-operator
app.kubernetes.io/instance: k6-operator
app.kubernetes.io/version: "0.0.16"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: k6-operator
annotations:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: k6-operator-manager-role
subjects:
- kind: ServiceAccount
name: k6-operator-controller
namespace: dev-enablement
---
# Source: k6-operator/templates/clusterRoleBinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: k6-operator-proxy-rolebinding
labels:
annotations:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: k6-operator-proxy-role
subjects:
- kind: ServiceAccount
name: k6-operator-controller
namespace: dev-enablement
Loading
Loading