Open DonBower opened 3 years ago
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.
172.20.253.78
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:
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
After deploying helm chart in --debug --dry-run mode, the service is rendered:
Which produces the following service:
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:
The following updates to the template templates/web-prometheus-svc.yaml
spec:
section render the proper service yaml code:Here is the result after modifying the template as above, and supplying these values: deployment-values.yml: