concourse / concourse/concourse-chart

templates do not render usable concourse-web-prometheus service

Open
#213 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
160
Forks
189
PR merge metrics
No merged PRs in 30d

Description

After deploying helm chart in --debug --dry-run mode, the service is rendered:

---
# Source: concourse/templates/web-prometheus-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: concourse-web-prometheus
  labels:
    app: concourse-web
    chart: "concourse-14.0.3"
    release: "concourse"
    heritage: "Helm"
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "9391"
spec:
  type: ClusterIP
  ports:
    - name: prometheus
      port: 9391
      targetPort: prometheus
  selector:
    app: concourse-web

Which produces the following service:

kubectl get services
NAME                            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
concourse-postgresql            ClusterIP   None             <none>        5432/TCP         44h
concourse-postgresql-headless   ClusterIP   None             <none>        5432/TCP         44h
concourse-web                   NodePort    172.20.250.183   <none>        8080:30001/TCP   19m
concourse-web-prometheus        ClusterIP   172.20.253.78    <none>        9391/TCP         10m
concourse-web-worker-gateway    NodePort    172.20.115.171   <none>        2222:30002/TCP   44h
concourse-worker                ClusterIP   None             <none>        <none>           44h
kubernetes                      ClusterIP   172.20.0.1       <none>        443/TCP          2d

However a loadbalancer cannot be connected to the ClusterIP 172.20.253.78, because it's on a non-routable network.

Instead the templates need to be able to render a NodePort service, such as:

---
# Source: concourse/prometheus-svc.yml
apiVersion: v1
kind: Service
metadata:
  name: concourse-web-prometheus
  labels:
    app: concourse-web
    chart: "concourse-14.0.3"
    release: "concourse"
    heritage: "Helm"
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "9391"
spec:
  type: NodePort
  ports:
  - name: prometheus
    port: 9391
    targetPort: prometheus
    nodePort: 30003
  selector:
    app: concourse-web

The following updates to the template templates/web-prometheus-svc.yaml spec: section render the proper service yaml code:

spec:
  type: {{ .Values.web.service.prometheus.type }}
  {{- if .Values.web.service.prometheus.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
    {{- range .Values.web.service.prometheus.loadBalancerSourceRanges }}
    - {{ . }}
    {{- end }}
  {{- end }}
  {{- if and (eq "ClusterIP" .Values.web.service.prometheus.type) .Values.web.service.prometheus.clusterIP }}
  clusterIP: {{ .Values.web.service.prometheus.clusterIP }}
  {{- end }}
  {{- if and (eq "LoadBalancer" .Values.web.service.prometheus.type) .Values.web.service.prometheus.loadBalancerIP }}
  loadBalancerIP: {{ .Values.web.service.prometheus.loadBalancerIP }}
  {{- end }}
  ports:
  - name: prometheus
    port: {{ .Values.concourse.web.prometheus.bindPort }}
    targetPort: prometheus
    {{- if and (eq "NodePort" .Values.web.service.prometheus.type) .Values.web.service.prometheus.NodePort }}
    nodePort: {{ .Values.web.service.prometheus.NodePort}}
    {{- end }}
  selector:
    app: {{ template "concourse.web.fullname" . }}

Here is the result after modifying the template as above, and supplying these values:
deployment-values.yml:

web:
  replicas: 3
  service:
    api:
      type: NodePort
      atcNodePort: 30008
      NodePort: 30001
    workerGateway:
      type: NodePort
      NodePort: 30002
    prometheus:
      type: NodePort
      NodePort: 30003
kubectl get services
NAME                            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
concourse-postgresql            ClusterIP   None             <none>        5432/TCP         45h
concourse-postgresql-headless   ClusterIP   None             <none>        5432/TCP         45h
concourse-web                   NodePort    172.20.250.183   <none>        8080:30001/TCP   71m
concourse-web-prometheus        NodePort    172.20.152.48    <none>        9391:30003/TCP   11s
concourse-web-worker-gateway    NodePort    172.20.115.171   <none>        2222:30002/TCP   45h
concourse-worker                ClusterIP   None             <none>        <none>           45h
kubernetes                      ClusterIP   172.20.0.1       <none>        443/TCP          2d1h

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with templates/web-prometheus-svc.yaml and the web.service.prometheus values used by the Helm chart. Run a --debug --dry-run deployment with the provided NodePort values and compare the rendered service with the expected YAML. Done means the Prometheus service can render as a NodePort with the requested nodePort while retaining the existing ClusterIP behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes, yaml
Domain
devops, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.