| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- {{/*
- Base service template
- */}}
- {{- define "base.service" -}}
- apiVersion: v1
- kind: Service
- metadata:
- name: {{ .Values.app.name }}
- labels:
- app: {{ .Values.app.name }}
- spec:
- type: {{ .Values.service.type }}
- ports:
- - port: {{ .Values.service.port }}
- targetPort: http
- protocol: TCP
- name: http
- selector:
- app: {{ .Values.app.name }}
- {{- if .Values.service.dubbo_port }}
- ---
- # Headless Service for Dubbo RPC
- apiVersion: v1
- kind: Service
- metadata:
- name: {{ .Values.app.name }}-dubbo
- labels:
- app: {{ .Values.app.name }}
- spec:
- type: ClusterIP
- clusterIP: None # Headless Service
- ports:
- - port: {{ .Values.service.dubbo_port }}
- targetPort: dubbo
- protocol: TCP
- name: dubbo
- selector:
- app: {{ .Values.app.name }}
- {{- end }}
- {{- end }}
- {{/*
- Base deployment template
- */}}
- {{- define "base.deployment" -}}
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: {{ .Values.app.name }}
- labels:
- app: {{ .Values.app.name }}
- spec:
- revisionHistoryLimit: {{ .Values.revisionHistoryLimit | default 3 }}
- replicas: {{ .Values.replicaCount | default 1 }}
- selector:
- matchLabels:
- app: {{ .Values.app.name }}
- template:
- metadata:
- labels:
- app: {{ .Values.app.name }}
- spec:
- containers:
- - name: {{ .Values.app.name }}
- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
- imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
- ports:
- - containerPort: {{ .Values.service.targetPort | default 8080 }}
- name: http
- protocol: TCP
- {{- if .Values.service.dubbo_port }}
- - containerPort: {{ .Values.service.dubbo_port }}
- name: dubbo
- protocol: TCP
- {{- end }}
- {{- if .Values.livenessProbe }}
- livenessProbe:
- httpGet:
- path: {{ .Values.livenessProbe.path | default "/actuator/health" }}
- port: {{ .Values.service.targetPort | default 8080 }}
- initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds | default 30 }}
- periodSeconds: {{ .Values.livenessProbe.periodSeconds | default 10 }}
- {{- end }}
- {{- if .Values.readinessProbe }}
- readinessProbe:
- httpGet:
- path: {{ .Values.readinessProbe.path | default "/actuator/health" }}
- port: {{ .Values.service.targetPort | default 8080 }}
- initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds | default 10 }}
- periodSeconds: {{ .Values.readinessProbe.periodSeconds | default 5 }}
- {{- end }}
- resources:
- limits:
- cpu: {{ .Values.resources.limits.cpu | default "500m" }}
- memory: {{ .Values.resources.limits.memory | default "512Mi" }}
- requests:
- cpu: {{ .Values.resources.requests.cpu | default "250m" }}
- memory: {{ .Values.resources.requests.memory | default "256Mi" }}
- volumeMounts:
- - name: config-volume
- mountPath: /etc/config
- env:
- - name: SPRING_CLOUD_NACOS_DISCOVERY_SERVER_ADDR
- value: "nacos.bak.com:8848"
- - name: SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR
- value: "nacos.bak.com:8848"
- {{- if .Values.service.dubbo_port }}
- - name: DUBBO_PROTOCOL_PORT
- value: "{{ .Values.service.dubbo_port }}"
- - name: DUBBO_REGISTRY_ADDRESS
- value: "nacos://nacos.bak.com:8848?namespace=public"
- {{- end }}
- volumes:
- - name: config-volume
- configMap:
- name: {{ .Values.app.name }}-config
- {{- end }}
- {{/*
- Base ConfigMap template
- */}}
- {{- define "base.configmap" -}}
- apiVersion: v1
- kind: ConfigMap
- metadata:
- name: {{ .Values.app.name }}-config
- labels:
- app: {{ .Values.app.name }}
- data:
- application.yml: |
- {{ .Values.config.yml | toYaml | indent 4 }}
- {{- end }}
|