我已经为具有 mysql 后端数据库的 mysql 企业监控应用程序编写了自己的 dockerfile。所以,我希望 pod 内的数据目录能够持续存在。我已将数据目录挂载到一个卷上。但是,当我进入我的 pod 并检查数据目录时,数据目录中没有文件。我观察到的是它正在覆盖已经存在的数据目录。
下面是我的dockerfile
FROM centos:7
ENV DIR /binaries
ENV PASS admin
WORKDIR ${DIR}
COPY libstdc++-4.8.5-39.el7.x86_64.rpm ${DIR}
COPY numactl-libs-2.0.12-3.el7.x86_64.rpm ${DIR}
COPY mysqlmonitor-8.0.18.1217-linux-x86_64-installer.bin ${DIR}
RUN yum install -y libaio && yum -y install gcc && yum -y install gcc-c++ && yum -y install compat-libstdc++-33 && yum -y install libstdc++-devel && yum -y install elfutils-libelf-devel && yum -y install glibc-devel && yum -y install libaio-devel && yum -y install sysstat
RUN yum install -y gcc && yum install -y make && yum install -y apr-devel && yum install -y openssl-devel && yum install -y java
RUN rpm -ivh numactl-libs-2.0.12-3.el7.x86_64.rpm
RUN useradd sql
RUN chown sql ${DIR}
RUN chmod 777 ${DIR}
RUN chmod 755 /home/sql
USER sql
WORKDIR ${DIR}
RUN ./mysqlmonitor-8.0.18.1217-linux-x86_64-installer.bin --installdir /home/sql/mysql/enterprise/monitor --mode unattended --tomcatport 18080 --tomcatsslport 18443 --adminpassword ### --dbport 13306
RUN rm -rf /binaries/*
VOLUME /home/sql/mysql/enterprise/monitor/mysql/data
ENTRYPOINT ["/bin/bash", "-c", "/home/sql/mysql/enterprise/monitor/mysqlmonitorctl.sh start && tail -f /home/sql/mysql/enterprise/monitor/apache-tomcat/logs/mysql-monitor.log"]
下面是我在 ibm-kubernetes-service 中部署的 yaml 片段
Deployment yaml file
apiVersion: apps/v1
kind: Deployment
metadata:
name: mypod
spec:
replicas: 1
selector:
matchLabels:
app: mem
template:
metadata:
labels:
app: mem
spec:
containers:
- name: mem
image: 22071997/mem
command:
volumeMounts:
- mountPath: /home/sql/mysql/enterprise/mysql/data
name: data-volume
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: mem-pvc
输出:
[sql@mypod-67cb4f85b8-9km26 data]$ pwd
/home/sql/mysql/enterprise/mysql/data
[sql@mypod-67cb4f85b8-9km26 data]$ ls
[sql@mypod-67cb4f85b8-9km26 data]$
提前感谢您帮助我:)