swarm
This commit is contained in:
25
helm/nacos/templates/NOTES.txt
Normal file
25
helm/nacos/templates/NOTES.txt
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
{{- range .paths }}
|
||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services nacos-cs)
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT/nacos
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "nacos.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nacos.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nacos.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl port-forward $POD_NAME 8080:80
|
||||
{{- end }}
|
||||
2. MODE:
|
||||
standalone: you need to modify replicaCount in the values.yaml, .Values.replicaCount=1
|
||||
cluster: kubectl scale sts {{ .Release.Namespace }}-nacos --replicas=3
|
45
helm/nacos/templates/_helpers.tpl
Normal file
45
helm/nacos/templates/_helpers.tpl
Normal file
@ -0,0 +1,45 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "nacos.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "nacos.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "nacos.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "nacos.labels" -}}
|
||||
app.kubernetes.io/name: {{ include "nacos.name" . }}
|
||||
helm.sh/chart: {{ include "nacos.chart" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
18
helm/nacos/templates/configmap.yaml
Normal file
18
helm/nacos/templates/configmap.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
{{- if eq .Values.nacos.storage.type "mysql"}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nacos-cm
|
||||
data:
|
||||
{{- with .Values.nacos.storage.db }}
|
||||
mysql.db.host: {{.host}}
|
||||
mysql.db.name: {{ .name }}
|
||||
mysql.port: "{{ .port | default 3306}}"
|
||||
mysql.user: {{ .username }}
|
||||
mysql.password: {{ .password }}
|
||||
mysql.param: {{ .param | default "characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
|
149
helm/nacos/templates/deployment.yaml
Normal file
149
helm/nacos/templates/deployment.yaml
Normal file
@ -0,0 +1,149 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "nacos.fullname" . }}
|
||||
annotations:
|
||||
{{- toYaml .Values.annotations | indent 4 }}
|
||||
spec:
|
||||
{{- if eq .Values.global.mode "cluster" }}
|
||||
serviceName: nacos-hs
|
||||
{{- else }}
|
||||
serviceName: nacos-cs
|
||||
{{- end }}
|
||||
replicas: {{ .Values.nacos.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ include "nacos.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ include "nacos.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
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.nacos.plugin.enable) }}
|
||||
initContainers:
|
||||
- name: peer-finder-plugin-install
|
||||
image: {{.Values.nacos.plugin.image.repository}}:{{.Values.nacos.plugin.image.tag}}
|
||||
imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- mountPath: /home/nacos/plugins/peer-finder
|
||||
name: data
|
||||
subPath: peer-finder
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.nacos.image.repository }}:{{ .Values.nacos.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.nacos.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.nacos.serverPort }}
|
||||
protocol: TCP
|
||||
- containerPort: {{ add .Values.nacos.serverPort 1000}}
|
||||
name: client-rpc
|
||||
- containerPort: {{ add .Values.nacos.serverPort 1001 }}
|
||||
name: raft-rpc
|
||||
- containerPort: 7848
|
||||
name: old-raft-rpc
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
env:
|
||||
- name: NACOS_SERVER_PORT
|
||||
value: {{ .Values.nacos.serverPort | quote }}
|
||||
- name: NACOS_APPLICATION_PORT
|
||||
value: {{ .Values.nacos.serverPort | quote }}
|
||||
- name: PREFER_HOST_MODE
|
||||
value: {{ .Values.nacos.preferhostmode | quote }}
|
||||
{{- if eq .Values.global.mode "standalone" }}
|
||||
- name: MODE
|
||||
value: "standalone"
|
||||
|
||||
{{- else if eq .Values.global.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}}
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: {{ .Values.nacos.serverPort }}
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: {{ .Values.nacos.serverPort }}
|
||||
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.persistence.data | nindent 8 }}
|
||||
{{- end }}
|
||||
|
36
helm/nacos/templates/ingress.yaml
Normal file
36
helm/nacos/templates/ingress.yaml
Normal file
@ -0,0 +1,36 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "nacos.fullname" . -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{ include "nacos.labels" . | indent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ . }}
|
||||
backend:
|
||||
serviceName: nacos-cs
|
||||
servicePort: http
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
62
helm/nacos/templates/service.yaml
Normal file
62
helm/nacos/templates/service.yaml
Normal file
@ -0,0 +1,62 @@
|
||||
{{- if and (eq .Values.global.mode "cluster") }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "nacos.fullname" . }}
|
||||
annotations:
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.nacos.serverPort }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
- port: {{ add .Values.service.port 1000}}
|
||||
name: client-rpc
|
||||
targetPort: {{add .Values.nacos.serverPort 1000}}
|
||||
- port: {{add .Values.service.port 1001}}
|
||||
name: raft-rpc
|
||||
targetPort: {{add .Values.nacos.serverPort 1001}}
|
||||
## 兼容1.4.x版本的选举端口
|
||||
- port: 7848
|
||||
name: old-raft-rpc
|
||||
targetPort: 7848
|
||||
protocol: TCP
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "nacos.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nacos-cs
|
||||
labels:
|
||||
{{- toYaml .Values.service.labels | nindent 4 }}
|
||||
annotations:
|
||||
{{- toYaml .Values.service.annotations | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.nacos.serverPort }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
- port: {{ add .Values.service.port 1000}}
|
||||
name: client-rpc
|
||||
targetPort: {{add .Values.nacos.serverPort 1000}}
|
||||
- port: {{add .Values.service.port 1001}}
|
||||
name: raft-rpc
|
||||
targetPort: {{add .Values.nacos.serverPort 1001}}
|
||||
## 兼容1.4.x版本的选举端口
|
||||
- port: 7848
|
||||
name: old-raft-rpc
|
||||
targetPort: 7848
|
||||
protocol: TCP
|
||||
{{- if eq .Values.service.type "NodePort" }}
|
||||
nodePort: {{ .Values.service.nodePort }}
|
||||
{{- end }}
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "nacos.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
Reference in New Issue
Block a user