From e1a731dc679cf6188f07dbc53adebe9241779684 Mon Sep 17 00:00:00 2001 From: portdirect Date: Sat, 3 Mar 2018 22:31:10 -0500 Subject: [PATCH] Gnocchi: use endpoints section and lookups to set port This PS moves gnocchi to use the endpoints section and lookups to set the port it serves on. Change-Id: I509d2324d9d063bc382baa4c7676ef415de99907 --- gnocchi/templates/configmap-etc.yaml | 8 ++++++++ gnocchi/templates/daemonset-statsd.yaml | 2 +- gnocchi/templates/deployment-api.yaml | 4 ++-- gnocchi/templates/etc/_wsgi-gnocchi.conf.tpl | 4 ++-- gnocchi/templates/service-api.yaml | 2 +- gnocchi/templates/service-statsd.yaml | 7 ++++--- gnocchi/values.yaml | 21 ++++++++++++++++++-- 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/gnocchi/templates/configmap-etc.yaml b/gnocchi/templates/configmap-etc.yaml index 4f804796b2..ef42d8c15e 100644 --- a/gnocchi/templates/configmap-etc.yaml +++ b/gnocchi/templates/configmap-etc.yaml @@ -75,6 +75,14 @@ limitations under the License. {{- uuidv4 | set .Values.conf.gnocchi.statsd "project_id" | quote | trunc 0 -}} {{- end -}} +{{- if empty .Values.conf.gnocchi.api.port -}} +{{- tuple "metric" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set .Values.conf.gnocchi.api "port" | quote | trunc 0 -}} +{{- end -}} + +{{- if empty .Values.conf.gnocchi.statsd.port -}} +{{- tuple "metric_statsd" "internal" "statsd" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set .Values.conf.gnocchi.statsd "port" | quote | trunc 0 -}} +{{- end -}} + {{- $envAll := . }} --- apiVersion: v1 diff --git a/gnocchi/templates/daemonset-statsd.yaml b/gnocchi/templates/daemonset-statsd.yaml index c79aa252f7..a43cd470a4 100644 --- a/gnocchi/templates/daemonset-statsd.yaml +++ b/gnocchi/templates/daemonset-statsd.yaml @@ -67,7 +67,7 @@ spec: - /tmp/gnocchi-statsd.sh ports: - name: gn-stats - containerPort: {{ .Values.conf.gnocchi.statsd.port }} + containerPort: {{ tuple "metric_statsd" "internal" "statsd" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} volumeMounts: - name: pod-etc-gnocchi mountPath: /etc/gnocchi diff --git a/gnocchi/templates/deployment-api.yaml b/gnocchi/templates/deployment-api.yaml index 6a093d014b..a0bb647950 100644 --- a/gnocchi/templates/deployment-api.yaml +++ b/gnocchi/templates/deployment-api.yaml @@ -79,10 +79,10 @@ spec: - stop ports: - name: gn-api - containerPort: {{ .Values.conf.gnocchi.api.port }} + containerPort: {{ tuple "metric" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} readinessProbe: tcpSocket: - port: {{ .Values.conf.gnocchi.api.port }} + port: {{ tuple "metric" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} volumeMounts: - name: pod-etc-gnocchi mountPath: /etc/gnocchi diff --git a/gnocchi/templates/etc/_wsgi-gnocchi.conf.tpl b/gnocchi/templates/etc/_wsgi-gnocchi.conf.tpl index 597a615c74..dd45c05d06 100644 --- a/gnocchi/templates/etc/_wsgi-gnocchi.conf.tpl +++ b/gnocchi/templates/etc/_wsgi-gnocchi.conf.tpl @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */}} -Listen 0.0.0.0:{{ .Values.conf.gnocchi.api.port }} +Listen 0.0.0.0:{{ tuple "metric" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded CustomLog /dev/stdout combined env=!forwarded CustomLog /dev/stdout proxy env=forwarded - + WSGIDaemonProcess gnocchi processes=1 threads=2 user=gnocchi group=gnocchi display-name=%{GROUP} WSGIProcessGroup gnocchi WSGIScriptAlias / "/var/lib/kolla/venv/lib/python2.7/site-packages/gnocchi/rest/app.wsgi" diff --git a/gnocchi/templates/service-api.yaml b/gnocchi/templates/service-api.yaml index 16ff31c8fa..ece07cca6e 100644 --- a/gnocchi/templates/service-api.yaml +++ b/gnocchi/templates/service-api.yaml @@ -24,7 +24,7 @@ metadata: spec: ports: - name: gn-api - port: {{ .Values.conf.gnocchi.api.port }} + port: {{ tuple "metric" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} {{ if .Values.network.api.node_port.enabled }} nodePort: {{ .Values.network.api.node_port.port }} {{ end }} diff --git a/gnocchi/templates/service-statsd.yaml b/gnocchi/templates/service-statsd.yaml index bbba851cc7..4cf65c371f 100644 --- a/gnocchi/templates/service-statsd.yaml +++ b/gnocchi/templates/service-statsd.yaml @@ -20,15 +20,16 @@ limitations under the License. apiVersion: v1 kind: Service metadata: - name: gnocchi-statsd + name: {{ tuple "metric_statsd" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} spec: ports: - - port: {{ .Values.conf.gnocchi.statsd.port }} + - name: gn-stats + port: {{ tuple "metric_statsd" "internal" "statsd" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} {{ if .Values.network.statsd.node_port.enabled }} nodePort: {{ .Values.network.statsd.node_port.port }} {{ end }} selector: - app: gnocchi-statsd +{{ tuple $envAll "gnocchi" "statsd" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ if .Values.network.statsd.node_port.enabled }} type: NodePort {{ end }} diff --git a/gnocchi/values.yaml b/gnocchi/values.yaml index 0ca9a2d0ad..da75683e67 100644 --- a/gnocchi/values.yaml +++ b/gnocchi/values.yaml @@ -331,9 +331,13 @@ conf: provider: uuid api: auth_mode: keystone - port: 8041 + #NOTE(portdirect): the bind port should not be defined, and is manipulated + # via the endpoints section. + port: null statsd: - port: 8125 + #NOTE(portdirect): the bind port should not be defined, and is manipulated + # via the endpoints section. + port: null metricd: workers: 1 database: @@ -427,6 +431,19 @@ endpoints: api: default: 8041 public: 80 + metric_statsd: + name: gnocchi-statsd + hosts: + default: gnocchi-statsd + host_fqdn_override: + default: null + path: + default: null + scheme: + default: null + port: + statsd: + default: 8125 oslo_db_postgresql: auth: admin: