zoukankan      html  css  js  c++  java
  • kubernetes存储

    kubernetes4种存储:

    kubernetes-configMap:存储配置文件

    kubernetes-secret:加密信息(密码,用户名密码信息)

    kubernetes-volume:给pod提供共享存储服务

    kubernetes-persistent volume:PV,PVC持久卷

    [root@k8s-master01 ~]# cd /usr/local/
    aegis/        etc/          install-k8s/  libexec/      src/          
    bin/          games/        lib/          sbin/         
    cloudmonitor/ include/      lib64/        share/        
    [root@k8s-master01 ~]# cd /usr/local/install-k8s/
    [root@k8s-master01 install-k8s]# ll
    total 8
    drwxr-xr-x 2 root root 4096 Jul 10 00:50 core
    drwxr-xr-x 4 root root 4096 Jul 30 13:39 plugin
    [root@k8s-master01 install-k8s]# mkdir volume
    [root@k8s-master01 install-k8s]# cd volume/
    [root@k8s-master01 volume]# ll
    total 0
    [root@k8s-master01 volume]# vim em.yaml
    [root@k8s-master01 volume]# kubectl apply -f em.yaml 
    pod/test-pd created
    [root@k8s-master01 volume]# kubectl get pod
    NAME      READY   STATUS    RESTARTS   AGE
    test-pd   1/1     Running   0          14s
    [root@k8s-master01 volume]# 
    [root@k8s-master01 volume]# kubectl exec test-pd -it -- /bin/sh
    / # cd /cache/
    /cache # ll
    /bin/sh: ll: not found
    /cache # ls
    /cache # [root@k8s-master01 volume]# vim em.yaml 
    [root@k8s-master01 volume]# kubectl exec test-pd(pod名称) -c test-container(容器名称) -it -- /bin/sh
    apiVersion: v1
    kind: Pod
    metadata:
      name: test-pd
    spec:
      containers:
      - image: hub.msjfkg.com/library/myapp:v1
        name: test-container
        volumeMounts:
        - mountPath: /cache #不同的目录共享一个volume
          name: cache-volume
      - name: liveness-exec-container
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh","-c","sleep 6000s"]
        volumeMounts:
        - mountPath: /test
          name: cache-volume
      volumes:
      - name: cache-volume
        emptyDir: {}

    同一个pod下进入不同容器的方式:
    [root@k8s-master01 volume]# kubectl exec test-pd -c test-container -it -- /bin/sh

     hostPath 

    除了所需的path属性之外,用户还可以为hostPath卷指定type

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-pd
    spec:
      containers:
      - image: k8s.gcr.io/test-webserver
        name: test-container
        volumeMounts:
        - mountPath: /test-pd
          name: test-volume
      volumes:
      - name: test-volume
        hostPath:
          # directory location on host
          path: /data
          # this field is optional
          type: Directory
    
    容器中的/test-pd目录共享到本机的/data目录下
    

      

  • 相关阅读:
    算法题之丢手绢问题
    Java接口成员变量和方法默认修饰符
    清空select下拉框的方法
    Java基础数据类型的默认值
    JVM内存区域划分
    Java中匿名内部类
    Java值传递
    部署web Service到tomcat
    Tomcat环境下配置数据源
    遇到和需要解决的问题
  • 原文地址:https://www.cnblogs.com/tian880820/p/13404861.html
Copyright © 2011-2022 走看看