内容来源于官方 Longhorn 1.1.2 英文技术手册。

系列

目录

  • Block volume(块卷)
  • CSI persistent volume(CSI 持久卷)
  • Deployment(部署)
  • Pod with PersistentVolumeClaim(带有持久卷声明的 Pod)
  • Restore to file(恢复到文件)
  • Simple Pod(简单 Pod)
  • Simple PersistentVolumeClaim(简单持久卷声明)
  • StatefulSet
  • StorageClass

Block Volume(块卷)

    apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-block-vol
spec:
accessModes:
- ReadWriteOnce
volumeMode: Block
storageClassName: longhorn
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Pod
metadata:
name: block-volume-test
namespace: default
spec:
containers:
- name: block-volume-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
volumeDevices:
- devicePath: /dev/longhorn/testblk
name: block-vol
ports:
- containerPort: 80
volumes:
- name: block-vol
persistentVolumeClaim:
claimName: longhorn-block-vol

CSI Persistent Volume(CSI 持久卷)

    apiVersion: v1
kind: PersistentVolume
metadata:
name: longhorn-vol-pv
spec:
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: longhorn
csi:
driver: driver.longhorn.io
fsType: ext4
volumeAttributes:
numberOfReplicas: '3'
staleReplicaTimeout: '2880'
volumeHandle: existing-longhorn-volume
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-vol-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
volumeName: longhorn-vol-pv
storageClassName: longhorn
---
apiVersion: v1
kind: Pod
metadata:
name: volume-pv-test
namespace: default
spec:
restartPolicy: Always
containers:
- name: volume-pv-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- ls
- /data/lost+found
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 4
volumeMounts:
- name: vol
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: vol
persistentVolumeClaim:
claimName: longhorn-vol-pvc

Deployment(部署)

    apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
selector:
matchLabels:
app: mysql # has to match .spec.template.metadata.labels
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
restartPolicy: Always
containers:
- image: mysql:5.6
name: mysql
livenessProbe:
exec:
command:
- ls
- /var/lib/mysql/lost+found
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 4
env:
- name: MYSQL_ROOT_PASSWORD
value: changeme
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-volume
mountPath: /var/lib/mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "rancher"
volumes:
- name: mysql-volume
persistentVolumeClaim:
claimName: mysql-pvc

Pod with PersistentVolumeClaim(带有持久卷声明的 Pod)

    apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-volv-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Pod
metadata:
name: volume-test
namespace: default
spec:
restartPolicy: Always
containers:
- name: volume-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- ls
- /data/lost+found
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 4
volumeMounts:
- name: volv
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: volv
persistentVolumeClaim:
claimName: longhorn-volv-pvc

Restore to file(恢复到文件)

    apiVersion: v1
kind: Pod
metadata:
name: restore-to-file
namespace: longhorn-system
spec:
nodeName: <NODE_NAME>
containers:
- name: restore-to-file
command:
# set restore-to-file arguments here
- /bin/sh
- -c
- longhorn backup restore-to-file
'<BACKUP_URL>'
--output-file '/tmp/restore/<OUTPUT_FILE>'
--output-format <OUTPUT_FORMAT>
# the version of longhorn engine should be v0.4.1 or higher
image: longhorn/longhorn-engine:v0.4.1
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
volumeMounts:
- name: disk-directory
mountPath: /tmp/restore # the argument <output-file> should be in this directory
env:
# set Backup Target Credential Secret here.
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: <S3_SECRET_NAME>
key: AWS_ACCESS_KEY_ID
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: <S3_SECRET_NAME>
key: AWS_SECRET_ACCESS_KEY
- name: AWS_ENDPOINTS
valueFrom:
secretKeyRef:
name: <S3_SECRET_NAME>
key: AWS_ENDPOINTS
volumes:
# the output file can be found on this host path
- name: disk-directory
hostPath:
path: /tmp/restore
restartPolicy: Never

Simple Pod(简单 Pod)

    apiVersion: v1
kind: Pod
metadata:
name: longhorn-simple-pod
namespace: default
spec:
restartPolicy: Always
containers:
- name: volume-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- ls
- /data/lost+found
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 4
volumeMounts:
- name: volv
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: volv
persistentVolumeClaim:
claimName: longhorn-simple-pvc

Simple PersistentVolumeClaim(简单持久卷声明)

    apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-simple-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 1Gi

StatefulSet

    apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
selector:
app: nginx
type: NodePort
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labels
serviceName: "nginx"
replicas: 2 # by default is 1
template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabels
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
livenessProbe:
exec:
command:
- ls
- /usr/share/nginx/html/lost+found
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 4
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "longhorn"
resources:
requests:
storage: 1Gi

