Skip to content

Commit

Permalink
feat(svc): add grpc service port
Browse files Browse the repository at this point in the history
 - set ports to same defaults as mimir helm chart
  • Loading branch information
Umaaz committed Apr 26, 2024
1 parent 22f289b commit 1381e40
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion charts/mimir-singleton/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.2.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
11 changes: 1 addition & 10 deletions charts/mimir-singleton/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mimir-singleton.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mimir-singleton.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mimir-singleton.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
{{- else }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mimir-singleton.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
Expand Down
14 changes: 14 additions & 0 deletions charts/mimir-singleton/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,17 @@ configMap:
- key: "overrides.yaml"
path: "overrides.yaml"
{{- end -}}

{{/*
Internal servers http listen port - derived from Mimir default
*/}}
{{- define "mimir-singleton.serverHttpListenPort" -}}
{{ (((.Values.config).structuredConfig).server).http_listen_port | default "8080" }}
{{- end -}}

{{/*
Internal servers grpc listen port - derived from Mimir default
*/}}
{{- define "mimir-singleton.serverGrpcListenPort" -}}
{{ (((.Values.config).structuredConfig).server).grpc_listen_port | default "9095" }}
{{- end -}}
8 changes: 6 additions & 2 deletions charts/mimir-singleton/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ metadata:
labels:
{{- include "mimir-singleton.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
type: ClusterIP
ports:
- port: {{ .Values.service.port }}
- port: {{ include "mimir-singleton.serverHttpListenPort" . }}
targetPort: http
protocol: TCP
name: http
- port: {{ include "mimir-singleton.serverGrpcListenPort" . }}
targetPort: grpc
protocol: TCP
name: grpc
selector:
{{- include "mimir-singleton.selectorLabels" . | nindent 4 }}
5 changes: 4 additions & 1 deletion charts/mimir-singleton/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ spec:
name: mimir
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ include "mimir-singleton.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir-singleton.serverGrpcListenPort" . }}
protocol: TCP
livenessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "mimir-singleton.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "mimir-singleton.fullname" . }}:{{ include "mimir-singleton.serverHttpListenPort" . }}']
restartPolicy: Never
10 changes: 4 additions & 6 deletions charts/mimir-singleton/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 9009

ingress:
enabled: false
className: ""
Expand Down Expand Up @@ -142,7 +138,6 @@ config:
native_histograms_ingestion_enabled: true
server:
http_listen_port: 9009
log_level: error
ruler_storage:
Expand Down Expand Up @@ -198,7 +193,10 @@ config:
enable_api: true
alertmanager_url: http://localhost:9009/alertmanager/
structuredConfig: {}
structuredConfig:
server:
grpc_listen_port: 9095
http_listen_port: 8080

## The configuration for mimir overrides module
overrides:
Expand Down

0 comments on commit 1381e40

Please sign in to comment.