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

Added topologySpreadConstraints for the operator + a small refactoring #611

Merged
merged 3 commits into from
Aug 16, 2023
Merged
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
1 change: 1 addition & 0 deletions charts/victoria-metrics-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,5 @@ Change the values according to the need of the environment in ``victoria-metrics
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| serviceMonitor | object | `{"annotations":{},"enabled":false,"extraLabels":{},"relabelings":[]}` | configures monitoring with serviceScrape. VMServiceScrape must be pre-installed |
| tolerations | list | `[]` | Array of tolerations object. Ref: [https://kubernetes.io/docs/concepts/configuration/assign-pod-node/](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/) |
| topologySpreadConstraints | list | `[]` | Pod Topology Spread Constraints. Ref: [https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/) |
| watchNamespace | string | `""` | |
11 changes: 9 additions & 2 deletions charts/victoria-metrics-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ Create the name of the service account
{{- end -}}

{{/*
Create unified labels for vm-operator components
Selector labels
*/}}
{{- define "vm-operator.labels" -}}
{{- define "vm-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create unified labels for vm-operator components
*/}}
{{- define "vm-operator.labels" -}}
{{- include "vm-operator.selectorLabels" . }}
helm.sh/chart: {{ include "vm-operator.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
23 changes: 16 additions & 7 deletions charts/victoria-metrics-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ spec:
replicas: {{.Values.replicaCount}}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "vm-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.annotations }}
annotations:
{{ toYaml . | indent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- include "vm-operator.selectorLabels" . | nindent 8}}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -127,6 +125,17 @@ spec:
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := .Values.topologySpreadConstraints }}
- {{ toYaml $constraint | nindent 10 | trim }}
{{- if not $constraint.labelSelector }}
labelSelector:
matchLabels:
{{- include "vm-operator.selectorLabels" $ | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
Expand Down
5 changes: 2 additions & 3 deletions charts/victoria-metrics-operator/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ spec:
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- include "vm-operator.selectorLabels" . | nindent 6 }}
{{- end }}
5 changes: 2 additions & 3 deletions charts/victoria-metrics-operator/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ spec:
port: 443
targetPort: 9443
selector:
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: "ClusterIP"
{{- include "vm-operator.selectorLabels" . | nindent 4 }}
type: "ClusterIP"
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ metadata:
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "vm-operator.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
{{- if .Values.serviceMonitor.scheme }}
Expand All @@ -42,4 +41,4 @@ spec:
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/victoria-metrics-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ tolerations: []

# -- Pod affinity
affinity: {}

# -- Pod Topology Spread Constraints. Ref: [https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/)
topologySpreadConstraints: []

# -- operator container additional commandline arguments
extraArgs: {}

Expand Down
Loading