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
  • 相关阅读:
    centos 7 安装vsftpd
    Goland 使用插件一键发布Docker到线上centos服务器
    Docker alpine 添加bash+修改时区发布镜像到docker.io
    centos 7 nginx 配置Let's Encrypt证书,并自动更新
    centos 7 源码方式安装nginx(1.16.1) + ssl + 阿里证书配置
    centos nginx 卸载
    influxdb time duration literal
    阿里云标准-Redis安全基线检查
    配置systemctl(zookeeper、hadoop、redis)
    【转】Hadoop2.7.7 API: yarn-site.xml 解析
  • 原文地址:https://www.cnblogs.com/vincenshen/p/9030490.html
Copyright © 2011-2022 走看看