diff --git a/charts/api/CHANGELOG.md b/charts/api/CHANGELOG.md index 0c9066a..6f6fbba 100644 --- a/charts/api/CHANGELOG.md +++ b/charts/api/CHANGELOG.md @@ -2,6 +2,9 @@ This chart does not yet follow SemVer. +## 0.36.1 +- Restrict the API queue ServiceAccount to the namespaces it uses + ## 0.36.0 - Populates env var `ELASTICSEARCH_HOST` - Removes env vars diff --git a/charts/api/Chart.yaml b/charts/api/Chart.yaml index 24dc13f..240d654 100644 --- a/charts/api/Chart.yaml +++ b/charts/api/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart for the WBStack API name: api -version: 0.36.0 +version: 0.36.1 home: https://github.com/wbstack maintainers: - name: WBstack diff --git a/charts/api/templates/deployment-queue.yaml b/charts/api/templates/deployment-queue.yaml index 2e4b635..822f99a 100644 --- a/charts/api/templates/deployment-queue.yaml +++ b/charts/api/templates/deployment-queue.yaml @@ -239,6 +239,8 @@ spec: key: oauth-private.key - name: API_JOB_NAMESPACE value: {{ $.Values.queue.apiJobNamespace }} + - name: WBSTACK_QS_JOB_NAMESPACE + value: {{ $.Values.queue.qsJobNamespace }} {{- if $.Values.app.gce.serviceAccountSecret }} volumeMounts: - name: "service-account-wbstack-api" diff --git a/charts/api/templates/role-defaultrole.yaml b/charts/api/templates/role-defaultrole.yaml index 83cc345..687f345 100644 --- a/charts/api/templates/role-defaultrole.yaml +++ b/charts/api/templates/role-defaultrole.yaml @@ -1,5 +1,5 @@ apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole +kind: Role metadata: name: {{ include "api.fullname" . }}-defaultrole labels: @@ -11,9 +11,6 @@ rules: - apiGroups: [""] resources: ["pods", "services"] verbs: ["get", "list", "watch"] -- apiGroups: ["batch"] - resources: ["jobs"] - verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [""] resources: ["configmaps"] verbs: ["get", "list", "update", "patch"] diff --git a/charts/api/templates/role-jobmanager.yaml b/charts/api/templates/role-jobmanager.yaml new file mode 100644 index 0000000..28e7a4e --- /dev/null +++ b/charts/api/templates/role-jobmanager.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "api.fullname" . }}-api-jobmanager + namespace: {{ .Values.queue.apiJobNamespace }} + labels: +{{ include "api.labels" . | indent 4 }} +rules: +- apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "api.fullname" . }}-qs-jobmanager + namespace: {{ .Values.queue.qsJobNamespace }} + labels: +{{ include "api.labels" . | indent 4 }} +rules: +- apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] diff --git a/charts/api/templates/rolebinding-defaultrole.yaml b/charts/api/templates/rolebinding-defaultrole.yaml index eee7c52..2cff58d 100644 --- a/charts/api/templates/rolebinding-defaultrole.yaml +++ b/charts/api/templates/rolebinding-defaultrole.yaml @@ -1,5 +1,5 @@ apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding +kind: RoleBinding metadata: name: {{ include "api.fullname" . }}-defaultrole labels: @@ -7,8 +7,8 @@ metadata: subjects: - kind: ServiceAccount name: {{ include "api.fullname" . }}-defaultrole - namespace: default + namespace: {{ .Release.Namespace }} roleRef: - kind: ClusterRole + kind: Role name: {{ include "api.fullname" . }}-defaultrole apiGroup: rbac.authorization.k8s.io diff --git a/charts/api/templates/rolebinding-jobmanager.yaml b/charts/api/templates/rolebinding-jobmanager.yaml new file mode 100644 index 0000000..b424a68 --- /dev/null +++ b/charts/api/templates/rolebinding-jobmanager.yaml @@ -0,0 +1,31 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "api.fullname" . }}-api-jobmanager + namespace: {{ .Values.queue.apiJobNamespace }} + labels: +{{ include "api.labels" . | indent 4 }} +subjects: +- kind: ServiceAccount + name: {{ include "api.fullname" . }}-defaultrole + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "api.fullname" . }}-api-jobmanager + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "api.fullname" . }}-qs-jobmanager + namespace: {{ .Values.queue.qsJobNamespace }} + labels: +{{ include "api.labels" . | indent 4 }} +subjects: +- kind: ServiceAccount + name: {{ include "api.fullname" . }}-defaultrole + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "api.fullname" . }}-qs-jobmanager + apiGroup: rbac.authorization.k8s.io diff --git a/charts/api/values.yaml b/charts/api/values.yaml index 4fa36dd..04c908e 100644 --- a/charts/api/values.yaml +++ b/charts/api/values.yaml @@ -47,6 +47,7 @@ replicaCount: queue: apiJobNamespace: api-jobs + qsJobNamespace: qs-jobs # a list of integers defining the delays for backing off when retrying # failed jobs from the queue. E.g. `[10,100,1000]` backoff: []