StorageClass

    kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: longhorn
provisioner: driver.longhorn.io
allowVolumeExpansion: true
parameters:
numberOfReplicas: "3"
staleReplicaTimeout: "2880" # 48 hours in minutes
fromBackup: ""
# diskSelector: "ssd,fast"
# nodeSelector: "storage,fast"
# fsType: "ext4"
# recurringJobs: '[
# {
# "name":"snap",
# "task":"snapshot",
# "cron":"*/1 * * * *",
# "retain":1
# },
# {
# "name":"backup",
# "task":"backup",
# "cron":"*/2 * * * *",
# "retain":1,
# "labels": {
# "interval":"2m"
# }
# }
# ]'

请注意,只有 ext4 文件系统支持在卷意外分离后(detached unexpectedly)自动重新挂载。

Longhorn,企业级云原生容器分布式存储 - K8S 资源配置示例的更多相关文章

  1. Longhorn,企业级云原生容器分布式存储 - 监控(Prometheus+AlertManager+Grafana)

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  2. Longhorn,企业级云原生容器分布式存储 - 备份与恢复

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  3. Longhorn,企业级云原生容器分布式存储 - 高可用

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  4. Longhorn,企业级云原生容器分布式存储 - 支持 ReadWriteMany (RWX) 工作负载(实验性功能)

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  5. Longhorn,企业级云原生容器分布式存储 - 定制默认设置

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  6. Longhorn 企业级云原生容器存储解决方案-部署篇

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生分布式块存储解决方案设计架构和概念 安装 Longhorn 可以通过多种方式安装 ...

  7. Longhorn 云原生容器分布式存储 - Air Gap 安装

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  8. Longhorn 云原生容器分布式存储 - Python Client

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  9. Longhorn 云原生容器分布式存储 - 故障排除指南

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

随机推荐

  1. leetcode TOP100 字母异位词分组

    字母异位词分组 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 思路: 一个map,将每个字符串字符进行记数,字符作为map的key,次数初始为零,以此来标识字 ...

  2. 使用Flyway来管理数据库版本

    使用Flyway来管理数据库版本 Flyway是什么 Flyway是一款数据库迁移(migration)工具. 它可以帮助我们在不同环境保持数据库的同步,减少手工操作,避免数据导入的顺序错误,同时也减 ...

  3. cke编辑器插入&ZeroWidthSpace占位字符的问题记录

    背景 本博文主要记录在使用cke编辑器时,遇到的一系列的问题 问题1:在执行某些业务操作后,编辑器会偶现在页面头部或者尾部插入&ZeroWidthSpace占位符(编辑器好像就爱干这事~) 解 ...

  4. .Net Core微服务——服务发现:Consul(一)

    先思考一些问题:它是做什么的.以及怎么使用它.带着这些问题往下走. consul是做什么的 consul用于微服务下的服务治理.服务治理是什么?它包含但不限于:服务发现.服务配置.健康检查.键值存储. ...

  5. C语言:常用数学函数

    #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> # ...

  6. Java集合Stream类filter的使用

    之前的Java集合中removeIf的使用一文写了使用removeIf来实现按条件对集合进行过滤.这篇文章使用同样是JDK1.8新加入的Stream中filter方法来实现同样的效果.并且在实际项目中 ...

  7. 一个很多人不知道的SpringBoot小技能!!

    大家好,我是冰河~~ 最近,发现很多小伙伴在修改了SpringBoot的配置文件后,都要重新编译整个项目,极大的浪费了开发时间.我身边就有很多小伙伴一直是这样做的.那么,有没有什么方式能够修改配置文件 ...

  8. 【学习笔记】Tensor多维数组和axis的理解

    Tensor多维数组和axis的理解 今天在编写程序的时候一直对于axis=0或等于1搞不明白,这样对于整个numpy或者是tensorflow的基本运算和数据处理都会很模糊,所以花了一些时间来搞清楚 ...

  9. 【Mysql】InnoDB 中的 B+ 树索引

    接上一篇内容,InnoDB 的作者想到一种更灵活的方式来管理所有目录项,是什么? 一.目录项记录页 其实这些用户目录项与用户记录很像,只是目录项中的两个列记录的是主键和页号而已,那么就可以复用之前存储 ...

  10. vue组件之间通信总结(超详细)

    组件通信在我们平时开发过程中,特别是在vue和在react中,有着举足轻重的地位.本篇将总结在vue中,组件之间通信的几种方式: props.$emit $parent.$children $attr ...