From b523b49b593abb3d532d692eb6d1d06508fb00c7 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Fri, 2 Feb 2024 08:22:38 +0100 Subject: [PATCH 1/4] feat(labels): refactoring Kubernetes recommended labels Signed-off-by: Nicolas Lamirault --- charts/bctlquickstart/templates/_helpers.tpl | 1 + .../agent/bctl-agent-clusterrole.yaml | 19 ++- .../agent/bctl-agent-clusterrolebinding.yaml | 13 +- .../agent/bctl-agent-deployment.yaml | 158 +++++++++--------- .../templates/agent/bctl-agent-role.yaml | 13 +- .../agent/bctl-agent-rolebinding.yaml | 13 +- .../agent/bctl-agent-serviceaccount.yaml | 1 + .../templates/cleanup/bctl-cleanup-job.yaml | 1 + .../templates/cleanup/bctl-cleanup-role.yaml | 9 +- .../cleanup/bctl-cleanup-rolebindings.yaml | 13 +- .../cleanup/bctl-cleanup-serviceaccount.yaml | 1 + .../quickstart/bctl-quickstart-job.yaml | 119 ++++++------- .../quickstart/bctl-quickstart-role.yaml | 19 ++- .../bctl-quickstart-rolebindings.yaml | 13 +- .../bctl-quickstart-serviceaccount.yaml | 1 + 15 files changed, 207 insertions(+), 187 deletions(-) diff --git a/charts/bctlquickstart/templates/_helpers.tpl b/charts/bctlquickstart/templates/_helpers.tpl index 91460f3..b743e67 100644 --- a/charts/bctlquickstart/templates/_helpers.tpl +++ b/charts/bctlquickstart/templates/_helpers.tpl @@ -39,6 +39,7 @@ helm.sh/chart: {{ include "bctlquickstartchart.chart" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} +app.kubernetes.io/part-of: {{ include "bctlquickstartchart.name" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-clusterrole.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-clusterrole.yaml index e2fe28e..57355cd 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-clusterrole.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-clusterrole.yaml @@ -4,18 +4,19 @@ metadata: name: {{ include "bctlquickstartchart.agentClusterRoleName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} rules: - - apiGroups: [""] - resources: ["users", "groups", "serviceaccounts"] - verbs: ["impersonate"] - - apiGroups: [""] - resources: ["serviceaccounts"] - verbs: ["create", "delete", "list", "get"] - - apiGroups: ["rbac.authorization.k8s.io"] - resources: ["clusterrolebindings", "rolebindings"] - verbs: ["list"] \ No newline at end of file + - apiGroups: [""] + resources: ["users", "groups", "serviceaccounts"] + verbs: ["impersonate"] + - apiGroups: [""] + resources: ["serviceaccounts"] + verbs: ["create", "delete", "list", "get"] + - apiGroups: ["rbac.authorization.k8s.io"] + resources: ["clusterrolebindings", "rolebindings"] + verbs: ["list"] \ No newline at end of file diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-clusterrolebinding.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-clusterrolebinding.yaml index bfb859a..c5edbe4 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-clusterrolebinding.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-clusterrolebinding.yaml @@ -4,16 +4,17 @@ metadata: name: {{ include "bctlquickstartchart.agentClusterRoleBindingName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} subjects: - - kind: ServiceAccount - namespace: {{ .Release.Namespace }} - name: {{ include "bctlquickstartchart.agentServiceAccountName" . }} + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: {{ include "bctlquickstartchart.agentServiceAccountName" . }} roleRef: - kind: ClusterRole - name: {{ include "bctlquickstartchart.agentClusterRoleName" . }} - apiGroup: rbac.authorization.k8s.io \ No newline at end of file + kind: ClusterRole + name: {{ include "bctlquickstartchart.agentClusterRoleName" . }} + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml index d71ee8c..c04a39e 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml @@ -4,85 +4,91 @@ metadata: name: {{ include "bctlquickstartchart.agentDeploymentName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent + app: {{ include "bctlquickstartchart.agentDeploymentName" . }} {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} spec: - replicas: 1 - selector: - matchLabels: - app: {{ include "bctlquickstartchart.agentDeploymentName" . }} - template: - metadata: - labels: - app: {{ include "bctlquickstartchart.agentDeploymentName" . }} - spec: - serviceAccountName: {{ include "bctlquickstartchart.agentServiceAccountName" . }} - {{- if .Values.image.agentImagePullSecrets }} - imagePullSecrets: - {{- range .Values.image.agentImagePullSecrets }} - - name: {{ . }} - {{- end }} - {{- end }} - {{- if .Values.priorityClass }} - priorityClassName: {{ .Values.priorityClass }} - {{- end }} - containers: - - name: bctl-agent - image: "{{ required "A valid .Values.image.agentImageName entry required!" .Values.image.agentImageName}}:{{ required "A valid .Values.image.agentImageTag entry required!" .Values.image.agentImageTag }}" - resources: - {{- toYaml .Values.agentResources | nindent 16 }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - containerPort: 6001 - name: bctl-port - env: - - name: SERVICE_URL - value: "{{ required "A valid .Values.serviceUrl entry required!" .Values.serviceUrl }}" - - name: TARGET_NAME - value: "{{ required "A valid .Values.clusterName entry required!" .Values.clusterName }}" - - name: API_KEY - {{ if .Values.apiKey }} - value: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" - {{ else if .Values.apiKeyExistingSecret }} - valueFrom: - secretKeyRef: - name: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" - key: "api-key" - {{ end }} - - name: NAMESPACE - value: {{ .Release.Namespace }} - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: DEV - value: {{ printf "'%t'" .Values.isDev }} - - name: LOG_LEVEL - value: {{ .Values.logLevel }} - {{ if .Values.environmentId }} - - name: ENVIRONMENT - value: {{ .Values.environmentId }} - {{ end }} - {{ if .Values.idp.expectedProvider }} - - name: IDP_PROVIDER - value: {{ .Values.idp.expectedProvider }} - {{ end }} - {{ if .Values.idp.expectedOrgId }} - - name: IDP_ORG_ID - value: {{ .Values.idp.expectedOrgId }} - {{ end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 16 }} - {{- end }} + replicas: 1 + selector: + matchLabels: + {{- include "bctlquickstartchart.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: agent + app: {{ include "bctlquickstartchart.agentDeploymentName" . }} + template: + metadata: + labels: + {{- include "bctlquickstartchart.labels" . | nindent 8 }} + app.kubernetes.io/component: agent + app: {{ include "bctlquickstartchart.agentDeploymentName" . }} + spec: + serviceAccountName: {{ include "bctlquickstartchart.agentServiceAccountName" . }} + {{- if .Values.image.agentImagePullSecrets }} + imagePullSecrets: + {{- range .Values.image.agentImagePullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + {{- if .Values.priorityClass }} + priorityClassName: {{ .Values.priorityClass }} + {{- end }} + containers: + - name: bctl-agent + image: "{{ required "A valid .Values.image.agentImageName entry required!" .Values.image.agentImageName}}:{{ required "A valid .Values.image.agentImageTag entry required!" .Values.image.agentImageTag }}" + resources: + {{- toYaml .Values.agentResources | nindent 16 }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 6001 + name: bctl-port + env: + - name: SERVICE_URL + value: "{{ required "A valid .Values.serviceUrl entry required!" .Values.serviceUrl }}" + - name: TARGET_NAME + value: "{{ required "A valid .Values.clusterName entry required!" .Values.clusterName }}" + - name: API_KEY + {{ if .Values.apiKey }} + value: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" + {{ else if .Values.apiKeyExistingSecret }} + valueFrom: + secretKeyRef: + name: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" + key: "api-key" + {{ end }} + - name: NAMESPACE + value: {{ .Release.Namespace }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: DEV + value: {{ printf "'%t'" .Values.isDev }} + - name: LOG_LEVEL + value: {{ .Values.logLevel }} + {{ if .Values.environmentId }} + - name: ENVIRONMENT + value: {{ .Values.environmentId }} + {{ end }} + {{ if .Values.idp.expectedProvider }} + - name: IDP_PROVIDER + value: {{ .Values.idp.expectedProvider }} + {{ end }} + {{ if .Values.idp.expectedOrgId }} + - name: IDP_ORG_ID + value: {{ .Values.idp.expectedOrgId }} + {{ end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 16 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 16 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 16 }} + {{- end }} diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-role.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-role.yaml index beb4c60..077feca 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-role.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-role.yaml @@ -4,15 +4,16 @@ metadata: name: {{ include "bctlquickstartchart.agentRoleName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} rules: - - apiGroups: [""] - resources: ["secrets"] - verbs: ["get", "update", "create"] - - apiGroups: [""] - resources: ["pods/log", "events"] - verbs: ["get", "list"] \ No newline at end of file + - apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "update", "create"] + - apiGroups: [""] + resources: ["pods/log", "events"] + verbs: ["get", "list"] \ No newline at end of file diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-rolebinding.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-rolebinding.yaml index 5ca773d..1789493 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-rolebinding.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-rolebinding.yaml @@ -4,16 +4,17 @@ metadata: name: {{ include "bctlquickstartchart.agentRoleBindingName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} subjects: - - kind: ServiceAccount - namespace: {{ .Release.Namespace }} - name: {{ include "bctlquickstartchart.agentServiceAccountName" . }} + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: {{ include "bctlquickstartchart.agentServiceAccountName" . }} roleRef: - kind: Role - name: {{ include "bctlquickstartchart.agentRoleName" . }} - apiGroup: rbac.authorization.k8s.io \ No newline at end of file + kind: Role + name: {{ include "bctlquickstartchart.agentRoleName" . }} + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-serviceaccount.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-serviceaccount.yaml index 7f5c4fa..b515ae7 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-serviceaccount.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-serviceaccount.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "bctlquickstartchart.agentServiceAccountName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: agent {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-job.yaml b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-job.yaml index 3f43eca..df1825c 100644 --- a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-job.yaml +++ b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-job.yaml @@ -8,6 +8,7 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: cleanup spec: ttlSecondsAfterFinished: 300 # Leave job for 5 minutes if failed/success template: diff --git a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-role.yaml b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-role.yaml index 0399d0f..b9de2ac 100644 --- a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-role.yaml +++ b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-role.yaml @@ -4,13 +4,14 @@ metadata: name: {{ include "bctlquickstartchart.cleanupRoleName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: cleanup {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} rules: - - apiGroups: [""] - resources: ["secrets"] - verbs: ["delete"] - resourceNames: [{{ include "bctlquickstartchart.agentSecretName" . }}] + - apiGroups: [""] + resources: ["secrets"] + verbs: ["delete"] + resourceNames: [{{ include "bctlquickstartchart.agentSecretName" . }}] diff --git a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-rolebindings.yaml b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-rolebindings.yaml index a6c422b..6eea1bb 100644 --- a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-rolebindings.yaml +++ b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-rolebindings.yaml @@ -4,16 +4,17 @@ metadata: name: {{ include "bctlquickstartchart.cleanupRoleBindingName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: cleanup {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} subjects: - - kind: ServiceAccount - namespace: {{ .Release.Namespace }} - name: {{ include "bctlquickstartchart.cleanupServiceAccountName" . }} + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: {{ include "bctlquickstartchart.cleanupServiceAccountName" . }} roleRef: - kind: Role - name: {{ include "bctlquickstartchart.cleanupRoleName" . }} - apiGroup: rbac.authorization.k8s.io \ No newline at end of file + kind: Role + name: {{ include "bctlquickstartchart.cleanupRoleName" . }} + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-serviceaccount.yaml b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-serviceaccount.yaml index 7fe155e..6c89923 100644 --- a/charts/bctlquickstart/templates/cleanup/bctl-cleanup-serviceaccount.yaml +++ b/charts/bctlquickstart/templates/cleanup/bctl-cleanup-serviceaccount.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "bctlquickstartchart.cleanupServiceAccountName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: cleanup {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml index 826b76c..7704579 100644 --- a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml +++ b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml @@ -5,69 +5,70 @@ metadata: name: {{ include "bctlquickstartchart.quickstartJobName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: quickstart annotations: "helm.sh/hook": post-install "helm.sh/hook-weight": "0" "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded namespace: {{ .Release.Namespace }} spec: - backoffLimit: 0 - ttlSecondsAfterFinished: 300 # Leave job for 5 minutes if failed/success - template: - spec: - serviceAccountName: {{ include "bctlquickstartchart.quickstartServiceAccountName" . }} - restartPolicy: Never - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.quickstartImageName }}:{{ .Values.image.quickstartImageTag }}" - resources: - {{- toYaml .Values.quickstartResources | nindent 16 }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: API_KEY - {{ if .Values.apiKey }} - value: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" - {{ else if .Values.apiKeyExistingSecret }} - valueFrom: - secretKeyRef: - name: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" - key: "api-key" - {{ end }} - - name: CLUSTER_NAME - value: "{{ required "A valid .Values.clusterName entry required!" .Values.clusterName }}" - - name: SERVICE_URL - value: "{{ required "A valid .Values.serviceUrl entry required!" .Values.serviceUrl }}" - command: - - bctl-quickstart - args: - {{- if .Values.users }} - {{- range $user := .Values.users }} - - "-users" - - "{{ $user }}" - {{- end }} - {{- end }} - {{- if .Values.targetUsers }} - {{- range $targetUser := .Values.targetUsers }} - - "-targetUsers" - - "{{ $targetUser }}" - {{- end }} - {{- end }} - {{- if .Values.targetGroups }} - {{- range $targetGroup := .Values.targetGroups }} - - "-targetGroups" - - "{{ $targetGroup }}" - {{- end }} - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 16 }} - {{- end }} + backoffLimit: 0 + ttlSecondsAfterFinished: 300 # Leave job for 5 minutes if failed/success + template: + spec: + serviceAccountName: {{ include "bctlquickstartchart.quickstartServiceAccountName" . }} + restartPolicy: Never + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.quickstartImageName }}:{{ .Values.image.quickstartImageTag }}" + resources: + {{- toYaml .Values.quickstartResources | nindent 16 }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: API_KEY + {{ if .Values.apiKey }} + value: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" + {{ else if .Values.apiKeyExistingSecret }} + valueFrom: + secretKeyRef: + name: "{{- include "bctlquickstartchart.apiKeyOrRef" . -}}" + key: "api-key" + {{ end }} + - name: CLUSTER_NAME + value: "{{ required "A valid .Values.clusterName entry required!" .Values.clusterName }}" + - name: SERVICE_URL + value: "{{ required "A valid .Values.serviceUrl entry required!" .Values.serviceUrl }}" + command: + - bctl-quickstart + args: + {{- if .Values.users }} + {{- range $user := .Values.users }} + - "-users" + - "{{ $user }}" + {{- end }} + {{- end }} + {{- if .Values.targetUsers }} + {{- range $targetUser := .Values.targetUsers }} + - "-targetUsers" + - "{{ $targetUser }}" + {{- end }} + {{- end }} + {{- if .Values.targetGroups }} + {{- range $targetGroup := .Values.targetGroups }} + - "-targetGroups" + - "{{ $targetGroup }}" + {{- end }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 16 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 16 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 16 }} + {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-role.yaml b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-role.yaml index fa6fe94..3f539c6 100644 --- a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-role.yaml +++ b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-role.yaml @@ -5,19 +5,20 @@ metadata: name: {{ include "bctlquickstartchart.quickstartRoleName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: quickstart {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} rules: - - apiGroups: [""] - resources: ["pods"] - verbs: ["watch"] - - apiGroups: ["apps"] - resources: ["deployments"] - verbs: ["get", "patch", "list"] - - apiGroups: ["batch"] - resources: ["jobs"] - verbs: ["delete"] + - apiGroups: [""] + resources: ["pods"] + verbs: ["watch"] + - apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get", "patch", "list"] + - apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["delete"] {{- end }} \ No newline at end of file diff --git a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-rolebindings.yaml b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-rolebindings.yaml index 6c65ce8..36711c1 100644 --- a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-rolebindings.yaml +++ b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-rolebindings.yaml @@ -5,17 +5,18 @@ metadata: name: {{ include "bctlquickstartchart.quickstartRoleBindingName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: quickstart {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} namespace: {{ .Release.Namespace }} subjects: - - kind: ServiceAccount - namespace: {{ .Release.Namespace }} - name: {{ include "bctlquickstartchart.quickstartServiceAccountName" . }} + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: {{ include "bctlquickstartchart.quickstartServiceAccountName" . }} roleRef: - kind: Role - name: {{ include "bctlquickstartchart.quickstartRoleName" . }} - apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "bctlquickstartchart.quickstartRoleName" . }} + apiGroup: rbac.authorization.k8s.io {{- end }} \ No newline at end of file diff --git a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-serviceaccount.yaml b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-serviceaccount.yaml index fecde3b..4d710b3 100644 --- a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-serviceaccount.yaml +++ b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-serviceaccount.yaml @@ -5,6 +5,7 @@ metadata: name: {{ include "bctlquickstartchart.quickstartServiceAccountName" . }} labels: {{- include "bctlquickstartchart.labels" . | nindent 4 }} + app.kubernetes.io/component: quickstart {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} From da919529ef00cd8da41de50fc3133b4e8416c8e9 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Fri, 2 Feb 2024 08:24:50 +0100 Subject: [PATCH 2/4] feat(labels): support additional labels for all resources Signed-off-by: Nicolas Lamirault --- charts/bctlquickstart/templates/_helpers.tpl | 3 +++ charts/bctlquickstart/values.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/charts/bctlquickstart/templates/_helpers.tpl b/charts/bctlquickstart/templates/_helpers.tpl index b743e67..a74557c 100644 --- a/charts/bctlquickstart/templates/_helpers.tpl +++ b/charts/bctlquickstart/templates/_helpers.tpl @@ -41,6 +41,9 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/part-of: {{ include "bctlquickstartchart.name" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.additionalLabels }} +{{ toYaml .Values.additionalLabels }} +{{- end }} {{- end }} {{/* diff --git a/charts/bctlquickstart/values.yaml b/charts/bctlquickstart/values.yaml index f788f3d..bde0e58 100644 --- a/charts/bctlquickstart/values.yaml +++ b/charts/bctlquickstart/values.yaml @@ -19,6 +19,9 @@ fullnameOverride: "bctl-quickstart-chart" # Annotations to add to our objects annotations: {} +# -- Additional labels to add to all resources +additionalLabels: {} + quickstart: # Controls if we create any of the quickstart objects create: true From ab5f042d2ad29fd0e3ae15a75d5f39e1e112685a Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Fri, 2 Feb 2024 08:31:45 +0100 Subject: [PATCH 3/4] feat(resources): Do not specify default resources Signed-off-by: Nicolas Lamirault --- .../agent/bctl-agent-deployment.yaml | 4 ++- .../quickstart/bctl-quickstart-job.yaml | 4 ++- charts/bctlquickstart/values.yaml | 31 ++++++++++--------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml index c04a39e..ab35ff1 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml @@ -38,8 +38,10 @@ spec: containers: - name: bctl-agent image: "{{ required "A valid .Values.image.agentImageName entry required!" .Values.image.agentImageName}}:{{ required "A valid .Values.image.agentImageTag entry required!" .Values.image.agentImageTag }}" + {{- with .Values.agentResources }} resources: - {{- toYaml .Values.agentResources | nindent 16 }} + {{- toYaml . | nindent 10 }} + {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - containerPort: 6001 diff --git a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml index 7704579..7ad4e68 100644 --- a/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml +++ b/charts/bctlquickstart/templates/quickstart/bctl-quickstart-job.yaml @@ -21,8 +21,10 @@ spec: containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.quickstartImageName }}:{{ .Values.image.quickstartImageTag }}" + {{- with .Values.quickstartResources }} resources: - {{- toYaml .Values.quickstartResources | nindent 16 }} + {{- toYaml . | nindent 8 }} + {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: API_KEY diff --git a/charts/bctlquickstart/values.yaml b/charts/bctlquickstart/values.yaml index bde0e58..884c5cd 100644 --- a/charts/bctlquickstart/values.yaml +++ b/charts/bctlquickstart/values.yaml @@ -60,24 +60,25 @@ targetGroups: [] # Optional environment to put the cluster into. Specify the ID. environmentId: "" -# Resources to use for the agent and quickstart job -agentResources: - limits: - cpu: 1 - memory: 1G - requests: - cpu: 1 - memory: 1G +# Resources to use for the agent +agentResources: {} + # limits: + # cpu: 1 + # memory: 1G + # requests: + # cpu: 1 + # memory: 1G priorityClass: "system-cluster-critical" -quickstartResources: - limits: - cpu: 1 - memory: 1G - requests: - cpu: 1 - memory: 1G +# Resources to use for quickstart job +quickstartResources: {} + # limits: + # cpu: 1 + # memory: 1G + # requests: + # cpu: 1 + # memory: 1G nodeSelector: {} From 8fc857b27d54e7b3c949dba2515eecd7bd3bb1bd Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Fri, 2 Feb 2024 08:38:17 +0100 Subject: [PATCH 4/4] fix(helm): typo and annotations Signed-off-by: Nicolas Lamirault --- .../templates/agent/bctl-agent-deployment.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml index ab35ff1..a5e7006 100644 --- a/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml +++ b/charts/bctlquickstart/templates/agent/bctl-agent-deployment.yaml @@ -20,6 +20,10 @@ spec: app: {{ include "bctlquickstartchart.agentDeploymentName" . }} template: metadata: + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} labels: {{- include "bctlquickstartchart.labels" . | nindent 8 }} app.kubernetes.io/component: agent @@ -84,13 +88,13 @@ spec: {{ end }} {{- with .Values.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 16 }} + {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 16 }} + {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: - {{- toYaml . | nindent 16 }} + {{- toYaml . | nindent 8 }} {{- end }}