Yylzhangahupdate file
9175c74a创建于 2025年10月10日历史提交
{{- if .Values.authhub.mysql.enabled -}}
---
apiVersion: v1
kind: Service
metadata:
  name: mysql-db
  namespace: {{ .Release.Namespace }}
spec:
  type: {{ default "ClusterIP" .Values.authhub.mysql.service.type }}
  selector:
    app: mysql
  ports:
    - port: 3306
      targetPort: 3306
      nodePort: {{ default nil .Values.authhub.mysql.service.nodePort }}

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deploy
  namespace: {{ .Release.Namespace }}
  labels:
    app: mysql
spec:
  replicas: {{ default 1 .Values.globals.replicaCount }}
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/mysql/mysql-config.yaml") . | sha256sum }}
      labels:
        app: mysql
    spec:
      automountServiceAccountToken: false
      containers:
        - name: mysql
          image: {{ .Values.authhub.mysql.image | default (printf "%s/neocopilot/mysql:8-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (.Values.globals.arch | default "x86")) }}
          imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }}
          args:
            - "--character-set-server=utf8mb4"
            - "--collation-server=utf8mb4_unicode_ci"
          ports:
            - containerPort: 3306
              protocol: TCP
          livenessProbe:
            exec:
              command:
                - sh
                - -c
                - mysqladmin -h 127.0.0.1 -u $MYSQL_USER --password=$MYSQL_PASSWORD ping
            failureThreshold: 5
            initialDelaySeconds: 60
            periodSeconds: 90
          env:
            - name: TZ
              value: "Asia/Shanghai"
            - name: MYSQL_USER
              value: "authhub"
            - name: MYSQL_RANDOM_ROOT_PASSWORD
              value: "yes"
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: authhub-secret
                  key: mysql-password
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: mysql-data
            - mountPath: /docker-entrypoint-initdb.d/init.sql
              name: mysql-init
              subPath: init.sql
          resources:
            requests:
              cpu: 0.1
              memory: 384Mi
            limits:
              {{ toYaml .Values.authhub.mysql.resourceLimits | nindent 14 }}
      restartPolicy: Always
      volumes:
        - name: mysql-data
          persistentVolumeClaim:
            claimName: mysql-pvc
        - name: mysql-init
          configMap:
            name: mysql-config
{{- end -}}