繁体   English   中英

Mysql 容器未在 Kubernetes 上启动

[英]Mysql container not starting up on Kubernetes

我正在使用图像在docker-compose中运行我的应用程序。 但是,当我在 Kubernetes 集群上运行相同的程序时,我得到了错误

[ERROR] Could not open file '/opt/bitnami/mysql/logs/mysqld.log' for error logging: Permission denied

这是我的部署文件

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.21.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: common-db
  name: common-db
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: common-db
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert
        kompose.version: 1.21.0 ()
      creationTimestamp: null
      labels:
        io.kompose.service: common-db
    spec:
      containers:
      - env:
        - name: ALLOW_EMPTY_PASSWORD
          value: "yes"
        - name: MYSQL_DATABASE
          value: "common-development"
        - name: MYSQL_REPLICATION_MODE
          value: "master"
        - name: MYSQL_REPLICATION_PASSWORD
          value: "repl_password"
        - name: MYSQL_REPLICATION_USER
          value: "repl_user"
        image: bitnami/mysql:5.7
        imagePullPolicy: ""
        name: common-db
        ports:
        - containerPort: 3306
        securityContext:
          runAsUser: 0
        resources:
          requests:
            memory: 512Mi
            cpu: 500m
          limits:
            memory: 512Mi
            cpu: 500m
        volumeMounts:
          - name: common-db-initdb
            mountPath: /opt/bitnami/mysql/conf/my_custom.cnf
      volumes:
        - name: common-db-initdb
          configMap:
            name: common-db-config
      serviceAccountName: ""

status: {}

配置 map 具有配置my.cnf数据。 关于我可能出错的地方的任何指示? 特别是如果相同的图像适用于docker-compose

尝试使用init container更改文件权限,就像在官方 bitnami helm 图表中一样,他们还在更新文件权限和管理安全上下文。

舵图: https://github.com/bitnami/charts/blob/master/bitnami/mysql/templates/master-statefulset.yaml

更新

 initContainers:
      - command:
        - /bin/bash
        - -ec
        - |
          chown -R 1001:1001 /bitnami/mysql
        image: docker.io/bitnami/minideb:buster
        imagePullPolicy: Always
        name: volume-permissions
        resources: {}
        securityContext:
          runAsUser: 0
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /bitnami/mysql
          name: data
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 1001
        runAsUser: 1001
      serviceAccount: mysql

您可能需要使用子路径。 要了解有关子路径的详细信息,请单击此处

volumeMounts:
  - name: common-db-initd
    mountPath: /opt/bitnami/mysql/conf/my_custom.cnf
    subPath: my_custom.cnf

此外,您可以使用 helm chart轻松安装 bitnami mysql。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM