Skip to content

Commit

Permalink
kubeadm: add NFS storage class tests
Browse files Browse the repository at this point in the history
This deploys an NFS storage class and tests that we can deploy a pod
consuming this storage using NFS vers 4.2 mounting options.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Nov 9, 2023
1 parent 6d15b29 commit 6c88fd6
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
32 changes: 32 additions & 0 deletions kola/tests/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,38 @@ func kubeadmBaseTest(c cluster.TestCluster, params map[string]interface{}) {
}
})

c.Run("NFS deployment", func(c cluster.TestCluster) {
if _, err := c.SSH(kubectl, "/opt/bin/helm repo add nfs-ganesha-server-and-external-provisioner https://kubernetes-sigs.github.io/nfs-ganesha-server-and-external-provisioner/"); err != nil {
c.Fatalf("unable to add helm NFS repo: %v", err)
}

if _, err := c.SSH(kubectl, "/opt/bin/helm install nfs-server-provisioner nfs-ganesha-server-and-external-provisioner/nfs-server-provisioner --set 'storageClass.mountOptions={nfsvers=4.2}'"); err != nil {
c.Fatalf("unable to install NFS Helm Chart: %v", err)
}

// Manifests have been deployed through Ignition
if _, err := c.SSH(kubectl, "/opt/bin/kubectl apply -f nfs-pod.yaml -f nfs-pvc.yaml"); err != nil {
c.Fatalf("unable to create NFS pod and pvc: %v", err)
}

// Wait up to 3 min (36*5 = 180s). The test can be flaky on overcommitted platforms.
if err := util.Retry(36, 5*time.Second, func() error {
out, err := c.SSH(kubectl, `/opt/bin/kubectl get pod/test-pod-1 -o json | jq '.status.containerStatuses[] | select (.name == "test") | .ready'`)
if err != nil {
return fmt.Errorf("getting container status: %v", err)
}

ready := string(out)
if ready != "true" {
return fmt.Errorf("'test' pod should be ready, got: %s", ready)
}

return nil
}); err != nil {
c.Fatalf("nginx pod with NFS is not deployed: %v", err)
}
})

// this should not fail, we always have the CNI present at this step.
cni, ok := params["CNI"]
if !ok {
Expand Down
36 changes: 36 additions & 0 deletions kola/tests/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,42 @@ storage:
image: ghcr.io/flatcar/nginx
ports:
- containerPort: 80
- path: /home/core/nfs-pod.yaml
filesystem: root
mode: 0644
contents:
inline: |
apiVersion: v1
kind: Pod
metadata:
name: test-pod-1
spec:
containers:
- name: test
image: ghcr.io/flatcar/nginx
volumeMounts:
- name: config
mountPath: /test
volumes:
- name: config
persistentVolumeClaim:
claimName: test-dynamic-volume-claim
- path: /home/core/nfs-pvc.yaml
filesystem: root
mode: 0644
contents:
inline: |
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-dynamic-volume-claim
spec:
storageClassName: "nfs"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
`

masterScript = `#!/bin/bash
Expand Down
36 changes: 36 additions & 0 deletions kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,39 @@ storage:
image: ghcr.io/flatcar/nginx
ports:
- containerPort: 80
- path: /home/core/nfs-pod.yaml
filesystem: root
mode: 0644
contents:
inline: |
apiVersion: v1
kind: Pod
metadata:
name: test-pod-1
spec:
containers:
- name: test
image: ghcr.io/flatcar/nginx
volumeMounts:
- name: config
mountPath: /test
volumes:
- name: config
persistentVolumeClaim:
claimName: test-dynamic-volume-claim
- path: /home/core/nfs-pvc.yaml
filesystem: root
mode: 0644
contents:
inline: |
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-dynamic-volume-claim
spec:
storageClassName: "nfs"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
36 changes: 36 additions & 0 deletions kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,39 @@ storage:
image: ghcr.io/flatcar/nginx
ports:
- containerPort: 80
- path: /home/core/nfs-pod.yaml
filesystem: root
mode: 0644
contents:
inline: |
apiVersion: v1
kind: Pod
metadata:
name: test-pod-1
spec:
containers:
- name: test
image: ghcr.io/flatcar/nginx
volumeMounts:
- name: config
mountPath: /test
volumes:
- name: config
persistentVolumeClaim:
claimName: test-dynamic-volume-claim
- path: /home/core/nfs-pvc.yaml
filesystem: root
mode: 0644
contents:
inline: |
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-dynamic-volume-claim
spec:
storageClassName: "nfs"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi

0 comments on commit 6c88fd6

Please sign in to comment.