blob: 95e27faa4430adea495bf5d66a51820b3bc93eee [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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.global.mode "cluster") (.Values.plugin.enable) }}
initContainers:
- name: peer-finder-plugin-install
image: {{.Values.plugin.image.repository }}:{{.Values.plugin.image.tag }}
imagePullPolicy: {{ .Values.plugin.image.pullPolicy }}
volumeMounts:
- mountPath: /home/nacos/plugins/peer-finder
name: data
subPath: peer-finder
{{- end }}
containers:
- name: nacos
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
startupProbe:
initialDelaySeconds: 180
periodSeconds: 5
timeoutSeconds: 10
httpGet:
scheme: HTTP
port: {{ .Values.service.port }}
path: /nacos/v1/console/health/readiness
livenessProbe:
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 10
httpGet:
scheme: HTTP
port: {{ .Values.service.port }}
path: /nacos/v1/console/health/liveness
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
- containerPort: {{ add .Values.service.port 1000 }}
name: clientgen-rpc
- containerPort: {{ add .Values.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.service.port | quote }}
- name: NACOS_APPLICATION_PORT
value: {{ .Values.service.port | quote }}
- name: PREFER_HOST_MODE
value: {{ .Values.service.port | quote }}
{{- if eq .Values.global.mode "standalone" }}
- name: MODE
value: "standalone"
{{- else if eq .Values.global.mode "cluster" }}
- name: SERVICE_NAME
value: "nacos-headless"
- name: DOMAIN_NAME
value: {{ .Values.domainName | quote }}
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
{{- end }}
{{- if eq .Values.storage.type "mysql" }}
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: nacos-configmap
key: mysql.db.host
- name: MYSQL_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: nacos-configmap
key: mysql.db.name
- name: MYSQL_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-configmap
key: mysql.port
- name: MYSQL_SERVICE_USER
valueFrom:
configMapKeyRef:
name: nacos-configmap
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: nacos-configmap
key: mysql.password
- name: MYSQL_SERVICE_DB_PARAM
valueFrom:
configMapKeyRef:
name: nacos-configmap
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:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{ if .Values.persistence.ClaimName }}
claimName: {{ .Values.persistence.ClaimName }}
{{- else -}}
emptyDir: {{ .Values.persistence.emptyDir }}
{{- end }}
{{- end }}