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

Modify labels configuration for litmus-core #363

Open
wants to merge 7 commits into
base: master
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
2 changes: 1 addition & 1 deletion charts/litmus-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "3.11.0"
description: A Helm chart to install litmus infra components on Kubernetes
name: litmus-core
version: 3.11.0
version: 3.11.1
home: https://litmuschaos.io
sources:
- https://github.com/litmuschaos/litmus
Expand Down
2 changes: 1 addition & 1 deletion charts/litmus-core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# litmus-core

![Version: 3.11.0](https://img.shields.io/badge/Version-3.11.0-informational?style=flat-square) ![AppVersion: 3.11.0](https://img.shields.io/badge/AppVersion-3.11.0-informational?style=flat-square)
![Version: 3.11.1](https://img.shields.io/badge/Version-3.11.1-informational?style=flat-square) ![AppVersion: 3.11.0](https://img.shields.io/badge/AppVersion-3.11.0-informational?style=flat-square)

A Helm chart to install litmus infra components on Kubernetes

Expand Down
32 changes: 24 additions & 8 deletions charts/litmus-core/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/* Generate basic labels */}}
{{- define "litmus.labels" }}
{{/* Generate common labels */}}
{{- define "litmus.commonLabels" }}
app.kubernetes.io/component: litmus-infra
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ template "litmus.name" . }}
app.kubernetes.io/part-of: {{ template "litmus.name" . }}
app.kubernetes.io/version: "{{ .Chart.Version }}"
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
Expand All @@ -46,10 +44,28 @@ litmuschaos.io/version: {{ .Chart.AppVersion }}
{{- end }}
{{- end }}

{{/*
Specify default selectors
*/}}
{{- define "litmus.selectors" }}
{{/* Generate chaos-operator labels*/}}
{{- define "litmus.operatorLabels" }}
{{ include "litmus.commonLabels" . }}
{{ include "litmus.operatorSelectors" . }}
{{- end }}

{{/* Chaos operator selectors labels */}}
{{- define "litmus.operatorSelectors" }}
app: {{ template "litmus.name" . }}
app.kubernetes.io/name: {{ template "litmus.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/* Generate chaos-exporter labels*/}}
{{- define "litmus.exporterLabels" }}
{{ include "litmus.commonLabels" . }}
{{ include "litmus.exporterSelectors" . }}
{{- end }}

{{/* Chaos exporter selectors labels */}}
{{- define "litmus.exporterSelectors" }}
app: {{ template "litmus.name" . }}
app.kubernetes.io/name: {{ template "litmus.name" . }}-monitor
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/litmus-core/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ kind: ClusterRole
metadata:
name: {{ include "litmus.fullname" . }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
rules:
- apiGroups: [""]
resources: ["replicationcontrollers","secrets"]
Expand Down Expand Up @@ -46,8 +45,7 @@ kind: ClusterRole
metadata:
name: {{ include "litmus.fullname" . }}-admin
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
rules:
- apiGroups: [""]
resources: ["pods","pods/exec","pods/eviction","events"]
Expand Down
6 changes: 2 additions & 4 deletions charts/litmus-core/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "litmus.fullname" . }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -23,8 +22,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "litmus.fullname" . }}-admin
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
Copy link
Member

@uditgaurav uditgaurav May 16, 2024

Choose a reason for hiding this comment

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

Why do we need the labels on clusterrole and clusterrolebinding?

Copy link
Contributor Author

@Calvinaud Calvinaud May 16, 2024

Choose a reason for hiding this comment

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

The labels were already present before this PR. Personally I still think that the labels are useful since it help to know at which application the clusterrole/clusterrolebinding are part of.

For the ****-admin, I think the question is more are they part of the "operator" but I would still said yes.

But if needed, I can remove them.

roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
9 changes: 3 additions & 6 deletions charts/litmus-core/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ metadata:
name: {{ include "litmus.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "litmus.name" . }}
{{- include "litmus.selectors" . | indent 6 }}
{{- include "litmus.operatorSelectors" . | indent 6 }}
template:
metadata:
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 8 }}
{{- include "litmus.operatorLabels" . | indent 8 }}
spec:
serviceAccountName: {{ include "litmus.fullname" . }}
{{- if .Values.priorityClassName }}
Expand Down
9 changes: 3 additions & 6 deletions charts/litmus-core/templates/exporter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
name: {{ include "litmus.fullname" . }}-monitor
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.exporterLabels" . | indent 4 }}
{{- if .Values.exporter.annotations }}
annotations:
{{- toYaml .Values.exporter.annotations | nindent 4 }}
Expand All @@ -15,13 +14,11 @@ spec:
replicas: 1
selector:
matchLabels:
app: {{ template "litmus.name" . }}
{{- include "litmus.selectors" . | indent 6 }}
{{- include "litmus.exporterSelectors" . | indent 6 }}
template:
metadata:
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 8 }}
{{- include "litmus.exporterLabels" . | indent 8 }}
{{- if .Values.exporter.annotations }}
annotations:
{{- toYaml .Values.exporter.annotations | nindent 10 }}
Expand Down
6 changes: 2 additions & 4 deletions charts/litmus-core/templates/exporter-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ metadata:
namespace: {{ .Values.exporter.serviceMonitor.namespace }}
{{- end }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.exporterLabels" . | indent 4 }}
{{- if .Values.exporter.serviceMonitor.additionalLabels }}
{{- toYaml .Values.exporter.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
Expand All @@ -31,6 +30,5 @@ spec:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "litmus.name" . }}
{{- include "litmus.selectors" . | indent 6 }}
{{- include "litmus.exporterSelectors" . | indent 6 }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/litmus-core/templates/exporter-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ kind: Service
metadata:
name: {{ include "litmus.name" . }}-monitor
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | nindent 4 }}
{{- include "litmus.exporterLabels" . | nindent 4 }}
{{- if .Values.exporter.service.annotations }}
annotations:
{{- toYaml .Values.exporter.service.annotations | nindent 4 }}
Expand All @@ -18,6 +17,5 @@ spec:
targetPort: http
type: {{ .Values.exporter.service.type }}
selector:
app: {{ template "litmus.name" . }}
{{- include "litmus.selectors" . | nindent 4 }}
{{- include "litmus.exporterSelectors" . | nindent 4 }}
{{- end -}}
3 changes: 1 addition & 2 deletions charts/litmus-core/templates/namespaced-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ kind: Role
metadata:
name: {{ include "litmus.fullname" . }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
rules:
- apiGroups: ["","apps","batch","extensions","litmuschaos.io", "argoproj.io"]
resources: ["pods","pods/exec","pods/log","pods/eviction","jobs","deployments","daemonsets","statefulsets","events","configmaps","services","rollouts","chaosengines","chaosexperiments","chaosresults"]
Expand Down
3 changes: 1 addition & 2 deletions charts/litmus-core/templates/namespaced-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ kind: RoleBinding
metadata:
name: {{ include "litmus.fullname" . }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
6 changes: 2 additions & 4 deletions charts/litmus-core/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ kind: ServiceAccount
metadata:
name: {{ include "litmus.fullname" . }}
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
{{ if eq .Values.operatorMode "admin" }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "litmus.fullname" . }}-admin
labels:
app: {{ template "litmus.name" . }}
{{- include "litmus.labels" . | indent 4 }}
{{- include "litmus.operatorLabels" . | indent 4 }}
{{ end }}