summaryrefslogtreecommitdiffstats
path: root/kubernetes/common/music/charts/zookeeper/templates/statefulset.yaml
blob: 580042d090f3997406f67583963c7368715d6500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: {{ template "common.fullname" . }}
  labels:
    app: {{ template "common.name" . }}
    chart: {{ .Chart.Name }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: server
spec:
  podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
    - weight: 1
      podAffinityTerm:
        labelSelector:
          matchExpressions:
            - key: app
              operator: In
              values:
              - "{{ .Chart.Name }}"
  serviceName: {{ template "common.fullname" . }}-headless
  replicas: {{ .Values.replicaCount }}
  terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
  selector:
    matchLabels:
      app: {{ template "common.name" . }}
      release: {{ .Release.Name }}
      component: server
  updateStrategy:
{{ toYaml .Values.updateStrategy | indent 4 }}
  template:
    metadata:
      labels:
        app: {{ template "common.name" . }}
        release: {{ .Release.Name }}
        component: server
      {{- if .Values.podLabels }}
        ## Custom pod labels
        {{- range $key, $value := .Values.podLabels }}
        {{ $key }}: {{ $value | quote }}
        {{- end }}
      {{- end }}
      annotations:
      {{- if .Values.podAnnotations }}
        ## Custom pod annotations
        {{- range $key, $value := .Values.podAnnotations }}
        {{ $key }}: {{ $value | quote }}
        {{- end }}
      {{- end }}
    spec:
{{- if .Values.schedulerName }}
      schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
      securityContext:
{{ toYaml .Values.securityContext | indent 8 }}
      containers:

        - name: zookeeper
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.image.pullPolicy }}
          command:
            - /bin/bash
            - -xec
            - zkGenConfig.sh && exec zkServer.sh start-foreground
          ports:
{{- range $key, $port := .Values.ports }}
            - name: {{ $key }}
{{ toYaml $port | indent 14 }}
{{- end }}
          livenessProbe:
{{ toYaml .Values.livenessProbe | indent 12 }}
          readinessProbe:
{{ toYaml .Values.readinessProbe | indent 12 }}
          env:
            - name: ZK_REPLICAS
              value: {{ .Values.replicaCount | quote }}
          {{- range $key, $value := .Values.env }}
            - name: {{ $key | upper | replace "." "_" }}
              value: {{ $value | quote }}
          {{- end }}
          resources:
{{ include "common.resources" . }}
          volumeMounts:
            - name: {{ include "common.fullname" . }}-data
              mountPath: /var/lib/zookeeper

{{- if .Values.exporters.jmx.enabled }}
        - name: jmx-exporter
          image: "{{ .Values.exporters.jmx.image.repository }}:{{ .Values.exporters.jmx.image.tag }}"
          imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.exporters.jmx.image.pullPolicy }}
          ports:
  {{- range $key, $port := .Values.exporters.jmx.ports }}
            - name: {{ $key }}
{{ toYaml $port | indent 14 }}
  {{- end }}
          livenessProbe:
{{ toYaml .Values.exporters.jmx.livenessProbe | indent 12 }}
          readinessProbe:
{{ toYaml .Values.exporters.jmx.readinessProbe | indent 12 }}
          env:
            - name: SERVICE_PORT
              value: {{ .Values.exporters.jmx.ports.jmxxp.containerPort | quote }}
          {{- with .Values.exporters.jmx.env }}
            {{- range $key, $value := . }}
            - name: {{ $key | upper | replace "." "_" }}
              value: {{ $value | quote }}
            {{- end }}
          {{- end }}
          resources:
{{ toYaml .Values.exporters.jmx.resources | indent 12 }}
          volumeMounts:
            - name: config-jmx-exporter
              mountPath: /opt/jmx_exporter/config.yml
              subPath: config.yml
{{- end }}

{{- if .Values.exporters.zookeeper.enabled }}
        - name: zookeeper-exporter
          image: "{{ .Values.exporters.zookeeper.image.repository }}:{{ .Values.exporters.zookeeper.image.tag }}"
          imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.exporters.zookeeper.image.pullPolicy }}
          args:
            - -bind-addr=:{{ .Values.exporters.zookeeper.ports.zookeeperxp.containerPort }}
            - -metrics-path={{ .Values.exporters.zookeeper.path }}
            - -zookeeper=localhost:{{ .Values.ports.client.containerPort }}
            - -log-level={{ .Values.exporters.zookeeper.config.logLevel }}
            - -reset-on-scrape={{ .Values.exporters.zookeeper.config.resetOnScrape }}
          ports:
  {{- range $key, $port := .Values.exporters.zookeeper.ports }}
            - name: {{ $key }}
{{ toYaml $port | indent 14 }}
  {{- end }}
          livenessProbe:
{{ toYaml .Values.exporters.zookeeper.livenessProbe | indent 12 }}
          readinessProbe:
{{ toYaml .Values.exporters.zookeeper.readinessProbe | indent 12 }}
          env:
          {{- range $key, $value := .Values.exporters.zookeeper.env }}
            - name: {{ $key | upper | replace "." "_" }}
              value: {{ $value | quote }}
          {{- end }}
          resources:
{{ toYaml .Values.exporters.zookeeper.resources | indent 12 }}
{{- end }}

    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
      {{- if (or .Values.exporters.jmx.enabled (not .Values.persistence.enabled)) }}
      volumes:
        {{- if .Values.exporters.jmx.enabled }}
        - name: config-jmx-exporter
          configMap:
            name: {{ .Release.Name }}-jmx-exporter
        {{- end }}
      {{- end }}
  {{- if .Values.persistence.enabled }}
  volumeClaimTemplates:
  - metadata:
      name: {{ include "common.fullname" . }}-data
      labels:
        name: {{ include "common.fullname" . }}
        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
        release: "{{ .Release.Name }}"
        heritage: "{{ .Release.Service }}"
    spec:
      accessModes:
      - {{ .Values.persistence.accessMode | quote }}
      storageClassName: {{ include "common.storageClass" . }}
      resources:
        requests:
          storage: {{ .Values.persistence.size | quote }}
  {{- end }}