• Kubernetes Storage


    参考文章:

    https://kubernetes.io/docs/concepts/storage/volumes/

    https://www.cnblogs.com/styshoo/p/6731425.html

    容器中的磁盘文件是短暂的,这为在容器中运行重要的应用程序带来了一些问题。

    第一 当容器崩溃时,Kubelet将会重启容器,这时候数据文件就会丢失。

    第二 在同一个Pod中的容器通常需要共享数据。

    Kubernetes使用Volume抽象解决了这两个问题。  

    Kubernetes supports several types of Volumes:

    • awsElasticBlockStore
    • azureDisk
    • azureFile
    • cephfs
    • configMap
    • csi
    • downwardAPI
    • emptyDir
    • fc (fibre channel)
    • flocker
    • gcePersistentDisk
    • gitRepo
    • glusterfs
    • hostPath
    • iscsi
    • local
    • nfs
    • persistentVolumeClaim
    • projected
    • portworxVolume
    • quobyte
    • rbd
    • scaleIO
    • secret
    • storageos
    • vsphereVolume

    NFS PersistentVolume

    前提条件:搭建NFS服务器,K8s node安装nfs客户端

    pv-yaml

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: nginx-data
    spec:
      capacity:
        storage: 1Gi
      accessModes:
        - ReadWriteMany
      nfs:
        path: /nfs-data
        server: 172.16.65.200
      persistentVolumeReclaimPolicy: Recycle
    View Code

    pvc-yaml

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: nginx-data
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 1Gi
    View Code

    deployment-yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-web
    spec:
      replicas: 3
      selector:
        matchLabels:
          name: nginx-web
      template:
        metadata:
          labels:
            name: nginx-web
        spec:
          containers:
          - name: nginx-web
            image: nginx
            volumeMounts:
            - mountPath: /usr/share/nginx/html
              name: nginx-data
            ports:
            - containerPort: 80
          volumes:
          - name: nginx-data
            persistentVolumeClaim:
              claimName: nginx-data
    View Code

    service-yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx-service
    spec:
      selector:
        name: nginx-web
      type: NodePort
      ports:
      - port: 80
        protocol: TCP
        targetPort: 80
        name: http
        nodePort: 30080
    View Code
  • 相关阅读:
    hdu Boring counting
    hdu Connections between cities
    hdu Median Filter
    hdu Entropy
    hdu Box Relations
    未能加载数据集 加载DataSet错误
    SqlServer中的datetime类型的空值和c#中的DateTime的空值的研究
    Spread.NET中文开发文档汇总
    ChartDirector资料小结
    AmCharts图表JavaScript Charts参数
  • 原文地址:https://www.cnblogs.com/vincenshen/p/9030490.html
Copyright © 2020-2023  润新知