Skip to content

Instantly share code, notes, and snippets.

@surajssd
Last active February 6, 2020 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surajssd/a43c76d3226ea1f5869c8b86952f407b to your computer and use it in GitHub Desktop.
Save surajssd/a43c76d3226ea1f5869c8b86952f407b to your computer and use it in GitHub Desktop.

Deploy Local storage provisioner

To test the issue with /mnt in kubelet in Lokomotive kinvolk-archives/lokomotive-kubernetes#160.

Add following flag to apiserver, kube-controller-manager, kube-scheduler

- --feature-gates=BlockVolume=true

Run following commands to edit the configs:

kubectl -n kube-system edit ds kube-apiserver
kubectl -n kube-system edit deploy kube-controller-manager
kubectl -n kube-system edit deploy kube-scheduler

And to add the flag to kubelet this is what you should add:

--feature-gates=BlockVolume=true \

Add that using following command:

kubectl -n kube-system edit ds kubelet

Create volumes on each host. By running following command:

sudo -i
mkdir /mnt/disks
for vol in vol1 vol2 vol3; do
    mkdir /mnt/disks/$vol
    mount -t tmpfs $vol /mnt/disks/$vol
done

Deploy the provisioner:

kubectl apply -f deployment/kubernetes/example/default_example_storageclass.yaml
kubectl create ns static-provisioner

Use following values file

common:
  namespace: static-provisioner
  podSecurityPolicy: true

classes:
- name: fast-disks # Defines name of storage classe.
  hostDir: /mnt/disks
  volumeMode: Filesystem
  fsType: tmpfs
  blockCleanerCommand:
     - "/scripts/shred.sh"
     - "2"
helm template --values custom-values.yaml ./helm/provisioner/ | k apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: privileged-psp-default
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-psp
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:serviceaccounts:default
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labels
serviceName: "nginx"
replicas: 3 # by default is 1
template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "fast-disks"
resources:
requests:
storage: 1Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment