Last active
October 31, 2021 04:53
-
-
Save barkbay/789d53755abefc0ad718258bab7bed43 to your computer and use it in GitHub Desktop.
EC2 NVME Local Storage Provisioner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: storage.k8s.io/v1 | |
kind: StorageClass | |
metadata: | |
name: local-storage | |
provisioner: kubernetes.io/no-provisioner | |
volumeBindingMode: WaitForFirstConsumer | |
reclaimPolicy: Delete | |
mountOptions: | |
- noatime | |
- nodiratime | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: local-provisioner-config | |
namespace: default | |
data: | |
setPVOwnerRef: "true" | |
useNodeNameOnly: "true" | |
storageClassMap: | | |
local-storage: | |
hostDir: /pv-disks | |
mountDir: /pv-disks | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: setup-disks | |
data: | |
entrypoint.sh: |- | |
#!/bin/sh | |
echo "Creating /pv-disks" | |
## TODO: List all disks on the host | |
mkdir -p /pv-disks | |
ln -sf /dev/nvme1n1 /pv-disks | |
--- | |
apiVersion: apps/v1 | |
kind: DaemonSet | |
metadata: | |
name: local-volume-provisioner | |
namespace: default | |
labels: | |
app: local-volume-provisioner | |
spec: | |
selector: | |
matchLabels: | |
app: local-volume-provisioner | |
template: | |
metadata: | |
labels: | |
app: local-volume-provisioner | |
spec: | |
#nodeSelector: | |
# Update the selector to match nodes holding NVMe disks | |
#beta.kubernetes.io/instance-type: c5d.xlarge | |
serviceAccountName: local-storage-admin | |
initContainers: | |
- name: install | |
image: busybox | |
securityContext: | |
privileged: true | |
command: | |
- "/bin/entrypoint.sh" | |
volumeMounts: | |
- mountPath: /bin/entrypoint.sh | |
name: setup-disks | |
subPath: entrypoint.sh | |
- mountPath: /pv-disks | |
name: local-storage | |
mountPropagation: Bidirectional | |
containers: | |
- image: "quay.io/external_storage/local-volume-provisioner:v2.3.3" | |
imagePullPolicy: "Always" | |
name: provisioner | |
securityContext: | |
privileged: true | |
env: | |
- name: MY_NODE_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: spec.nodeName | |
volumeMounts: | |
- mountPath: /etc/provisioner/config | |
name: provisioner-config | |
readOnly: true | |
- mountPath: /dev | |
name: provisioner-dev | |
- mountPath: /pv-disks | |
name: local-storage | |
mountPropagation: Bidirectional | |
- mountPath: /bin/entrypoint.sh | |
name: setup-disks | |
subPath: entrypoint.sh | |
volumes: | |
- name: provisioner-dev | |
hostPath: | |
path: /dev | |
- name: provisioner-config | |
configMap: | |
name: local-provisioner-config | |
- name: local-storage | |
hostPath: | |
path: /pv-disks | |
- name: setup-disks | |
configMap: | |
defaultMode: 0700 | |
name: setup-disks | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: local-storage-admin | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: local-storage-provisioner-pv-binding | |
namespace: default | |
subjects: | |
- kind: ServiceAccount | |
name: local-storage-admin | |
namespace: default | |
roleRef: | |
kind: ClusterRole | |
name: system:persistent-volume-provisioner | |
apiGroup: rbac.authorization.k8s.io | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
name: local-storage-provisioner-node-clusterrole | |
rules: | |
- apiGroups: [""] | |
resources: ["nodes"] | |
verbs: ["get"] | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: local-storage-provisioner-node-binding | |
namespace: default | |
subjects: | |
- kind: ServiceAccount | |
name: local-storage-admin | |
namespace: default | |
roleRef: | |
kind: ClusterRole | |
name: local-storage-provisioner-node-clusterrole | |
apiGroup: rbac.authorization.k8s.io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment