Skip to content

feat: Kubernetes recommended labels #175

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ If release name contains chart name it will be used as a full name.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "ack-s3-controller.labels" -}}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" $ }}
{{ include "ack-s3-controller.selectorLabels" $ }}
app.kubernetes.io/component: s3-controller
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: ack-s3-controller
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" $ }}
{{- if .Values.additionalLabels }}
{{ toYaml $.Values.additionalLabels $ }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ack-s3-controller.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}

{{/* The name of the service account to use */}}
{{- define "ack-s3-controller.service-account.name" -}}
{{ default "default" .Values.serviceAccount.name }}
Expand Down
14 changes: 2 additions & 12 deletions helm/templates/caches-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-namespace-caches
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" . | nindent 4 }}
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
Expand All @@ -24,12 +19,7 @@ metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-configmaps-cache
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" . | nindent 4 }}
roleRef:
kind: Role
apiGroup: rbac.authorization.k8s.io
Expand Down
16 changes: 3 additions & 13 deletions helm/templates/caches-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ kind: ClusterRole
metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-namespaces-cache
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand All @@ -25,12 +20,7 @@ metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-configmaps-cache
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand All @@ -39,4 +29,4 @@ rules:
verbs:
- get
- list
- watch
- watch
16 changes: 3 additions & 13 deletions helm/templates/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-rolebinding
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
Expand All @@ -34,12 +29,7 @@ metadata:
name: {{ $fullname }}-{{ . }}
namespace: {{ . }}
labels:
app.kubernetes.io/name: {{ $fullname }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ $appVersion }}
k8s-app: {{ $fullname }}
helm.sh/chart: {{ $chartVersion }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
roleRef:
kind: Role
apiGroup: rbac.authorization.k8s.io
Expand All @@ -49,4 +39,4 @@ subjects:
name: {{ $serviceAccountName }}
namespace: {{ $releaseNamespace }}
{{ end }}
{{ end }}
{{ end }}
16 changes: 3 additions & 13 deletions helm/templates/cluster-role-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ kind: ClusterRole
metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
{{- range $key, $value := $labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Expand All @@ -30,15 +25,10 @@ metadata:
name: {{ $fullname }}-{{ . }}
namespace: {{ . }}
labels:
app.kubernetes.io/name: {{ $fullname }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ $appVersion }}
k8s-app: {{ $fullname }}
helm.sh/chart: {{ $chartVersion }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
{{- range $key, $value := $labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{ $rbacRules }}
{{ end }}
{{ end }}
{{ end }}
17 changes: 4 additions & 13 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.deployment.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "ack-s3-controller.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- if .Values.deployment.annotations }}
Expand All @@ -25,10 +19,7 @@ spec:
{{- end }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
k8s-app: {{ include "ack-s3-controller.app.name" . }}
{{- include "ack-s3-controller.labels" . | nindent 8 }}
{{- range $key, $value := .Values.deployment.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Expand Down Expand Up @@ -148,7 +139,7 @@ spec:
{{- if .Values.deployment.extraEnvVars -}}
{{ toYaml .Values.deployment.extraEnvVars | nindent 8 }}
{{- end }}
{{- if or .Values.aws.credentials.secretName .Values.deployment.extraVolumeMounts }}
{{- if or .Values.aws.credentials.secretName .Values.deployment.extraVolumeMounts }}
volumeMounts:
{{- if .Values.aws.credentials.secretName }}
- name: {{ .Values.aws.credentials.secretName }}
Expand Down
8 changes: 1 addition & 7 deletions helm/templates/leader-election-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ metadata:
namespace: {{ .Release.Namespace }}
{{ end }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
roleRef:
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "ack-s3-controller.app.fullname" . }}-leaderelection
Expand Down
7 changes: 1 addition & 6 deletions helm/templates/leader-election-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ metadata:
namespace: {{ .Release.Namespace }}
{{ end }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
rules:
- apiGroups:
- coordination.k8s.io
Expand Down
12 changes: 2 additions & 10 deletions helm/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ metadata:
name: {{ .Chart.Name | trimSuffix "-chart" | trunc 44 }}-controller-metrics
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
spec:
selector:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
k8s-app: {{ include "ack-s3-controller.app.name" . }}
{{- include "ack-s3-controller.selectorLabels" $ | nindent 4 }}
{{- range $key, $value := .Values.deployment.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Expand Down
7 changes: 1 addition & 6 deletions helm/templates/role-reader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-reader
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
rules:
- apiGroups:
- s3.services.k8s.aws
Expand Down
7 changes: 1 addition & 6 deletions helm/templates/role-writer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ metadata:
name: {{ include "ack-s3-controller.app.fullname" . }}-writer
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
rules:
- apiGroups:
- s3.services.k8s.aws
Expand Down
7 changes: 1 addition & 6 deletions helm/templates/service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: {{ include "ack-s3-controller.app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
k8s-app: {{ include "ack-s3-controller.app.name" . }}
helm.sh/chart: {{ include "ack-s3-controller.chart.name-version" . }}
{{- include "ack-s3-controller.labels" $ | nindent 4 }}
name: {{ include "ack-s3-controller.service-account.name" . }}
namespace: {{ .Release.Namespace }}
annotations:
Expand Down
15 changes: 10 additions & 5 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ image:
nameOverride: ""
fullnameOverride: ""

# Common labels to add to all resources.
additionalLabels: {}
# app: my-app


deployment:
annotations: {}
labels: {}
Expand Down Expand Up @@ -114,7 +119,7 @@ installScope: cluster
watchNamespace: ""

# Set the value of labelsSelectors to be used by the controller to filter the resources to watch.
# You can set multiple labelsSelectors by providing a comma separated list of a=b arguments. e.g "label1=value1,label2=value2"
# You can set multiple labelsSelectors by providing a comma separated list of a=b arguments. e.g "label1=value1,label2=value2"
watchSelectors: ""

resourceTags:
Expand All @@ -140,7 +145,7 @@ reconcile:
# An object representing the reconcile max concurrent syncs configuration for each specific
# resource.
resourceMaxConcurrentSyncs: {}

# Set the value of resources to specify which resource kinds to reconcile.
# If empty, all resources will be reconciled.
# If specified, only the listed resource kinds will be reconciled.
Expand Down Expand Up @@ -175,7 +180,7 @@ featureGates:
ServiceLevelCARM: false
# Enables the Team level granularity for CARM. See https://github.com/aws-controllers-k8s/community/issues/2031
TeamLevelCARM: false
# Enable ReadOnlyResources feature/annotation.
# Enable ReadOnlyResources feature/annotation.
ReadOnlyResources: false
# Enable ResourceAdoption feature/annotation.
ResourceAdoption: false
# Enable ResourceAdoption feature/annotation.
ResourceAdoption: false