Skip to content

Commit 22c5f0f

Browse files
ci: Run Nutanix provider e2e tests on self-hosted runner (#755)
Modify e2e workflow to Run Nutanix jobs on self-hosted-github runner This is necessary as we want some e2e jobs to run on hosted runners and some to run on self-hosted runners. The actions runner controller does not support using multiple labels to target the runners See: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller/using-actions-runner-controller-runners-in-a-workflow#using-runner-scale-set-names Depends on #754. --------- Co-authored-by: Sid Shukla <[email protected]>
1 parent 6f2612b commit 22c5f0f

File tree

9 files changed

+300
-103
lines changed

9 files changed

+300
-103
lines changed

.github/actionlint.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
self-hosted-runner:
5+
# Labels of self-hosted runner in array of string
6+
labels:
7+
- self-hosted-ncn-dind

.github/workflows/checks.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,23 @@ jobs:
5959
matrix:
6060
provider:
6161
- Docker
62+
- Nutanix
6263
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
6364
# - AWS
64-
# - Nutanix
65+
cni:
66+
- Calico
67+
- Cilium
68+
addon-strategy:
69+
- ClusterResourceSet
70+
- HelmAddon
6571
fail-fast: false
6672
uses: ./.github/workflows/e2e.yml
6773
with:
6874
provider: ${{ matrix.provider }}
75+
cni: ${{ matrix.cni }}
76+
addon-strategy: ${{ matrix.addon-strategy }}
6977
focus: Quick start
78+
runs-on: ${{ matrix.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
7079
secrets: inherit
7180
permissions:
7281
contents: read
@@ -80,11 +89,20 @@ jobs:
8089
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
8190
# - AWS
8291
# - Nutanix
92+
cni:
93+
- Calico
94+
- Cilium
95+
addon-strategy:
96+
- ClusterResourceSet
97+
- HelmAddon
8398
fail-fast: false
8499
uses: ./.github/workflows/e2e.yml
85100
with:
86101
provider: ${{ matrix.provider }}
102+
cni: ${{ matrix.cni }}
103+
addon-strategy: ${{ matrix.addon-strategy }}
87104
focus: Self-hosted
105+
runs-on: ${{ matrix.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
88106
secrets: inherit
89107
permissions:
90108
contents: read

.github/workflows/e2e.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@ on:
88
description: Infrastructure provider to run e2e tests with
99
type: string
1010
required: true
11+
cni:
12+
description: CNI to run e2e tests with
13+
type: string
14+
required: true
15+
addon-strategy:
16+
description: Addon strategy to run e2e tests with
17+
type: string
18+
required: true
1119
skip:
1220
description: e2e tests to skip
1321
type: string
1422
focus:
1523
description: e2e tests to focus
1624
type: string
25+
runs-on:
26+
description: The runner to run the e2e tests on
27+
type: string
28+
required: true
1729

1830
jobs:
1931
e2e-test:
20-
runs-on: ubuntu-22.04
32+
runs-on: ${{ inputs.runs-on }}
2133
permissions:
2234
contents: read
2335
checks: write
@@ -27,10 +39,19 @@ jobs:
2739
with:
2840
fetch-depth: 0
2941

42+
# Install nix using cachix/install-nix-action if running on ARC runners
43+
# See: https://github.com/DeterminateSystems/nix-installer-action/issues/68
44+
- name: Install Nix on self-hosted ARC runners
45+
uses: cachix/install-nix-action@V27
46+
if: inputs.runs-on == 'self-hosted-ncn-dind'
47+
with:
48+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
49+
3050
- name: Install devbox
3151
uses: jetify-com/[email protected]
3252
with:
33-
enable-cache: true
53+
enable-cache: "true"
54+
skip-nix-installation: ${{ inputs.runs-on == 'self-hosted-ncn-dind' }}
3455

3556
- name: Go cache
3657
uses: actions/cache@v4
@@ -42,26 +63,53 @@ jobs:
4263
restore-keys: |
4364
${{ runner.os }}-go-
4465
45-
# The default disk size of these runners is ~14GB, this is not enough to run the e2e tests.
66+
# The default disk size of Github hosted runners is ~14GB, this is not enough to run the e2e tests.
4667
# Cleanup the disk, see upstream discussion https://github.com/actions/runner-images/issues/2840.
4768
- name: Cleanup Disk Space
69+
if: inputs.runs-on != 'self-hosted-ncn-dind'
4870
run: |
4971
echo "Before removing files:"
5072
df -h
5173
sudo rm -rf /usr/share/dotnet
5274
sudo rm -rf /opt/ghc
5375
sudo rm -rf "/usr/local/share/boost"
54-
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
76+
sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
5577
echo "After removing files:"
5678
df -h
5779
80+
- name: Get Control Plane endpoint IP
81+
id: get-control-plane-endpoint-ip
82+
if: inputs.provider == 'Nutanix'
83+
run: |
84+
CONTROL_PLANE_ENDPOINT_RANGE_START="${{ vars.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_START }}"
85+
CONTROL_PLANE_ENDPOINT_RANGE_END="${{ vars.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_END }}"
86+
control_plane_endpoint_ip="$(devbox run -- fping -g -u "${CONTROL_PLANE_ENDPOINT_RANGE_START}" "${CONTROL_PLANE_ENDPOINT_RANGE_END}" | devbox run -- shuf --head-count=1)"
87+
echo "control_plane_endpoint_ip=${control_plane_endpoint_ip}" >> "${GITHUB_OUTPUT}"
88+
89+
- name: Check Control Plane endpoint IP
90+
if: inputs.provider == 'Nutanix'
91+
run: |
92+
if [[ -z "${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}" ]]; then
93+
echo "control_plane_endpoint_ip is empty; cannot proceed with e2e tests"
94+
exit 1
95+
fi
96+
5897
- name: Run e2e tests
59-
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}' E2E_SKIP='${{ inputs.skip }}' E2E_FOCUS='${{ inputs.focus }}'
98+
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }} && cni:${{ inputs.cni }} && addonStrategy:${{ inputs.addon-strategy }}' E2E_SKIP='${{ inputs.skip }}' E2E_FOCUS='${{ inputs.focus }}'
6099
env:
61100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
102+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
62103
NUTANIX_ENDPOINT: ${{ secrets.NUTANIX_ENDPOINT }}
63-
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
64104
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
105+
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
106+
NUTANIX_PORT: ${{ vars.NUTANIX_PORT }}
107+
NUTANIX_INSECURE: false
108+
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ${{ vars.NUTANIX_PRISM_ELEMENT_CLUSTER_NAME }}
109+
NUTANIX_SUBNET_NAME: ${{ vars.NUTANIX_SUBNET_NAME }}
110+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ${{ vars.NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME }}
111+
NUTANIX_STORAGE_CONTAINER_NAME: ${{ vars.NUTANIX_STORAGE_CONTAINER_NAME }}
112+
CONTROL_PLANE_ENDPOINT_IP: ${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}
65113

66114
- if: success() || failure() # always run even if the previous step fails
67115
name: Publish e2e test report

devbox.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"crane@latest",
77
"envsubst@latest",
88
"findutils@latest",
9+
"fping@latest",
910
"gh@latest",
1011
"ginkgo@latest",
1112
"git@latest",

devbox.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,54 @@
381381
}
382382
}
383383
},
384+
"fping@latest": {
385+
"last_modified": "2024-06-12T20:55:33Z",
386+
"resolved": "github:NixOS/nixpkgs/a9858885e197f984d92d7fe64e9fff6b2e488d40#fping",
387+
"source": "devbox-search",
388+
"version": "5.2",
389+
"systems": {
390+
"aarch64-darwin": {
391+
"outputs": [
392+
{
393+
"name": "out",
394+
"path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2",
395+
"default": true
396+
}
397+
],
398+
"store_path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2"
399+
},
400+
"aarch64-linux": {
401+
"outputs": [
402+
{
403+
"name": "out",
404+
"path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2",
405+
"default": true
406+
}
407+
],
408+
"store_path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2"
409+
},
410+
"x86_64-darwin": {
411+
"outputs": [
412+
{
413+
"name": "out",
414+
"path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2",
415+
"default": true
416+
}
417+
],
418+
"store_path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2"
419+
},
420+
"x86_64-linux": {
421+
"outputs": [
422+
{
423+
"name": "out",
424+
"path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2",
425+
"default": true
426+
}
427+
],
428+
"store_path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2"
429+
}
430+
}
431+
},
384432
"gh@latest": {
385433
"last_modified": "2024-05-30T12:09:21Z",
386434
"resolved": "github:NixOS/nixpkgs/aa61b27554a5fc282758bf0324781e3464ef2cde#gh",

hack/kind/dns-override.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
data:
6+
Corefile: |
7+
.:53 {
8+
errors
9+
health {
10+
lameduck 5s
11+
}
12+
ready
13+
kubernetes cluster.local in-addr.arpa ip6.arpa {
14+
pods insecure
15+
fallthrough in-addr.arpa ip6.arpa
16+
ttl 30
17+
}
18+
prometheus :9153
19+
forward . 8.8.8.8
20+
cache 30
21+
loop
22+
reload
23+
loadbalance
24+
}
25+
kind: ConfigMap
26+
metadata:
27+
name: coredns
28+
namespace: kube-system

test/e2e/config/caren.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ images:
88
loadBehavior: mustLoad
99
- name: ghcr.io/nutanix-cloud-native/caren-helm-reg:${E2E_IMAGE_TAG}-${GOARCH}
1010
loadBehavior: mustLoad
11+
- name: docker.io/mesosphere/cluster-api-controller:${CAPI_VERSION}-d2iq.0
12+
loadBehavior: mustLoad
13+
- name: docker.io/mesosphere/kubeadm-bootstrap-controller:${CAPI_VERSION}-d2iq.0
14+
loadBehavior: mustLoad
15+
- name: docker.io/mesosphere/kubeadm-control-plane-controller:${CAPI_VERSION}-d2iq.0
16+
loadBehavior: mustLoad
17+
- name: docker.io/mesosphere/capd-manager:${CAPD_VERSION}-d2iq.0
18+
loadBehavior: mustLoad
1119

1220
providers:
1321
- name: cluster-api

test/e2e/e2e_suite_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ import (
1111
"encoding/base64"
1212
"encoding/gob"
1313
"flag"
14+
"fmt"
1415
"os"
1516
"path/filepath"
1617
"slices"
1718
"strings"
1819
"testing"
20+
"time"
1921

2022
. "github.com/onsi/ginkgo/v2"
2123
. "github.com/onsi/gomega"
24+
corev1 "k8s.io/api/core/v1"
2225
storagev1 "k8s.io/api/storage/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2327
"k8s.io/apimachinery/pkg/runtime"
28+
"k8s.io/apimachinery/pkg/types"
29+
"k8s.io/apimachinery/pkg/util/yaml"
2430
"k8s.io/klog/v2"
2531
capie2e "sigs.k8s.io/cluster-api/test/e2e"
2632
capie2eframework "sigs.k8s.io/cluster-api/test/framework"
@@ -110,6 +116,39 @@ var _ = SynchronizedBeforeSuite(func() []byte {
110116
useExistingCluster,
111117
)
112118

119+
By("Overriding coreDNS resolver")
120+
// override coredns resolver to 8.8.8.8 and restart coredns deployment
121+
// read the dns-override.yaml file
122+
filePath, _ := filepath.Abs("../../hack/kind/dns-override.yaml")
123+
yamlFile, err := os.ReadFile(filePath)
124+
Expect(err).To(BeNil(), "Failed to read the dns-override.yaml file")
125+
126+
// decode the yaml file into a Kubernetes object
127+
decode := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(yamlFile), 4096)
128+
configMap := &corev1.ConfigMap{}
129+
err = decode.Decode(&configMap)
130+
Expect(err).To(BeNil(), "Failed to decode the yaml file into a Kubernetes object")
131+
132+
_, err = bootstrapClusterProxy.GetClientSet().
133+
CoreV1().
134+
ConfigMaps(configMap.GetNamespace()).
135+
Update(context.Background(), configMap, metav1.UpdateOptions{})
136+
Expect(
137+
err,
138+
).To(BeNil(), "Failed to update the coredns deployment with the dns-override.yaml file")
139+
140+
timeNow := time.Now().Format(time.RFC3339)
141+
patch := fmt.Sprintf(
142+
`{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubernetes.io/restartedAt":%q}}}}}`,
143+
timeNow,
144+
)
145+
146+
_, err = bootstrapClusterProxy.GetClientSet().
147+
AppsV1().
148+
Deployments("kube-system").
149+
Patch(context.Background(), "coredns", types.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
150+
Expect(err).To(BeNil(), "Failed to restart the coredns deployment")
151+
113152
By("Initializing the bootstrap cluster")
114153
initBootstrapCluster(bootstrapClusterProxy, e2eConfig, clusterctlConfigPath, artifactFolder)
115154

0 commit comments

Comments
 (0)