zoukankan      html  css  js  c++  java
  • Centos7 k8s tomcat-app项目持久化

    一、概念

      PV(Persistent Volume):相当于定义一个存储资源池

      PVC(Persistent Volume Claim):分配给谁用

      1、master端安装共享存储nfs服务器

    [root@k8s-node2 ~]# yum install nfs_utils.x86_64 -y
    [root@k8s-master ~]# vim /etc/exports
    /data  192.0.0.0/24(rw,async,no_root_squash,no_all__squash)
    [root@k8s-master ~]# systemctl restart rpcbind
    [root@k8s-master ~]# systemctl restart nfs
    
    
    使用帮助文档
    man no_root_sq
    然后搜索
    /no_root_sq 

       2、创建配置文件

    [root@k8s-master ~]# vim tomcat-mysql_pv.yaml
    apiVersion: v1 kind: PersistentVolume metadata: name: tomcat labels: type: tomcat spec: capacity: storage: 10Gi accessModes:
    - ReadWriteMany persistentVolumeReclaimPolicy: Recycle nfs: path: "/data/tomcat" server: 192.168.125.130 readOnly: false

      3、创建PV

    [root@k8s-master ~]# kubectl create -f tomcat-mysql_pv.yaml 
    persistentvolume "tomcat" created
    [root@k8s-master ~]# kubectl get pv
    NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE
    tomcat 10Gi RWX Recycle Available 3m

      4、创建PVC配置文件

    [root@k8s-master ~]# vim tomcat-mysql_pvc.yaml 
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: tomcat
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 10Gi

      5、创建pvc

    [root@k8s-master ~]# kubectl create -f tomcat-mysql_pvc.yaml 
    persistentvolumeclaim "tomcat" created
    [root@k8s-master ~]# kubectl get pv
    NAME      CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS    CLAIM            REASON    AGE
    tomcat    10Gi       RWX           Recycle         Bound     default/tomcat             5h
    [root@k8s-master ~]# 

      6、上传镜像

    [root@k8s-master ~]# docker  pull mysql:5.7
    [root@k8s-master ~]# docker tag docker.io/mysql:5.7 192.168.125.130:5000/mysql:5.7
    [root@k8s-master ~]# docker push 192.168.125.130:5000/mysql:5.7

      7、创建配置文件

    [root@k8s-master ~]# vim tomcat-mysql-dep.yaml 
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: mysql
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
          - name: mysql
            image: 192.168.125.130:5000/mysql:5.7
            ports:
            - containerPort: 3306
            volumeMounts:
            - name: tomcat-mysql
              mountPath: /var/lib/mysql
    
            env:
            - name: MYSQL_ROOT_PASSWORD
              value: '123456'
          volumes:
          - name: tomcat-mysql
            persistentVolumeClaim:
              claimName: tomcat

      8、执行命令

    [root@k8s-master ~]# kubectl apply -f tomcat-mysql-dep.yaml 
    deployment "mysql" created

    [root@k8s-master ~]# ls /data/tomcat/            查看目录下面是否有数据库的东西,有代表做成功

  • 相关阅读:
    自定义ProgressBar
    Anroid开发中常用快捷键
    Intent用法
    IO(Input Output)流
    自定义Dialog
    仿UC点击两次返回键退出程序
    横竖屏切换时Activity的生命周期
    单例模式
    Timer用法
    关于数组
  • 原文地址:https://www.cnblogs.com/aqicheng/p/13099641.html
Copyright © 2011-2022 走看看