Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: add NFS test #480

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions kola/tests/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var (
// and the nested params are used to render script templates
testConfig = map[string]map[string]interface{}{
"v1.28.1": map[string]interface{}{
"HelmVersion": "v3.13.2",
"MinMajorVersion": 3374,
// from https://github.com/flannel-io/flannel/releases
"FlannelVersion": "v0.22.0",
Expand Down Expand Up @@ -108,6 +109,7 @@ var (
"cgroupv1": false,
},
"v1.27.2": map[string]interface{}{
"HelmVersion": "v3.13.2",
"MinMajorVersion": 3374,
// from https://github.com/flannel-io/flannel/releases
"FlannelVersion": "v0.22.0",
Expand Down Expand Up @@ -140,6 +142,7 @@ var (
"cgroupv1": false,
},
"v1.26.5": map[string]interface{}{
"HelmVersion": "v3.13.2",
"MinMajorVersion": 3374,
// from https://github.com/flannel-io/flannel/releases
"FlannelVersion": "v0.20.2",
Expand Down Expand Up @@ -289,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
2 changes: 2 additions & 0 deletions kola/tests/kubeadm/kubeadm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestRenderTemplate(t *testing.T) {
res, err := render(
masterScript,
map[string]interface{}{
"HelmVersion": "1.2.3",
"CiliumVersion": "v0.11.1",
"FlannelVersion": "v0.14.0",
"CNI": CNI,
Expand Down Expand Up @@ -84,6 +85,7 @@ func TestRenderTemplate(t *testing.T) {
res, err := render(
masterConfig,
map[string]interface{}{
"HelmVersion": "1.2.3",
"CiliumVersion": "v0.11.1",
"CNI": "cilium",
"CiliumCLIVersion": "v0.9.0",
Expand Down
57 changes: 57 additions & 0 deletions kola/tests/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ storage:
ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-{{ .Arch }}.tar.gz"
[Install]
WantedBy=multi-user.target
- name: prepare-helm.service
enabled: true
contents: |
[Unit]
Description=Unpack helm to /opt/bin
ConditionPathExists=!/opt/bin/helm
[Service]
Type=oneshot
RemainAfterExit=true
Restart=on-failure
ExecStartPre=/usr/bin/mkdir --parents "{{ .DownloadDir }}"
ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz" --directory "{{ .DownloadDir }}" --strip-components=1 --no-same-owner
ExecStart=/usr/bin/rm "/opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz"
[Install]
WantedBy=multi-user.target
storage:
files:{{ if .cgroupv1 }}
- path: /etc/flatcar-cgroupv1
Expand Down Expand Up @@ -216,6 +231,12 @@ storage:
hash:
function: sha512
sum: {{ index (index . .Arch) "KubectlSum" }}
- path: /opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz
filesystem: root
mode: 0755
contents:
remote:
url: https://get.helm.sh/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz
- path: /etc/docker/daemon.json
filesystem: root
mode: 0644
Expand Down Expand Up @@ -264,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
57 changes: 57 additions & 0 deletions kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ systemd:
ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz"
[Install]
WantedBy=multi-user.target
- name: prepare-helm.service
enabled: true
contents: |
[Unit]
Description=Unpack helm to /opt/bin
ConditionPathExists=!/opt/bin/helm
[Service]
Type=oneshot
RemainAfterExit=true
Restart=on-failure
ExecStartPre=/usr/bin/mkdir --parents "/opt/bin"
ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-1.2.3-linux-amd64.tar.gz" --directory "/opt/bin" --strip-components=1 --no-same-owner
ExecStart=/usr/bin/rm "/opt/helm-1.2.3-linux-amd64.tar.gz"
[Install]
WantedBy=multi-user.target
storage:
files:
- path: /opt/cni-plugins-linux-amd64-v0.8.7.tgz
Expand Down Expand Up @@ -86,6 +101,12 @@ storage:
hash:
function: sha512
sum: a93b2ca067629cb1fe9cbf1af1a195c12126488ed321e3652200d4dbfee9a577865647b7ef6bb673e1bdf08f03108b5dcb4b05812a649a0de5c7c9efc1407810
- path: /opt/helm-1.2.3-linux-amd64.tar.gz
filesystem: root
mode: 0755
contents:
remote:
url: https://get.helm.sh/helm-1.2.3-linux-amd64.tar.gz
- path: /etc/docker/daemon.json
filesystem: root
mode: 0644
Expand Down Expand Up @@ -134,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
57 changes: 57 additions & 0 deletions kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ systemd:
ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-arm64.tar.gz"
[Install]
WantedBy=multi-user.target
- name: prepare-helm.service
enabled: true
contents: |
[Unit]
Description=Unpack helm to /opt/bin
ConditionPathExists=!/opt/bin/helm
[Service]
Type=oneshot
RemainAfterExit=true
Restart=on-failure
ExecStartPre=/usr/bin/mkdir --parents "/opt/bin"
ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-1.2.3-linux-arm64.tar.gz" --directory "/opt/bin" --strip-components=1 --no-same-owner
ExecStart=/usr/bin/rm "/opt/helm-1.2.3-linux-arm64.tar.gz"
[Install]
WantedBy=multi-user.target
storage:
files:
- path: /opt/cni-plugins-linux-arm64-v0.8.7.tgz
Expand Down Expand Up @@ -86,6 +101,12 @@ storage:
hash:
function: sha512
sum: b990b81d5a885a9d131aabcc3a5ca9c37dfaff701470f2beb896682a8643c7e0c833e479a26f21129b598ac981732bf52eecdbe73896fe0ff2d9c1ffd082d1fd
- path: /opt/helm-1.2.3-linux-arm64.tar.gz
filesystem: root
mode: 0755
contents:
remote:
url: https://get.helm.sh/helm-1.2.3-linux-arm64.tar.gz
- path: /etc/docker/daemon.json
filesystem: root
mode: 0644
Expand Down Expand Up @@ -134,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