add local storage example

pull/992/head
gjmzj 2021-01-13 22:24:47 +08:00
parent 73bedd7c37
commit 3a03ae67db
5 changed files with 87 additions and 0 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ bin/*
# k8s storage manifests # k8s storage manifests
manifests/storage/* manifests/storage/*
!manifests/storage/test.yaml !manifests/storage/test.yaml
!manifests/storage/local-storage/
# role based variable settings, exclude roles/os-harden/vars/ # role based variable settings, exclude roles/os-harden/vars/
#/roles/*/vars/* #/roles/*/vars/*

View File

@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: local-test
spec:
serviceName: ""
replicas: 2
selector:
matchLabels:
app: local-test
template:
metadata:
labels:
app: local-test
spec:
containers:
- name: test-container
image: busybox
command:
- "/bin/sh"
args:
- "-c"
- "sleep 100000"
volumeMounts:
- name: local-vol
mountPath: /usr/test-pod
volumeClaimTemplates:
- metadata:
name: local-vol
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "local-storage"
resources:
requests:
storage: 5Gi

View File

@ -0,0 +1,23 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv1
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /mnt/disks/vol1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- 192.168.1.2
- 192.168.1.3

View File

@ -0,0 +1,22 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv2
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /mnt/disks/vol2
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- 192.168.1.4

View File

@ -0,0 +1,6 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer