helm案例之模块meng-backend(三)

韵味老鸟 2024-07-06 17:19:12

helm案例之模块meng-backend(三)

#service.yaml

{{- if .Values.service.enabled -}}apiVersion: v1kind: Servicemetadata: name: {{ include "meng.fullname" . }} labels: {{- include "meng.labels" . | nindent 4 }}spec: type: {{ .Values.service.type }} ports: {{- if eq .Values.service.type "NodePort" }} {{- range .Values.service.ports }} - port: {{ .port }} targetPort: {{ .targetPort }} protocol: {{ .protocol }} name: {{ .name }} {{- with .nodePort }} nodePort: {{ . }} {{- end }} {{- end }} {{- else }} {{- range .Values.service.ports }} - port: {{ .port }} targetPort: {{ .targetPort }} protocol: {{ .protocol }} name: {{ .name }} {{- end }} {{- end }} #if NodePort selector: {{- include "meng.selectorLabels" . | nindent 4 }}{{- end }}

#deployment.yaml

{{- if eq .Values.controller.type "deployment" -}}apiVersion: apps/v1kind: Deploymentmetadata: name: {{ include "meng.fullname" . }} labels: {{- include "meng.labels" . | nindent 4 }}spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} selector: matchLabels: {{- include "meng.selectorLabels" . | nindent 6 }} template: metadata: #values-xx.yaml配置中配置了controller控制节 {{- with .Values.controller.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "meng.selectorLabels" . | nindent 8 }} spec: #harbor仓库账号信息 {{- with .Values.controller.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "meng.serviceAccountName" . }} securityContext: {{- toYaml .Values.controller.podSecurityContext | nindent 8 }} containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.controller.securityContext | nindent 12 }} #镜像,在helm更新时替换tag image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.controller.image.pullPolicy }} #环境变量,with表示如有该值,限制范围循环 {{- with .Values.controller.envs }} env: {{- range .Values.controller.envs }} - name: {{ .name }} value: {{ .value }} {{- end }} {{- end }} #端口信息 ports: {{- range .Values.service.ports }} - name: {{ .name }} containerPort: {{ .port }} protocol: {{ .protocol }} {{- end }} #存活检测 {{- if .Values.controller.livenessProbe.enabled }} livenessProbe: initialDelaySeconds: {{ .Values.controller.livenessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.controller.livenessProbe.periodSeconds }} timeoutSeconds: {{ .Values.controller.livenessProbe.timeoutSeconds }} successThreshold: {{ .Values.controller.livenessProbe.successThreshold }} failureThreshold: {{ .Values.controller.livenessProbe.failureThreshold }} tcpSocket: port: http {{- end }} #就绪检测 {{- if .Values.controller.readinessProbe.enabled }} readinessProbe: initialDelaySeconds: {{ .Values.controller.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.controller.readinessProbe.periodSeconds }} timeoutSeconds: {{ .Values.controller.readinessProbe.timeoutSeconds }} successThreshold: {{ .Values.controller.readinessProbe.successThreshold }} failureThreshold: {{ .Values.controller.readinessProbe.failureThreshold }} tcpSocket: port: http {{- end }} #资源限制 resources: {{- toYaml .Values.controller.resources | nindent 12 }} #挂载点 {{- with .Values.controller.volumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} #节点选择 {{- with .Values.controller.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} #亲和性 {{- with .Values.controller.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} #容忍性 {{- with .Values.controller.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} #挂载卷 {{- with .Values.controller.volumes }} volumes: {{- toYaml . | nindent 8 }} {{- end }}{{- end }}

0 阅读:0