zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    HDU3145 Max Sum of Max-K-sub-sequence (单调队列模板)
    AcWing1088 旅行问题(单调队列)
    POJ1821 Fence(单调队列)
    POJ1742 Coins(多重背包+二进制优化)
    AcWing217 绿豆蛙的归宿(期望)
    BZOJ.2134.[国家集训队]单选错位(概率 递推)
    洛谷.3805.[模板]manacher算法
    Codeforces.280C.Game on Tree(期望)
    BZOJ.2521.[SHOI2010]最小生成树(最小割ISAP/Dinic)
    洛谷.4172.[WC2006]水管局长(LCT Kruskal)
  • 原文地址:https://www.cnblogs.com/vincenshen/p/9030490.html
Copyright © 2011-2022 走看看