Skip to content

Commit

Permalink
Change example deployment scheme in multi-node cluster
Browse files Browse the repository at this point in the history
Current scheme does not work in multi-node cluster because
my-csi-app pod may land on different node than other pods
and mount point is not there.
This commit changes deployment so that there is one
instance of csi-hostpathplugin, and we use inter-pod affinity
to land attacher, provisioner, hostpathplugin and my-csi-appi
on a same node.
  • Loading branch information
okartau committed Feb 25, 2019
1 parent fd2e591 commit 09418e8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $ kubectl get pods
NAME READY STATUS RESTARTS AGE
csi-hostpath-attacher-0 1/1 Running 0 5m47s
csi-hostpath-provisioner-0 1/1 Running 0 5m47s
csi-hostpathplugin-lzzlc 2/2 Running 0 5m45s
csi-hostpathplugin-0 2/2 Running 0 5m45s
```

From the root directory, deploy the application pods including a storage class, a PVC, and a pod which mounts a volume using the Hostpath driver found in directory `./examples`:
Expand Down
10 changes: 10 additions & 0 deletions deploy/hostpath/csi-hostpath-attacher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ spec:
labels:
app: csi-hostpath-attacher
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- csi-hostpathplugin
topologyKey: kubernetes.io/hostname
serviceAccountName: csi-attacher
containers:
- name: csi-attacher
Expand Down
3 changes: 2 additions & 1 deletion deploy/hostpath/csi-hostpath-plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
kind: DaemonSet
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: csi-hostpathplugin
spec:
serviceName: "csi-hostpathplugin"
selector:
matchLabels:
app: csi-hostpathplugin
Expand Down
10 changes: 10 additions & 0 deletions deploy/hostpath/csi-hostpath-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ spec:
labels:
app: csi-hostpath-provisioner
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- csi-hostpathplugin
topologyKey: kubernetes.io/hostname
serviceAccountName: csi-provisioner
containers:
- name: csi-provisioner
Expand Down
12 changes: 11 additions & 1 deletion examples/csi-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ apiVersion: v1
metadata:
name: my-csi-app
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- csi-hostpathplugin
topologyKey: kubernetes.io/hostname
containers:
- name: my-frontend
image: busybox
Expand All @@ -13,4 +23,4 @@ spec:
volumes:
- name: my-csi-volume
persistentVolumeClaim:
claimName: csi-pvc # defined in csi-pvs.yaml
claimName: csi-pvc # defined in csi-pvs.yaml

0 comments on commit 09418e8

Please sign in to comment.