Skip to content

Commit

Permalink
fix: influxdb ports, ingress resource (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomklapka authored Jun 21, 2023
1 parent e293200 commit 5151027
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 129 deletions.
2 changes: 1 addition & 1 deletion charts/influxdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: influxdb
version: 4.12.1
version: 4.12.2
appVersion: 1.8.10
description: Scalable datastore for metrics, events, and real-time analytics.
keywords:
Expand Down
138 changes: 69 additions & 69 deletions charts/influxdb/README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions charts/influxdb/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
InfluxDB can be accessed via port {{ .Values.config.http.bind_address | default 8086 }} on the following DNS name from within your cluster:
InfluxDB can be accessed via port {{ include "influxdb.httpPortNumber" . }} on the following DNS name from within your cluster:

http://{{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.config.http.bind_address | default 8086 }}
http://{{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}:{{ include "influxdb.httpPortNumber" . }}

You can connect to the remote instance with the influx CLI. To forward the API port to localhost:8086, run the following:

kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ include "influxdb.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') 8086:{{ .Values.config.http.bind_address | default 8086 }}
kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ include "influxdb.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') 8086:{{ include "influxdb.httpPortNumber" . }}

You can also connect to the influx CLI from inside the container. To open a shell session in the InfluxDB pod, run the following:

Expand Down
29 changes: 27 additions & 2 deletions charts/influxdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,33 @@ Create the name of the service account to use
*/}}
{{- define "influxdb.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "influxdb.fullname" .) .Values.serviceAccount.name }}
{{ default (include "influxdb.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Define ports for kubernetes.
*/}}
{{- define "influxdb.rpcPortNumber" -}}
{{ default 8088 (regexReplaceAll ":([0-9]+)" (index .Values "config" "rpc" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.metaPortNumber" -}}
{{ default 8091 (regexReplaceAll ":([0-9]+)" (index .Values "config" "meta" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.httpPortNumber" -}}
{{ default 8086 (regexReplaceAll ":([0-9]+)" (index .Values "config" "http" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.graphitePortNumber" -}}
{{ default 2003 (regexReplaceAll ":([0-9]+)" (index .Values "config" "graphite" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.collectdPortNumber" -}}
{{ default 25826 (regexReplaceAll ":([0-9]+)" (index .Values "config" "collectd" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.opentsdbPortNumber" -}}
{{ default 4242 (regexReplaceAll ":([0-9]+)" (index .Values "config" "opentsdb" "bind-address") "${1}") }}
{{- end -}}
{{- define "influxdb.udpPortNumber" -}}
{{ default 8089 (regexReplaceAll ":([0-9]+)" (index .Values "config" "udp" "bind-address") "${1}") }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/influxdb/templates/backup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
- '-c'
- |
influxd backup \
-host {{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}.svc:{{ .Values.config.rpc.bind_address | default 8088 }} \
-host {{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}.svc:{{ include "influxdb.rpcPortNumber" . }} \
-portable /backup/"$(date +%Y%m%d%H%M%S)"
resources:
{{- toYaml .Values.backup.resources | nindent 14 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/influxdb/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
{{- include "influxdb.labels" . | nindent 4 }}
data:
influxdb.conf: |+
reporting-disabled = {{ .Values.config.reporting_disabled | default false }}
bind-address = ":{{ .Values.config.rpc.bind_address | default 8088 }}"
reporting-disabled = {{ .Values.config.reporting_disabled }}
bind-address = "{{ index .Values "config" "rpc" "bind-address"| default (printf ":%s" (include "influxdb.rpcPortNumber" . ))}}"
[meta]
dir = "/var/lib/influxdb/meta"
Expand Down
45 changes: 20 additions & 25 deletions charts/influxdb/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
{{- if .Values.ingress.enabled -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
{{- else }}
apiVersion: networking.k8s.io/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "influxdb.fullname" . }}
labels:
{{- include "influxdb.labels" . | nindent 4 }}
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ .Values.ingress.hostname | quote }}
- {{ .Values.ingress.hostname | quote }}
secretName: {{ .Values.ingress.secretName }}
{{- end }}
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
rules:
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .Values.ingress.path }}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ include "influxdb.fullname" . }}
port:
number: 8086
{{- else }}
serviceName: {{ include "influxdb.fullname" . }}
servicePort: 8086
{{- end }}
{{- end -}}
{{- if .Values.ingress.hostname }}
- host: {{ .Values.ingress.hostname }}
http:
{{- else }}
- http:
{{- end }}
paths:
- path: {{ .Values.ingress.path }}
pathType: Prefix
backend:
service:
name: {{ include "influxdb.fullname" . }}
port:
number: {{ include "influxdb.httpPortNumber" . }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/influxdb/templates/meta-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ metadata:
app.kubernetes.io/component: meta
data:
influxdb-meta.conf: |+
reporting-disabled = {{ .Values.config.reporting_disabled | default false }}
bind-address = ":{{ .Values.config.meta.bind_address | default 8091 }}"
reporting-disabled = {{ .Values.config.reporting_disabled }}
bind-address = "{{ index .Values "config" "meta" "bind-address" | default (printf ":%s" (include "influxdb.metaPortNumber" .))}}"
[enterprise]
license-key = {{ .Values.enterprise.licensekey | quote }}
Expand Down
2 changes: 1 addition & 1 deletion charts/influxdb/templates/meta-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
publishNotReadyAddresses: true
ports:
- name: meta
port: {{ .Values.config.meta.bind_address | default 8091 }}
port: {{ include "influxdb.metaPortNumber" . }}
targetPort: meta
selector:
{{- include "influxdb.selectorLabels" . | nindent 4 }}
Expand Down
6 changes: 3 additions & 3 deletions charts/influxdb/templates/meta-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ spec:
{{ toYaml .Values.enterprise.meta.resources | indent 10 }}
ports:
- name: udp
containerPort: {{ .Values.config.udp.bind_address | default 8089 }}
containerPort: {{ include "influxdb.udpPortNumber" . }}
- name: rpc
containerPort: {{ .Values.config.rpc.bind_address | default 8088 }}
containerPort: {{ include "influxdb.rpcPortNumber" . }}
- name: meta
containerPort: {{ .Values.config.meta.bind_address | default 8091 }}
containerPort: {{ include "influxdb.metaPortNumber" . }}
{{- if .Values.env }}
env:
{{ toYaml .Values.env | indent 10 }}
Expand Down
12 changes: 6 additions & 6 deletions charts/influxdb/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@ spec:
type: {{ .Values.service.type }}
ports:
- name: api
port: {{ .Values.config.http.bind_address | default 8086 }}
port: {{ include "influxdb.httpPortNumber" . }}
targetPort: api
{{- if (and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http))) }}
nodePort: {{ .Values.service.nodePorts.http | int }}
{{- end }}
- name: rpc
port: {{ .Values.config.rpc.bind_address | default 8088 }}
port: {{ include "influxdb.rpcPortNumber" . }}
targetPort: rpc
{{- if .Values.config.graphite.enabled }}
- name: graphite
port: {{ .Values.config.graphite.bind_address | default 2003 }}
port: {{ include "influxdb.graphitePortNumber" . }}
targetPort: graphite
{{- end }}
{{- if .Values.config.collectd.enabled }}
- name: collectd
port: {{ .Values.config.collectd.bind_address | default 25826 }}
port: {{ include "influxdb.collectdPortNumber" . }}
protocol: UDP
targetPort: collectd
{{- end }}
{{- if .Values.config.udp.enabled }}
- name: udp
port: {{ .Values.config.udp.bind_address | default 8089 }}
port: {{ include "influxdb.udpPortNumber" . }}
protocol: UDP
targetPort: udp
{{- end }}
{{- if .Values.config.opentsdb.enabled }}
- name: opentsdb
port: {{ .Values.config.opentsdb.bind_address | default 4242 }}
port: {{ include "influxdb.opentsdbPortNumber" . }}
targetPort: opentsdb
{{- end }}
selector:
Expand Down
16 changes: 9 additions & 7 deletions charts/influxdb/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,30 @@ spec:
{{- end }}
ports:
- name: api
containerPort: {{ .Values.config.http.bind_address | default 8086 }}
containerPort: {{ include "influxdb.httpPortNumber" . }}
{{- if .Values.config.graphite.enabled }}
- name: graphite
containerPort: {{ .Values.config.graphite.bind_address | default 2003 }}
containerPort: {{ include "influxdb.graphitePortNumber" . }}
{{- end }}
{{- if .Values.config.collectd.enabled }}
- name: collectd
containerPort: {{ .Values.config.collectd.bind_address | default 25826 }}
containerPort: {{ include "influxdb.collectdPortNumber" . }}
protocol: UDP
{{- end }}
{{- if .Values.config.udp.enabled }}
- name: udp
containerPort: {{ .Values.config.udp.bind_address | default 8089 }}
containerPort: {{ include "influxdb.udpPortNumber" . }}
protocol: UDP
{{- end }}
{{- if .Values.config.opentsdb.enabled }}
- name: opentsdb
containerPort: {{ .Values.config.opentsdb.bind_address | default 4242 }}
containerPort: {{ include "influxdb.opentsdbPortNumber" . }}
{{- end }}
- name: rpc
containerPort: {{ .Values.config.rpc.bind_address | default 8088 }}
containerPort: {{ include "influxdb.rpcPortNumber" . }}
{{- if .Values.enterprise.enabled }}
- name: meta
containerPort: {{ .Values.config.meta.bind_address | default 8091 }}
containerPort: {{ include "influxdb.metaPortNumber" . }}
{{- end }}
{{- if or .Values.env .Values.setDefaultUser.enabled }}
env:
Expand Down Expand Up @@ -187,10 +187,12 @@ spec:
volumeClaimTemplates:
- metadata:
name: {{ include "influxdb.fullname" . }}-data
{{- if .Values.persistence.annotations }}
annotations:
{{- range $key, $value := .Values.persistence.annotations }}
{{ $key }}: "{{ $value }}"
{{- end }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote}}
Expand Down
17 changes: 10 additions & 7 deletions charts/influxdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ persistence:
## GKE, AWS & OpenStack)
##
# storageClass: "-"
annotations:
annotations: {}
accessMode: ReadWriteOnce
size: 8Gi

Expand Down Expand Up @@ -140,11 +140,10 @@ ingress:
enabled: false
tls: false
# secretName: my-tls-cert # only needed if tls above is true
hostname: influxdb.foobar.com
className: null
hostname: ""
className: nginx
annotations: {}
# kubernetes.io/ingress.class: "nginx"
# kubernetes.io/tls-acme: "true"
# nginx.ingress.kubernetes.io/rewrite-target: $1
path: /


Expand Down Expand Up @@ -204,14 +203,18 @@ envFromSecret: {}
## ref: https://docs.influxdata.com/influxdb/v1.8/administration/config
config:
reporting_disabled: false
rpc: {}
rpc:
bind-address: ":8088"
meta: {}
data: {}
coordinator: {}
retention: {}
shard_precreation: {}
monitor: {}
http: {}
http:
enabled: true
bind-address: ":8086"
flux-enabled: true
logging: {}
subscriber: {}
graphite: {}
Expand Down

0 comments on commit 5151027

Please sign in to comment.