Skip to content

Commit

Permalink
feat: Allow users to set type and internalTrafficPolicy setting on Ku…
Browse files Browse the repository at this point in the history
…bernetes services. Enable internalTrafficPolicy only from Kubernetes version 1.22 or above.

Signed-off-by: Daniel Kovacs <[email protected]>
  • Loading branch information
kovaxur committed Oct 16, 2024
1 parent e60926a commit 5061ea4
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Grafana Mimir

* [FEATURE] Allow users to set type and internalTrafficPolicy setting on Kubernetes services
* [CHANGE] Alertmanager: the following metrics are not exported for a given `user` when the metric value is zero: #9359
* `cortex_alertmanager_alerts_received_total`
* `cortex_alertmanager_alerts_invalid_total`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
{{- toYaml .Values.admin_api.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.admin_api.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.admin_api.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ metadata:
{{- toYaml .Values.alertmanager.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.alertmanager.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.alertmanager.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ metadata:
{{- toYaml .Values.compactor.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.compactor.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.compactor.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ metadata:
{{- toYaml .Values.distributor.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.distributor.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.distributor.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ metadata:
namespace: {{ $.Release.Namespace | quote }}
spec:
type: {{ .service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .service.internalTrafficPolicy }}
{{- end }}
{{- with .service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ metadata:
{{- toYaml .Values.ingester.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.ingester.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.ingester.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ metadata:
namespace: {{ .Release.Namespace | quote }}
spec:
type: {{ .Values.nginx.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.nginx.service.internalTrafficPolicy }}
{{- end }}
{{- with .Values.nginx.service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
{{- toYaml .Values.overrides_exporter.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.overrides_exporter.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.overrides_exporter.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ metadata:
{{- toYaml .Values.querier.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.querier.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.querier.service.internalTrafficPolicy }}
{{- end}}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ metadata:
{{- toYaml .Values.query_frontend.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.query_frontend.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.query_frontend.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
annotations:
{{- toYaml .Values.query_scheduler.service.annotations | nindent 4 }}
spec:
type: ClusterIP
type: {{ .Values.query_scheduler.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.query_scheduler.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
{{- toYaml .Values.ruler_querier.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.ruler_querier.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.ruler_querier.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
{{- toYaml .Values.ruler_query_frontend.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.ruler_query_frontend.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.ruler_query_frontend.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
annotations:
{{- toYaml .Values.ruler_query_scheduler.service.annotations | nindent 4 }}
spec:
type: ClusterIP
type: {{ .Values.ruler_query_scheduler.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.ruler_query_scheduler.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ metadata:
{{- toYaml .Values.ruler.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.ruler.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.ruler.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ metadata:
{{- toYaml .Values.store_gateway.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
type: {{ .Values.store_gateway.service.type }}
{{- if semverCompare ">= 1.22-0" (include "mimir.kubeVersion" .) }}
internalTrafficPolicy: {{ .Values.store_gateway.service.internalTrafficPolicy }}
{{- end }}
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
Expand Down
46 changes: 46 additions & 0 deletions operations/helm/charts/mimir-distributed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ alertmanager:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

# -- Optionally set the scheduler for pods of the alertmanager
schedulerName: ""
Expand Down Expand Up @@ -815,6 +818,9 @@ distributor:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -906,6 +912,9 @@ ingester:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

# -- Optionally set the scheduler for pods of the ingester
schedulerName: ""
Expand Down Expand Up @@ -1125,6 +1134,9 @@ overrides_exporter:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

strategy:
type: RollingUpdate
Expand Down Expand Up @@ -1229,6 +1241,9 @@ ruler:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

# -- Dedicated service account for ruler pods.
# If not set, the default service account defined at the begining of this file will be used.
Expand Down Expand Up @@ -1357,6 +1372,9 @@ ruler_querier:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1464,6 +1482,9 @@ ruler_query_frontend:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1548,6 +1569,9 @@ ruler_query_scheduler:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1673,6 +1697,9 @@ querier:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1779,6 +1806,9 @@ query_frontend:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1863,6 +1893,9 @@ query_scheduler:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

resources:
requests:
Expand Down Expand Up @@ -1950,6 +1983,9 @@ store_gateway:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

# -- Optionally set the scheduler for pods of the store-gateway
schedulerName: ""
Expand Down Expand Up @@ -2157,6 +2193,9 @@ compactor:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

# -- Optionally set the scheduler for pods of the compactor
schedulerName: ""
Expand Down Expand Up @@ -2893,6 +2932,8 @@ nginx:
annotations: {}
# -- Labels for nginx service
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
# Ingress configuration
ingress:
# -- Specifies whether an ingress for the nginx should be created
Expand Down Expand Up @@ -3288,6 +3329,8 @@ gateway:
# Instead, it will update the existing one in place.
# If left as an empty string, a name is generated.
nameOverride: ""
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster

ingress:
enabled: false
Expand Down Expand Up @@ -3906,6 +3949,9 @@ admin_api:
service:
annotations: {}
labels: {}
# -- https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
internalTrafficPolicy: Cluster
type: ClusterIP

initContainers: []

Expand Down

0 comments on commit 5061ea4

Please sign in to comment.