Created
June 27, 2018 17:37
-
-
Save ncdc/39d5a59d5484501c7b2cf67642bc5b0c to your computer and use it in GitHub Desktop.
Kubernetes NFS provisioner setup
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
kind: StorageClass | |
apiVersion: storage.k8s.io/v1 | |
metadata: | |
name: example-nfs | |
provisioner: example.com/nfs | |
parameters: | |
gid: "1001" | |
rootSquash: "false" | |
mountOptions: "vers=4.1" |
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
kind: ClusterRole | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: nfs-provisioner-runner | |
rules: | |
- apiGroups: [""] | |
resources: ["persistentvolumes"] | |
verbs: ["get", "list", "watch", "create", "delete"] | |
- apiGroups: [""] | |
resources: ["persistentvolumeclaims"] | |
verbs: ["get", "list", "watch", "update"] | |
- apiGroups: ["storage.k8s.io"] | |
resources: ["storageclasses"] | |
verbs: ["get", "list", "watch"] | |
- apiGroups: [""] | |
resources: ["events"] | |
verbs: ["list", "watch", "create", "update", "patch"] | |
- apiGroups: [""] | |
resources: ["services", "endpoints"] | |
verbs: ["get"] | |
- apiGroups: ["extensions"] | |
resources: ["podsecuritypolicies"] | |
resourceNames: ["nfs-provisioner"] | |
verbs: ["use"] |
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
kind: ClusterRoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: run-nfs-provisioner | |
namespace: default | |
subjects: | |
- kind: ServiceAccount | |
name: nfs-provisioner | |
namespace: default | |
# update namespace above to your namespace in order to make this work | |
roleRef: | |
kind: ClusterRole | |
name: nfs-provisioner-runner | |
apiGroup: rbac.authorization.k8s.io |
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
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: nfs-provisioner | |
labels: | |
app: nfs-provisioner | |
spec: | |
ports: | |
- name: nfs | |
port: 2049 | |
- name: mountd | |
port: 20048 | |
- name: rpcbind | |
port: 111 | |
- name: rpcbind-udp | |
port: 111 | |
protocol: UDP | |
selector: | |
app: nfs-provisioner | |
--- | |
kind: Deployment | |
apiVersion: extensions/v1beta1 | |
metadata: | |
name: nfs-provisioner | |
spec: | |
replicas: 1 | |
strategy: | |
type: Recreate | |
template: | |
metadata: | |
labels: | |
app: nfs-provisioner | |
spec: | |
serviceAccount: nfs-provisioner | |
containers: | |
- name: nfs-provisioner | |
image: quay.io/kubernetes_incubator/nfs-provisioner:v1.0.9 | |
ports: | |
- name: nfs | |
containerPort: 2049 | |
- name: mountd | |
containerPort: 20048 | |
- name: rpcbind | |
containerPort: 111 | |
- name: rpcbind-udp | |
containerPort: 111 | |
protocol: UDP | |
securityContext: | |
capabilities: | |
add: | |
- DAC_READ_SEARCH | |
- SYS_RESOURCE | |
args: | |
- "-provisioner=example.com/nfs" | |
env: | |
- name: POD_IP | |
valueFrom: | |
fieldRef: | |
fieldPath: status.podIP | |
- name: SERVICE_NAME | |
value: nfs-provisioner | |
- name: POD_NAMESPACE | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.namespace | |
imagePullPolicy: "IfNotPresent" | |
volumeMounts: | |
- name: export-volume | |
mountPath: /export | |
volumes: | |
- name: export-volume | |
emptyDir: {} |
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
kind: Pod | |
apiVersion: v1 | |
metadata: | |
name: test | |
spec: | |
securityContext: | |
runAsUser: 1000 | |
supplementalGroups: | |
- 1001 | |
containers: | |
- name: test | |
image: gcr.io/google_containers/busybox:1.24 | |
command: | |
- "/bin/sh" | |
args: | |
- "-c" | |
- "sleep 3600" | |
volumeMounts: | |
- name: nfs-pvc | |
mountPath: "/mnt" | |
restartPolicy: "Never" | |
volumes: | |
- name: nfs-pvc | |
persistentVolumeClaim: | |
claimName: nfs |
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
kind: PersistentVolumeClaim | |
apiVersion: v1 | |
metadata: | |
name: nfs | |
spec: | |
storageClassName: "example-nfs" | |
accessModes: | |
- ReadWriteMany | |
resources: | |
requests: | |
storage: 1Mi |
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: v1 | |
kind: ServiceAccount | |
metadata: | |
name: nfs-provisioner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment