Skip to content

feat: [TKC-3299] add namespaces rbac #997

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

Merged
merged 16 commits into from
Mar 12, 2025
Merged
3 changes: 3 additions & 0 deletions charts/testkube-api/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
annotations: {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- if .Values.next.enabled }}
enable-cron-jobs: "{{ .Values.next.cronJobs.enabled }}"
{{- end }}
executors.json: |-
{{ include "testkube-api.executors" . | indent 4 }}
job-container-template.yml: |-
Expand Down
2 changes: 2 additions & 0 deletions charts/testkube-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ spec:
value: "{{ .Values.next.gitops.namePatterns.kubernetes }}"
- name: DISABLE_DEFAULT_AGENT
value: "{{ not .Values.next.legacyAgent.enabled }}"
- name: ENABLE_CRON_JOBS
value: "{{ .Values.next.cronJobs.enabled }}"
{{- end }}
image: {{ include "testkube-api.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand Down
7 changes: 7 additions & 0 deletions charts/testkube-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ next:
## Should it enable controller API
enabled: true


## Configure cron jobs in this installation.
# - tkcagnt_*** - Super Agent
cronJobs:
## Should it manage cron jobs
enabled: false

## Testkube API Deployment parameters
## Running Testkube in Agent mode
cloud:
Expand Down
1 change: 1 addition & 0 deletions charts/testkube-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A Helm chart for the testkube-operator (installs needed CRDs only for now)
| affinity | object | `{}` | |
| apiFullname | string | `"testkube-api-server"` | |
| apiPort | int | `8088` | |
| agentCronJobs | bool | `true` | |
| useArgoCDSync| bool | `false` | |
| extraEnvVars | list | `[]` | |
| fullnameOverride | string | `""` | |
Expand Down
4 changes: 4 additions & 0 deletions charts/testkube-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ spec:
- name: APISERVER_PURGE_EXECUTIONS
value: "true"
{{- end }}
{{- if .Values.agentCronJobs }}
- name: APISERVER_CONFIG
value: {{ .Values.apiFullname }}
{{- end }}
ports:
- containerPort: {{ .Values.webhookServerPort }}
name: webhook-server
Expand Down
24 changes: 24 additions & 0 deletions charts/testkube-operator/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,28 @@ rules:
- update
{{- end }}

---

apiVersion: {{ include "global.capabilities.rbac.apiVersion" . }}
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-namespaces-role
labels:
{{- if .Values.global.labels }}
{{- include "global.tplvalues.render" ( dict "value" .Values.global.labels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.global.annotations }}
annotations: {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }}
{{- end }}
namespace: {{ include "testkube-operator.namespace" . }}
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch

{{- end -}}
24 changes: 24 additions & 0 deletions charts/testkube-operator/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,28 @@ subjects:
name: {{ include "testkube-operator.webhook.serviceAccountName" . }}
namespace: {{ include "testkube-operator.namespace" . }}
{{- end }}

---

apiVersion: {{ include "global.capabilities.rbac.apiVersion" . }}
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-namespaces-rolebinding
labels:
{{- if .Values.global.labels }}
{{- include "global.tplvalues.render" ( dict "value" .Values.global.labels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.global.annotations }}
annotations: {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }}
{{- end }}
namespace: {{ include "testkube-operator.namespace" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-namespaces-role
subjects:
- kind: ServiceAccount
name: {{ include "testkube-operator.serviceAccountName" . }}
namespace: {{ include "testkube-operator.namespace" . }}

{{- end -}}
2 changes: 2 additions & 0 deletions charts/testkube-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ healthcheckPort: 8081
useArgoCDSync: false
# purge executions on CRD deletion
purgeExecutions: false
# agent cron jobs for scheduling test, suites, workflows
agentCronJobs: false

## Service Account parameters
serviceAccount:
Expand Down
1 change: 1 addition & 0 deletions charts/testkube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ kubectl label --overwrite crds scripts.tests.testkube.io app.kubernetes.io/manag
| testkube-operator.apiFullname | string | `"testkube-api-server"` | Testkube API full name |
| testkube-operator.apiPort | int | `8088` | Testkube API port |
| testkube-operator.cronJobTemplate | string | `""` | |
| testkube-operator.agentCronJobs | bool | `true` | Agent cron jobs for scheduling test, suites, workflows |
| testkube-operator.enabled | bool | `true` | |
| testkube-operator.extraEnvVars | list | `[]` | Extra environment variables to be set on deployment |
| testkube-operator.fullnameOverride | string | `"testkube-operator"` | Testkube Operator fullname override |
Expand Down
8 changes: 8 additions & 0 deletions charts/testkube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ testkube-api:
## Should it be enabled
enabled: true

## Configure cron jobs in this installation.
# - tkcagnt_*** - Super Agent
cronJobs:
## Should it manage cron jobs
enabled: false

# ref: https://cloud.google.com/kubernetes-engine/docs/how-to/prepare-arm-workloads-for-deployment#node-affinity-multi-arch-arm
# -- Tolerations to schedule a workload to nodes with any architecture type. Required for deployment to GKE cluster.
tolerations: []
Expand Down Expand Up @@ -1042,6 +1048,8 @@ testkube-operator:
useArgoCDSync: false
# -- Purge executions on CRD deletion
purgeExecutions: false
# -- Agent cron jobs for scheduling test, suites, workflows
agentCronJobs: false

# Service Account parameters
serviceAccount:
Expand Down