| {{- if .Values.nacos.enabled }} |
| apiVersion: apps/v1 |
| kind: StatefulSet |
| metadata: |
| name: {{ template "nacos.fullname" . }} |
| namespace: {{ template "nacos.namespace" . }} |
| spec: |
| replicas: {{ .Values.replicas }} |
| {{- if eq .Values.global.mode "cluster" }} |
| serviceName: nacos-headless |
| {{- else }} |
| serviceName: nacos |
| {{- end }} |
| selector: |
| matchLabels: {{- include "nacos.matchLabels" . | nindent 6 }} |
| template: |
| metadata: |
| labels: |
| app.kubernetes.io/name: nacos |
| spec: |
| {{- with .Values.nodeSelector }} |
| nodeSelector: |
| {{- toYaml . | nindent 8 }} |
| {{- end }} |
| {{- with .Values.affinity }} |
| affinity: |
| {{- toYaml . | nindent 8 }} |
| {{- end }} |
| {{- with .Values.tolerations }} |
| tolerations: |
| {{- toYaml . | nindent 8 }} |
| {{- end }} |
| {{- if and (eq .Values.nacos.mode "cluster") (.Values.nacos.plugin.enable) }} |
| initContainers: |
| - name: peer-finder-plugin-install |
| image: {{.Values.nacos.plugin.image.repository}}:{{.Values.nacos.plugin.image.tag}} |
| imagePullPolicy: {{ .Values.nacos.plugin.image.pullPolicy }} |
| volumeMounts: |
| - mountPath: /home/nacos/plugins/peer-finder |
| name: data |
| subPath: peer-finder |
| {{- end }} |
| containers: |
| - name: nacos |
| image: "{{ .Values.nacos.image.repository }}:{{ .Values.nacos.image.tag }}" |
| imagePullPolicy: {{ .Values.nacos.image.pullPolicy }} |
| startupProbe: |
| initialDelaySeconds: 180 |
| periodSeconds: 5 |
| timeoutSeconds: 10 |
| httpGet: |
| scheme: HTTP |
| port: {{ .Values.nacos.service.port }} |
| path: /nacos/v1/console/health/readiness |
| livenessProbe: |
| initialDelaySeconds: 10 |
| periodSeconds: 5 |
| timeoutSeconds: 10 |
| httpGet: |
| scheme: HTTP |
| port: {{ .Values.nacos.service.port }} |
| path: /nacos/v1/console/health/liveness |
| ports: |
| - name: http |
| containerPort: {{ .Values.nacos.service.port }} |
| protocol: TCP |
| - containerPort: {{ add .Values.nacos.service.port 1000 }} |
| name: client-rpc |
| - containerPort: {{ add .Values.nacos.service.port 1001 }} |
| name: raft-rpc |
| - containerPort: 7848 |
| name: old-raft-rpc |
| resources: |
| {{- toYaml .Values.resources | nindent 12 }} |
| env: |
| - name: NACOS_SERVER_PORT |
| value: {{ .Values.nacos.service.port | quote }} |
| - name: NACOS_APPLICATION_PORT |
| value: {{ .Values.nacos.service.port | quote }} |
| - name: PREFER_HOST_MODE |
| value: {{ .Values.nacos.service.port | quote }} |
| {{- if eq .Values.nacos.mode "standalone" }} |
| - name: MODE |
| value: "standalone" |
| |
| {{- else if eq .Values.nacos.mode "cluster" }} |
| - name: SERVICE_NAME |
| value: "nacos-hs" |
| - name: DOMAIN_NAME |
| value: {{ .Values.nacos.domainName | quote }} |
| - name: POD_NAMESPACE |
| valueFrom: |
| fieldRef: |
| apiVersion: v1 |
| fieldPath: metadata.namespace |
| {{- end }} |
| {{- if eq .Values.nacos.storage.type "mysql" }} |
| - name: SPRING_DATASOURCE_PLATFORM |
| value: "mysql" |
| - name: MYSQL_SERVICE_HOST |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.db.host |
| - name: MYSQL_SERVICE_DB_NAME |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.db.name |
| - name: MYSQL_SERVICE_PORT |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.port |
| - name: MYSQL_SERVICE_USER |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.user |
| - name: MYSQL_SERVICE_PASSWORD |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.password |
| - name: MYSQL_SERVICE_DB_PARAM |
| valueFrom: |
| configMapKeyRef: |
| name: nacos-cm |
| key: mysql.param |
| {{- else }} |
| - name: EMBEDDED_STORAGE |
| value: embedded |
| {{- end }} |
| volumeMounts: |
| - name: data |
| mountPath: /home/nacos/plugins/peer-finder |
| subPath: peer-finder |
| - name: data |
| mountPath: /home/nacos/data |
| subPath: data |
| - name: data |
| mountPath: /home/nacos/logs |
| subPath: logs |
| {{- if not .Values.persistence.enabled }} |
| volumes: |
| - name: data |
| emptyDir: {} |
| {{- end }} |
| {{- if .Values.persistence.enabled }} |
| volumeClaimTemplates: |
| - metadata: |
| name: data |
| spec: |
| {{- toYaml .Values.nacos.persistence.data | nindent 8 }} |
| {{- end }} |
| {{- end }} |
| |