This commit is contained in:
zeaslity
2024-10-30 16:30:51 +08:00
commit 437acbeb63
3363 changed files with 653948 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Kubernetes standard labels
*/}}
{{- define "uavcloud-middleware.nacos.labels.standard" -}}
cmii.app: {{ .Values.appName }}
cmii.type: {{ .Values.global.application.type }}
helm.sh/chart: {{ include "uavcloud-middleware.chart" . }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
{{- if $.Values.global.image.tag }}
app.kubernetes.io/version: {{ $.Values.global.image.tag | quote }}
{{- end }}
{{- end -}}
{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "uavcloud-middleware.nacos.labels.matchLabels" -}}
cmii.app: {{ .Values.appName }}
cmii.type: {{ .Values.global.application.type }}
{{- end -}}

View File

@@ -0,0 +1,19 @@
{{- if .Values.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $applicationName }}-cm
namespace: {{ $namespace }}
labels:
{{- include "uavcloud-middleware.nacos.labels.standard" . | nindent 4 }}
data:
mysql.db.name: "{{ .Values.database.db_name }}"
mysql.db.host: "{{ .Values.database.host }}"
mysql.port: "{{ .Values.database.port }}"
mysql.user: "{{ .Values.database.username }}"
mysql.password: "{{ .Values.database.password }}"
---
{{- end }}

View File

@@ -0,0 +1,30 @@
{{- if and .Values.enabled .Values.ingress.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName -}}
{{- $DeployDomainName := ternary (first (regexSplit ":" .Values.global.domain.DeployDomainName -1)) ( .Values.global.domain.DeployDomainName ) (contains ":" .Values.global.domain.DeployDomainName) -}}
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $applicationName }}
namespace: {{ $namespace }}
labels:
{{- include "uavcloud-middleware.nacos.labels.standard" . | nindent 4 }}
spec:
rules:
- host: "nacos.{{ $DeployDomainName }}"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: {{ $applicationName }}
servicePort: {{ .Values.containerPort.dashboard }}
{{- if .Values.global.ingress.tls_enabled }}
tls:
- hosts:
- "nacos.{{ $DeployDomainName }}"
secretName: "x.{{ $DeployDomainName }}-tls"
{{- end }}
---
{{- end }}

View File

@@ -0,0 +1,82 @@
{{- if .Values.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName -}}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $applicationName }}
namespace: {{ $namespace }}
labels:
{{- include "uavcloud-middleware.nacos.labels.standard" . | nindent 4 }}
spec:
serviceName: {{ $applicationName }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "uavcloud-middleware.nacos.labels.matchLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "uavcloud-middleware.nacos.labels.standard" . | nindent 8 }}
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
{{- if .Values.global.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.global.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
{{- /* podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.global.podAffinityPreset "context" $) | nindent 10 -}}*/}}
{{- /* podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.global.podAntiAffinityPreset "context" $) | nindent 10 }}*/}}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.global.nodeAffinityPreset.type "key" .Values.global.nodeAffinityPreset.key "values" .Values.global.nodeAffinityPreset.values) | nindent 10 -}}
{{- end }}
containers:
- name: nacos-server
image: "{{ .Values.global.image.repository | default .Values.image.repository }}/nacos-server:{{ .Values.image.tag }}"
ports:
- containerPort: {{ .Values.containerPort.dashboard }}
name: dashboard
env:
- name: NACOS_AUTH_ENABLE
value: "true"
- name: NACOS_REPLICAS
value: "1"
- name: MYSQL_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: {{ $applicationName }}-cm
key: mysql.db.name
- name: MYSQL_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: {{ $applicationName }}-cm
key: mysql.port
- name: MYSQL_SERVICE_USER
valueFrom:
configMapKeyRef:
name: {{ $applicationName }}-cm
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: {{ $applicationName }}-cm
key: mysql.password
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: {{ $applicationName }}-cm
key: mysql.db.host
- name: NACOS_SERVER_PORT
value: "{{ .Values.containerPort.dashboard }}"
- name: NACOS_APPLICATION_PORT
value: "{{ .Values.containerPort.dashboard }}"
- name: PREFER_HOST_MODE
value: "hostname"
- name: MODE
value: standalone
- name: SPRING_DATASOURCE_PLATFORM
value: mysql
resources:
{{- toYaml .Values.resources | nindent 12 }}
---
{{- end }}

View File

@@ -0,0 +1,24 @@
{{- if .Values.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName -}}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $applicationName }}
namespace: {{ $namespace }}
labels:
{{- include "uavcloud-middleware.nacos.labels.standard" . | nindent 4 }}
spec:
type: {{ .Values.global.middlewareService.type }}
selector:
{{- include "uavcloud-middleware.nacos.labels.matchLabels" . | nindent 4 }}
ports:
- port: {{ .Values.containerPort.dashboard }}
name: server
targetPort: {{ .Values.containerPort.dashboard }}
{{- if eq .Values.global.middlewareService.type "NodePort" }}
nodePort: {{ .Values.nodePort.dashboard }}
{{- end }}
---
{{- end }}