cluster

Infrastructure files for Nordgedanken and Midnightthoughts.
git clone git://archive.git.mtrnord.blog/MTRNord/cluster.git
Log | Files | Refs | README

mysql.yaml (2952B)


      1 apiVersion: apps/v1
      2 kind: StatefulSet
      3 metadata:
      4   name: mysql
      5   namespace: blog
      6 spec:
      7   serviceName: "mysql"
      8   replicas: 1
      9   selector:
     10     matchLabels:
     11       app: mysql
     12   template:
     13     metadata:
     14       labels:
     15         app: mysql
     16     spec:
     17       automountServiceAccountToken: false
     18       securityContext:
     19         fsGroup: 999
     20       containers:
     21         - name: mysql
     22           image: mariadb:12.0
     23           securityContext:
     24             allowPrivilegeEscalation: false
     25             readOnlyRootFilesystem: false
     26             runAsNonRoot: true
     27             runAsUser: 999
     28             runAsGroup: 999
     29             capabilities:
     30               drop:
     31                 - ALL
     32             seccompProfile:
     33               type: RuntimeDefault
     34           env:
     35             - name: MARIADB_ROOT_PASSWORD
     36               valueFrom:
     37                 secretKeyRef:
     38                   name: mysql-cred
     39                   key: admin-password
     40             - name: MARIADB_USER
     41               valueFrom:
     42                 secretKeyRef:
     43                   name: mysql-cred
     44                   key: username
     45             - name: MARIADB_PASSWORD
     46               valueFrom:
     47                 secretKeyRef:
     48                   name: mysql-cred
     49                   key: password
     50             - name: MARIADB_DATABASE
     51               valueFrom:
     52                 secretKeyRef:
     53                   name: mysql-cred
     54                   key: db-name
     55             - name: MYSQL_ROOT_HOST
     56               value: "%"
     57           volumeMounts:
     58             - name: mysql-volume
     59               mountPath: /var/lib/mysql
     60             - name: mysql-configmap
     61               mountPath: /docker-entrypoint-initdb.d
     62             - name: mysql-config
     63               mountPath: /etc/mysql/conf.d
     64           resources:
     65             requests:
     66               memory: "256Mi"
     67               cpu: "100m"
     68             limits:
     69               memory: "1024Mi"
     70               cpu: "600m"
     71           livenessProbe:
     72             tcpSocket:
     73               port: 3306
     74             initialDelaySeconds: 30
     75             periodSeconds: 10
     76             timeoutSeconds: 5
     77             successThreshold: 1
     78             failureThreshold: 3
     79           readinessProbe:
     80             tcpSocket:
     81               port: 3306
     82             initialDelaySeconds: 30
     83             periodSeconds: 10
     84             timeoutSeconds: 5
     85             successThreshold: 1
     86             failureThreshold: 3
     87       volumes:
     88         - name: mysql-configmap
     89           configMap:
     90             name: mysql-configmap
     91         - name: mysql-config
     92           configMap:
     93             name: mysql-config
     94   volumeClaimTemplates:
     95     - metadata:
     96         name: mysql-volume
     97       spec:
     98         accessModes: ["ReadWriteOnce"]
     99         storageClassName: "longhorn"
    100         resources:
    101           requests:
    102             storage: 2Gi
    103 ---
    104 apiVersion: v1
    105 kind: Service
    106 metadata:
    107   name: mysql-service
    108   namespace: blog
    109 spec:
    110   type: ClusterIP
    111   selector:
    112     app: mysql
    113   ports:
    114     - protocol: TCP
    115       port: 3306
    116       targetPort: 3306