mirror of
https://github.com/rancher/k3k.git
synced 2026-05-11 11:56:53 +00:00
* upload reports, run all conformance * set parallel * select k8s version for manual trigger * added k3k version input * wait for k3k deployment instead of pod
225 lines
7.4 KiB
YAML
225 lines
7.4 KiB
YAML
name: Conformance Tests - Shared Mode
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 1 * * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
k3k_version:
|
|
description: 'K3k version to test (e.g. v1.0.2). Leave empty to build from source.'
|
|
required: false
|
|
type: string
|
|
k8s_version:
|
|
description: 'Kubernetes version to test'
|
|
required: false
|
|
type: choice
|
|
options:
|
|
- ""
|
|
- "v1.34.6"
|
|
- "v1.35.3"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
K8S_VERSIONS: "v1.34.6,v1.35.3"
|
|
HELM_VERSION: v4.1.3
|
|
HELM_BIN_HASH_AMD64: 02ce9722d541238f81459938b84cf47df2fdf1187493b4bfb2346754d82a4700
|
|
K3D_VERSION: v5.8.3
|
|
K3D_BIN_HASH_AMD64: dbaa79a76ace7f4ca230a1ff41dc7d8a5036a8ad0309e9c54f9bf3836dbe853e
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
k8s_versions: ${{ steps.set-matrix.outputs.k8s_versions }}
|
|
steps:
|
|
- id: set-matrix
|
|
run: |
|
|
if [[ -z "${{ inputs.k8s_version }}" ]]; then
|
|
JSON_ARRAY=$(jq -nc '"${{ env.K8S_VERSIONS }}" | split(",")')
|
|
echo "k8s_versions=${JSON_ARRAY}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "k8s_versions=[\"${{ inputs.k8s_version }}\"]" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
conformance:
|
|
needs: setup
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
k8s_version: ${{ fromJSON(needs.setup.outputs.k8s_versions) }}
|
|
|
|
env:
|
|
KUBERNETES_VERSION: ${{ matrix.k8s_version }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Install helm
|
|
run: |
|
|
curl -sSfL -o helm.tar.gz https://get.helm.sh/helm-${{ env.HELM_VERSION }}-linux-amd64.tar.gz
|
|
echo "${{ env.HELM_BIN_HASH_AMD64 }} helm.tar.gz" | sha256sum --check
|
|
tar -xvzf helm.tar.gz --strip-components=1 -C /tmp/
|
|
sudo mv /tmp/helm /usr/local/bin
|
|
sudo chmod +x /usr/local/bin/helm
|
|
|
|
- name: Install hydrophone
|
|
run: go install sigs.k8s.io/hydrophone@3de3e886a2f6f09635d8b981c195490af1584d97 #v0.7.0
|
|
|
|
- name: Install k3d # taken from github.com/rancher/rancher/.github/workflows/integration-tests.yaml
|
|
run: |
|
|
curl -sSfL -o k3d "https://github.com/k3d-io/k3d/releases/download/${{ env.K3D_VERSION }}/k3d-linux-amd64"
|
|
echo "${{ env.K3D_BIN_HASH_AMD64 }} k3d" | sha256sum --check
|
|
sudo mv k3d /usr/local/bin
|
|
sudo chmod +x /usr/local/bin/k3d
|
|
|
|
- name: Install k3d and kubectl
|
|
run: |
|
|
curl -LO "https://dl.k8s.io/release/${{ env.KUBERNETES_VERSION }}/bin/linux/amd64/kubectl"
|
|
curl -LO "https://dl.k8s.io/release/${{ env.KUBERNETES_VERSION }}/bin/linux/amd64/kubectl.sha256"
|
|
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
|
|
|
|
- name: Setup Kubernetes (k3d)
|
|
env:
|
|
REPO_NAME: k3k-registry
|
|
REPO_PORT: 12345
|
|
run: |
|
|
echo "127.0.0.1 ${REPO_NAME}" | sudo tee -a /etc/hosts
|
|
|
|
k3d registry create ${REPO_NAME} --port ${REPO_PORT}
|
|
|
|
k3d cluster create k3k --servers 2 \
|
|
--image rancher/k3s:${{ env.KUBERNETES_VERSION }}-k3s1 \
|
|
-p "30000-30010:30000-30010@server:0" \
|
|
--registry-use k3d-${REPO_NAME}:${REPO_PORT}
|
|
|
|
kubectl cluster-info
|
|
kubectl get nodes
|
|
|
|
- name: Setup K3k (from source)
|
|
if: inputs.k3k_version == ''
|
|
env:
|
|
REPO: k3k-registry:12345
|
|
run: |
|
|
echo "127.0.0.1 k3k-registry" | sudo tee -a /etc/hosts
|
|
|
|
make build
|
|
make package
|
|
make push
|
|
|
|
# add k3kcli to $PATH
|
|
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
|
|
|
|
VERSION=$(make version)
|
|
k3d image import ${REPO}/k3k:${VERSION} -c k3k --verbose
|
|
k3d image import ${REPO}/k3k-kubelet:${VERSION} -c k3k --verbose
|
|
|
|
make install
|
|
|
|
- name: Setup K3k (from release)
|
|
if: inputs.k3k_version != ''
|
|
env:
|
|
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
|
|
run: |
|
|
K3K_VERSION="${{ inputs.k3k_version }}"
|
|
CHART_VERSION="${K3K_VERSION#v}"
|
|
|
|
helm repo add k3k https://rancher.github.io/k3k
|
|
helm repo update
|
|
helm install --namespace k3k-system --create-namespace --version "${CHART_VERSION}" k3k k3k/k3k
|
|
|
|
wget -qO k3kcli "https://github.com/rancher/k3k/releases/download/${{ inputs.k3k_version }}/k3kcli-linux-amd64"
|
|
sudo mv k3kcli /usr/local/bin/k3kcli
|
|
sudo chmod +x /usr/local/bin/k3kcli
|
|
|
|
- name: Wait for K3k controller
|
|
env:
|
|
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
|
|
run: |
|
|
echo "Wait for K3k controller deployment to be available"
|
|
kubectl wait -n k3k-system deployment -l "app.kubernetes.io/name=k3k" --for=condition=Available --timeout=5m
|
|
|
|
- name: Check k3kcli
|
|
run: k3kcli -v
|
|
|
|
- name: Create virtual cluster
|
|
run: |
|
|
kubectl create namespace k3k-mycluster
|
|
|
|
cat <<EOF | kubectl apply -f -
|
|
apiVersion: k3k.io/v1beta1
|
|
kind: Cluster
|
|
metadata:
|
|
name: mycluster
|
|
namespace: k3k-mycluster
|
|
spec:
|
|
mirrorHostNodes: true
|
|
tlsSANs:
|
|
- "127.0.0.1"
|
|
expose:
|
|
nodePort:
|
|
serverPort: 30001
|
|
EOF
|
|
|
|
echo "Wait for bootstrap secret to be available"
|
|
kubectl wait -n k3k-mycluster --for=create secret k3k-mycluster-bootstrap --timeout=5m
|
|
|
|
k3kcli kubeconfig generate --name mycluster
|
|
|
|
export KUBECONFIG=${{ github.workspace }}/k3k-mycluster-mycluster-kubeconfig.yaml
|
|
|
|
kubectl cluster-info
|
|
kubectl get nodes
|
|
kubectl get pods -A
|
|
|
|
- name: Run conformance tests
|
|
run: |
|
|
hydrophone --conformance --parallel 4 \
|
|
--kubeconfig ${{ github.workspace }}/k3k-mycluster-mycluster-kubeconfig.yaml \
|
|
--output-dir /tmp
|
|
|
|
- name: Archive logs
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
if: always()
|
|
with:
|
|
name: conformance-${{ matrix.k8s_version }}-logs
|
|
path: /tmp/e2e.log
|
|
|
|
- name: Archive results
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
if: always()
|
|
with:
|
|
name: conformance-${{ matrix.k8s_version }}-results
|
|
path: /tmp/junit_01.xml
|
|
|
|
- name: Job Summary
|
|
if: always()
|
|
run: |
|
|
echo '## 📊 Conformance Tests Results (${{ matrix.k8s_version }})' >> $GITHUB_STEP_SUMMARY
|
|
echo '| Passed | Failed | Pending | Skipped |' >> $GITHUB_STEP_SUMMARY
|
|
echo '|---|---|---|---|' >> $GITHUB_STEP_SUMMARY
|
|
|
|
RESULTS=$(tail -10 /tmp/e2e.log | grep -E "Passed .* Failed .* Pending .* Skipped" | cut -d '-' -f 3)
|
|
RESULTS=$(echo $RESULTS | grep -oE '[0-9]+' | xargs | sed 's/ / | /g')
|
|
echo "| $RESULTS |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# only include failed tests section if there are any
|
|
if grep -q '\[FAIL\]' /tmp/e2e.log; then
|
|
echo '' >> $GITHUB_STEP_SUMMARY
|
|
echo '### Failed Tests' >> $GITHUB_STEP_SUMMARY
|
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
grep '\[FAIL\]' /tmp/e2e.log >> $GITHUB_STEP_SUMMARY
|
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
fi
|