diff --git a/.github/workflows/all-e2e-test.yaml b/.github/workflows/all-e2e-test.yaml new file mode 100644 index 000000000..804942f19 --- /dev/null +++ b/.github/workflows/all-e2e-test.yaml @@ -0,0 +1,128 @@ +name: all E2E tests + +on: + workflow_dispatch: + pull_request: + branches: [ main ] + paths: + - ".github/workflows/all-e2e-test.yaml" + +permissions: + contents: read + +jobs: + e2e-all: + runs-on: [self-hosted, linux] + steps: + - name: 🩹 Safe config for 💩 DNS + run: | + sed 's/options /options use-vc single-request attempts:5 /' < /etc/resolv.conf > /etc/resolv.conf.new + cat /etc/resolv.conf.new > /etc/resolv.conf + - name: ⬇️ Checkout repository + uses: actions/checkout@v4 + - name: ⬇️ Install kubectl + uses: azure/setup-kubectl@v4 + with: + version: v1.32.9 + - name: ⬇️ Install helm + uses: azure/setup-helm@v4 + - name: ⬇️ Install kustomize + uses: imranismail/setup-kustomize@v1 + with: + kustomize-version: v4.5.7 + - name: 🔎 Check IP + id: ip + run: | + echo "ip=`curl -s https://api.ipify.org`" | tee $GITHUB_OUTPUT + - name: 🔐 Set ak/sk name based on runner region + run: .github/scripts/runneraksk.sh + - name: 🧹 Frieza + uses: outscale/frieza-github-actions/frieza-clean@master + with: + access_key: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} + secret_key: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} + region: ${{ env.OSC_REGION }} + - name: 👷 Deploy management cluster + id: management + uses: ./github_actions/deploy_cluster + with: + RUNNER_NAME: ${{ runner.name }} + OKS_ACCESS_KEY: ${{ secrets.OSC_ACCESS_KEY_OKS }} + OKS_SECRET_KEY: ${{ secrets.OSC_SECRET_KEY_OKS }} + OKS_REGION: ${{ vars.OKS_REGION }} + OSC_ACCESS_KEY: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} + OSC_SECRET_KEY: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} + OSC_REGION: ${{ env.OSC_REGION }} + CLUSTER_NAME: "caposc-all" + IMAGE_NAME: ${{ vars.IMG_MANAGEMENT }} + IMAGE_ACCOUNT_ID: ${{ secrets[env.OSC_ACCOUNT_ID_NAME] }} + CERT_MANAGER: "true" + - name: ⬇️ Install Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: 📦 Build and push Docker image + run: | + docker login ${{ vars.REGISTRY }} -u admin -p ${{ secrets.HARBOR_ADMIN_PASSWORD }} + sudo apt-get update + sudo apt install -y docker-buildx-plugin + make docker-buildx + make docker-push + env: + IMG: ${{ vars.REGISTRY }}/outscale/cluster-api-outscale-controllers:${{ github.sha }} + DOCKER_BUILDKIT: 1 + - name: 🔎 Preloader snapshot + id: preloader + uses: outscale/k8s-image-preloader/github_actions/preloader_snapshot@main + with: + KUBECONFIG: ${{ steps.management.outputs.KUBECONFIG }} + OSC_ACCESS_KEY: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} + OSC_SECRET_KEY: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} + OSC_REGION: ${{ env.OSC_REGION }} + CSI: true + - name: 🔐 Create CAPOSC ns and credentials + run: make credential + shell: bash + env: + KUBECONFIG: "${{ github.workspace }}/${{ steps.management.outputs.KUBECONFIG }}" + OSC_ACCESS_KEY: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} + OSC_SECRET_KEY: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} + - name: 🧪 Launch e2e tests + run: | + from=`echo ${{ vars.IMG_UPGRADE_FROM }} | sed 's/.*kubernetes-\(v[^-]*\)-.*/\1/'` + to=`echo ${{ vars.IMG_UPGRADE_TO }} | sed 's/.*kubernetes-\(v[^-]*\)-.*/\1/'` + export KUBERNETES_VERSION=$from + export KUBERNETES_VERSION_UPGRADE_FROM=$from + export KUBERNETES_VERSION_UPGRADE_TO=$to + E2E_FOCUS=all make e2etest + shell: bash + id: e2etest + env: + KUBECONFIG: "${{ github.workspace }}/${{ steps.management.outputs.KUBECONFIG }}" + CCM_OSC_ACCESS_KEY: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} + CCM_OSC_SECRET_KEY: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} + CCM_OSC_REGION: ${{ env.OSC_REGION }} + IMG: ${{ vars.REGISTRY }}/outscale/cluster-api-outscale-controllers:${{ github.sha }} + IMG_UPGRADE_FROM: ${{ vars.IMG_UPGRADE_FROM }} + IMG_UPGRADE_TO: ${{ vars.IMG_UPGRADE_TO }} + COREDNS_VERSION_UPGRADE_TO: ${{ vars.COREDNS_VERSION_UPGRADE_TO }} + ETCD_VERSION_UPGRADE_TO: ${{ vars.ETCD_VERSION_UPGRADE_TO }} + PRELOAD_SNAPSHOT_ID: ${{ steps.preloader.outputs.SNAPSHOT_ID }} + - name: 📝 Get CAPOSC state/logs + run: | + echo "**** pod state" + kubectl describe po -n cluster-api-provider-outscale-system + echo "**** pod logs" + make logs-capo + if: ${{ failure() && steps.e2etest.conclusion == 'failure' }} + shell: bash + env: + KUBECONFIG: "${{ github.workspace }}/${{ steps.management.outputs.KUBECONFIG }}" + CAPO_NAMESPACE: cluster-api-provider-outscale-system + - name: 📝 Get cluster api logs + run: make logs-capi + if: ${{ failure() && steps.e2etest.conclusion == 'failure' }} + shell: bash + env: + KUBECONFIG: "${{ github.workspace }}/${{ steps.management.outputs.KUBECONFIG }}" + CAPI_NAMESPACE: capi-kubeadm-bootstrap-system \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c86516dfd..65310ac16 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,5 @@ -name: build +name: Check build & lint + on: pull_request: branches: [main] @@ -13,11 +14,10 @@ on: - "!helm/**" - "Makefile" - "!docs/src/**" - - "!hack/json-format/*.sh" - - "!hack/json-format/src/*.rs" - - "!hack/json-format/Makefile" - - "!hack/json-format/Cargo.*" - - "!hack/json-format/tests/*.rs" + +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/dispatch_image_builder.yaml b/.github/workflows/dispatch_image_builder.yaml deleted file mode 100644 index 8df6556c4..000000000 --- a/.github/workflows/dispatch_image_builder.yaml +++ /dev/null @@ -1,89 +0,0 @@ -on: - repository_dispatch: - types: - - release -jobs: - example_matrix: - runs-on: [self-hosted, linux] - strategy: - matrix: - include: - - environment: eu-west-2 - version: ${{ github.event.client_payload.versions }} - - environment: cloudgouv-eu-west-1 - version: ${{ github.event.client_payload.versions }} - - environment: ap-northeast-1 - version: ${{ github.event.client_payload.versions }} - environment: - name: ${{ matrix.environment }} - steps: - - uses: actions/checkout@v4 - with: - repository: outscale/cluster-api-provider-outscale - ref: main - path: cluster-api-provider-outscale - - name: Use rust with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - target: x86_64-unknown-linux-musl - - name: Build json-format - run: make build - working-directory: ${{ github.workspace }}/cluster-api-provider-outscale/hack/json-format - shell: bash - - name: Checkout image-builder - uses: actions/checkout@v4 - with: - repository: 'kubernetes-sigs/image-builder' - path: "add-outscale-image" - ref: main - - uses: actions/setup-go@v5 - with: - go-version: '1.19.8' - - name: Install Packer - run: make install-packer - shell: bash - working-directory: ${{ github.workspace }}/cluster-api-provider-outscale - - name: generate file - shell: bash - run: | - kubernetes_series=`echo ${{ matrix.version[0] }} | cut -d "." -f1-2` - kubernetes_semver=`echo ${{ matrix.version[0] }}` - ./json_format -r ${kubernetes_semver} -v ${kubernetes_series} -o overwrite-k8s.json - cat overwrite-k8s.json - cp overwrite-k8s.json $GITHUB_WORKSPACE/add-outscale-image/images/capi - working-directory: ${{ github.workspace }}/cluster-api-provider-outscale/hack/json-format/target/x86_64-unknown-linux-musl/release - env: - capi_image: ${{ github.workspace }}/add-outscale-image/images/capi" - - name: Launch image-builder - run: | - sudo pip3 install setuptools-rust - sudo pip3 install --upgrade pip - export PATH=$HOME/.local/bin:$GITHUB_WORKSPACE/image-builder/images/capi/.local/bin:$PATH - make deps-osc - sudo groupadd -r packer && sudo useradd -m -s /bin/bash -r -g packer packer - cp -rf $GITHUB_WORKSPACE/add-outscale-image/images/capi /tmp - sudo chown -R packer:packer /tmp/capi - sudo chmod -R 777 /tmp/capi - sudo runuser -l packer -c "export LANG=C.UTF-8; export LC_ALL=C.UTF-8; export PACKER_LOG=1; export PATH=~packer/.local/bin/:/tmp/capi/.local/bin:$PATH; export OSC_ACCESS_KEY=${OSC_ACCESS_KEY}; export OSC_SECRET_KEY=${OSC_SECRET_KEY}; export OSC_REGION=${OSC_REGION}; export OSC_ACCOUNT_ID=${OSC_ACCOUNT_ID}; cd /tmp/capi; PACKER_VAR_FILES=overwrite-k8s.json make build-osc-all" - shell: bash - working-directory: "${{ github.workspace }}/add-outscale-image/images/capi" - env: - OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}} - OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}} - OSC_REGION: ${{secrets.OSC_REGION}} - OSC_ACCOUNT_ID: ${{secrets.OSC_ACCOUNT_ID}} - CRYPTOGRAPHY_DONT_BUILD_RUST: 1 - PACKER_LOG: 1 - LANG: C.UTF-8 - LC_ALL: C.UTF-8 - - name: Install gh - run: make install-gh - working-directory: ${{ github.workspace }}/cluster-api-provider-outscale - - name: Generate image docs - if: ${{ matrix.environment == 'eu-west-2' }} - run: K8S_VERSION=${{ matrix.version[0] }} make generate-image-docs - env: - SECRET_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} - working-directory: ${{ github.workspace }}/cluster-api-provider-outscale diff --git a/.github/workflows/image-clean.yaml b/.github/workflows/docker-prune.yaml similarity index 55% rename from .github/workflows/image-clean.yaml rename to .github/workflows/docker-prune.yaml index 28ff3ce24..99a0acf64 100644 --- a/.github/workflows/image-clean.yaml +++ b/.github/workflows/docker-prune.yaml @@ -1,4 +1,4 @@ -name: clean-image +name: docker-prune on: schedule: @@ -7,15 +7,15 @@ jobs: clean-image: runs-on: ubuntu-latest steps: - - name: Checkout cluster-api-outscale - uses: actions/checkout@v4 + - name: ⬇️ Checkout cluster-api-outscale + uses: actions/checkout@v5 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: Launch image-builder + - name: 🧹 Prune docker cache run: | - pip3 install -r hack/cleanup/requirements.txt - python3 hack/cleanup/cleanup_oapi.py --days $DAYS --owner $OWNER --imageNamePattern "^(ubuntu|centos)-[0-9.]+-[0-9.]+-kubernetes-v[0-9]+.[0-9]{2}.[0-9]+-[0-9]{4}-[0-9]{2}-[0-9]{2}$" --imageNameFilterPath $GITHUB_WORKSPACE/hack/cleanup/keep_image + docker buider prune + docker image prune shell: bash env: OSC_ACCESS_KEY: ${{secrets.OSC_OPENSOURCE_ACCESS_KEY}} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d9e7c48fa..636052081 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -11,28 +11,9 @@ on: - "!helm/**" - "Makefile" - "!docs/src/**" - - "!hack/json-format/*.sh" - - "!hack/json-format/src/*.rs" - - "!hack/json-format/Makefile" - - "!hack/json-format/Cargo.*" - - "!hack/json-format/tests/*.rs" - push: - branches: - - 'main' - paths: - - "**.go" - - "**.yaml" - - "!capm.yaml" - - "!osc-secret.yaml" - - "!example/**.yaml" - - "!helm/**" - - "Makefile" - - "!docs/src/**" - - "!hack/json-format/*.sh" - - "!hack/json-format/src/*.rs" - - "!hack/json-format/Makefile" - - "!hack/json-format/Cargo.*" - - "!hack/json-format/tests/*.rs" + +permissions: + contents: read jobs: docker: diff --git a/.github/workflows/json-format-pull-request.yaml b/.github/workflows/json-format-pull-request.yaml deleted file mode 100644 index 3d9336a25..000000000 --- a/.github/workflows/json-format-pull-request.yaml +++ /dev/null @@ -1,98 +0,0 @@ -name: validate-with-test -on: - pull_request: - branches: - - 'main' - paths: - - "!**.go" - - "!**.yaml" - - "!capm.yaml" - - "!osc-secret.yaml" - - "!example/**.yaml" - - "!helm/**" - - "!Makefile" - - "!docs/src/**" - - "hack/json-format/*.sh" - - "hack/json-format/src/*.rs" - - "hack/json-format/Makefile" - - "hack/json-format/Cargo.*" - - "hack/json-format/tests/*.rs" - push: - branches: - - 'main' - paths: - - "!**.go" - - "!**.yaml" - - "!capm.yaml" - - "!osc-secret.yaml" - - "!example/**.yaml" - - "!helm/**" - - "!Makefile" - - "!docs/src/**" - - "hack/json-format/*.sh" - - "hack/json-format/src/*.rs" - - "hack/json-format/Makefile" - - "hack/json-format/Cargo.*" - - "hack/json-format/tests/*.rs" -jobs: - validate-format-test: - runs-on: ubuntu-22.04 - steps: - - name: Checkout json-format - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Use Rust with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - name: Check Code format - run: make format-test - working-directory: ${{ github.workspace }}/hack/json-format - shell: bash - validate-cargo-test: - environment: eu-west-2 - runs-on: ubuntu-22.04 - steps: - - name: Checkout json-format - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Use Rust with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - name: Run tests - run: make cargo-test - working-directory: ${{ github.workspace }}/hack/json-format - shell: bash - integration-test: - environment: eu-west-2 - runs-on: ubuntu-22.04 - steps: - - name: Checkout json-format - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Use Rust with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - target: x86_64-unknown-linux-musl - - name: Build json-format - run: make build - working-directory: ${{ github.workspace }}/hack/json-format - shell: bash - - name: Run integration-test - run: make integration-test - working-directory: ${{ github.workspace }}/hack/json-format - shell: bash - env: - WORKING_BINARY_DIRECTORY: "${{ github.workspace }}/hack/json-format/target/x86_64-unknown-linux-musl/release" diff --git a/.github/workflows/kind.yaml b/.github/workflows/kind.yaml deleted file mode 100644 index f3978ce2a..000000000 --- a/.github/workflows/kind.yaml +++ /dev/null @@ -1,97 +0,0 @@ -name: kind - -on: - push: - tags: - - "v*" -jobs: - kind: - runs-on: [self-hosted, linux] - steps: - - name: Checkout cluster-api-outscales - uses: actions/checkout@v4 - - name: Checkout osc-k8s-rke-cluster - uses: actions/checkout@v4 - with: - repository: 'outscale-dev/osc-k8s-rke-cluster' - path: "rke-cluster-for-cluster-api" - ref: master - - name: Install kubectl - uses: azure/setup-kubectl@v3 - with: - version: v1.30.7 - id: install - - name: Install golang - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: Install kustomize - uses: imranismail/setup-kustomize@v1 - with: - kustomize-version: v4.5.7 - - uses: outscale/frieza-github-actions/frieza-clean@master - with: - access_key: ${{ secrets.OSC_ACCESS_KEY }} - secret_key: ${{ secrets.OSC_SECRET_KEY }} - region: ${{ secrets.OSC_REGION }} - - name: Install kind - run: | - make install-kind - make envtest - make install-kubebuildertool - - name: Build image - run: make docker-buildx - env: - IMG: 127.0.0.1:4242/cluster-api-outscale-controllers:${{ github.sha }} - DOCKER_BUILDKIT: 1 - - name: Deploy Cluster - uses: ./rke-cluster-for-cluster-api/github_actions/deploy_cluster/ - with: - repository_folder: "rke-cluster-for-cluster-api" - osc_access_key: ${{ secrets.OSC_ACCESS_KEY }} - osc_secret_key: ${{ secrets.OSC_SECRET_KEY }} - osc_region: ${{ secrets.OSC_REGION }} - image_id: ${{ secrets.OMI_ID }} - control_plane_vm_type: ${{ secrets.CP_VMTYPE }} - bastion_vm_type: ${{ secrets.BASTION_VMTYPE }} - worker_vm_type: ${{ secrets.WORKER_VMTYPE }} - rke_version: ${{ secrets.RKE_VERSION }} - kubernetes_version: ${{ secrets.KUBERNETES_VERSION }} - - name: Wait Kubernetes control plane is up and running - uses: nick-invision/retry@v2 - with: - timeout_seconds: 30 - max_attempts: 20 - retry_wait_seconds: 30 - command: kubectl get --raw='/readyz?verbose' - env: - KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml - - name: Wait all infrastructure app are really up and running - uses: jupyterhub/action-k8s-await-workloads@v1 - with: - workloads: "" - namespace: "" - timeout: 600 - max-restarts: -1 - env: - KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml - - name: Launch e2testkind - run: KUBECONFIG=$GITHUB_WORKSPACE/rke-cluster-for-cluster-api/rke/kube_config_cluster.yml make e2etestkind - shell: bash - id: e2etestkind - env: - IMG: 127.0.0.1:4242/cluster-api-outscale-controllers:${{ github.sha }} - OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}} - OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}} - OSC_REGION: ${{ secrets.OSC_REGION }} - OSC_SUBREGION_NAME: ${{ secrets.OSC_SUBREGION_NAME }} - IMG_UPGRADE_FROM: ${{ secrets.IMG_UPGRADE_FROM }} - IMG_UPGRADE_TO: ${{ secrets.IMG_UPGRADE_TO }} - - name: Destroy cluster - uses: ./rke-cluster-for-cluster-api/github_actions/destroy_cluster/ - if: ${{ always() }} - with: - repository_folder: "./rke-cluster-for-cluster-api" - osc_access_key: ${{ secrets.OSC_ACCESS_KEY }} - osc_secret_key: ${{ secrets.OSC_SECRET_KEY }} - osc_region: ${{ secrets.OSC_REGION }} diff --git a/.github/workflows/publish_doc.yaml b/.github/workflows/publish_doc.yaml index 8f13ba0c6..3a66d38c9 100644 --- a/.github/workflows/publish_doc.yaml +++ b/.github/workflows/publish_doc.yaml @@ -1,8 +1,9 @@ name: publish on: - push: - tags: - - "v*" + workflow_dispatch: + # push: + # tags: + # - "v*" jobs: publish: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2675ab8b4..3a2406a14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release + on: push: tags: diff --git a/.github/workflows/unit-func-e2e-test.yaml b/.github/workflows/unit-quickstart-e2e-test.yaml similarity index 93% rename from .github/workflows/unit-func-e2e-test.yaml rename to .github/workflows/unit-quickstart-e2e-test.yaml index 69ba32a65..84e5cb101 100644 --- a/.github/workflows/unit-func-e2e-test.yaml +++ b/.github/workflows/unit-quickstart-e2e-test.yaml @@ -1,4 +1,7 @@ -name: unit-func-e2e-test +name: Unit & quickstart E2E tests + +permissions: + contents: read on: pull_request: @@ -16,13 +19,8 @@ on: - "Makefile" - "hack/*.sh" - "!docs/src/**" - - "!hack/json-format/*.sh" - - "!hack/json-format/src/*.rs" - - "!hack/json-format/Makefile" - - "!hack/json-format/Cargo.*" - - "!hack/json-format/tests/*.rs" jobs: - unit_test: + unit: runs-on: ubuntu-latest steps: - name: ⬇️ Checkout repository @@ -36,16 +34,16 @@ jobs: make unit-test cat covers.txt shell: bash - e2etest: + e2e-quickstart: runs-on: [self-hosted, linux] - needs: [unit_test] + needs: [unit] steps: - name: ⬇️ Checkout repository uses: actions/checkout@v4 - name: ⬇️ Install kubectl uses: azure/setup-kubectl@v4 with: - version: v1.30.7 + version: v1.32.9 - name: ⬇️ Install helm uses: azure/setup-helm@v4 - name: ⬇️ Install kustomize @@ -100,7 +98,7 @@ jobs: KUBECONFIG: "${{ github.workspace }}/${{ steps.management.outputs.KUBECONFIG }}" OSC_ACCESS_KEY: ${{ secrets[env.OSC_ACCESS_KEY_NAME] }} OSC_SECRET_KEY: ${{ secrets[env.OSC_SECRET_KEY_NAME] }} - - name: 🧪 Launch e2e tests + - name: 🧪 Launch quickstart e2e tests run: | from=`echo ${{ vars.IMG_UPGRADE_FROM }} | sed 's/.*kubernetes-\(v[^-]*\)-.*/\1/'` to=`echo ${{ vars.IMG_UPGRADE_TO }} | sed 's/.*kubernetes-\(v[^-]*\)-.*/\1/'` diff --git a/.gitignore b/.gitignore index 078c37045..393c95ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,3 @@ secret.* clusterctl-settings.json # Dependency directories (remove the comment below to include it) bin/ -hack/json-format/target/ -hack/json-format/Cargo.lock -hack/json-format/**/*.rs.bk diff --git a/github_actions/deploy_cluster/main.sh b/github_actions/deploy_cluster/main.sh index 3c1e3172b..50fba58a5 100755 --- a/github_actions/deploy_cluster/main.sh +++ b/github_actions/deploy_cluster/main.sh @@ -26,14 +26,6 @@ export OSC_REGION=`echo $OSC_AKSK|cut -d% -f 3` export OSC_IMAGE_NAME=`echo $OSC_IMAGE_NAME_ACCOUNT_ID|cut -d% -f 1` export OSC_IMAGE_ACCOUNT_ID=`echo $OSC_IMAGE_NAME_ACCOUNT_ID|cut -d% -f 2` -if [ -z "$OSC_IMAGE_ACCOUNT_ID" ]; then - export OSC_IMAGE_ACCOUNT_ID=`curl --retry 5 --retry-all-errors \ - -X POST https://api.$OSC_REGION.outscale.com/api/v1/ReadAccounts \ - --user $OSC_ACCESS_KEY:$OSC_SECRET_KEY --aws-sigv4 'osc' \ - --header 'Content-Type: application/json' \ - --data '{}'|jq -r '.Accounts[0].AccountId'` -fi - cluster_name=`echo $RUNNER_NAME|tr '[:upper:]' '[:lower:]'|sed -r 's/-[a-z0-9]+$//'|cut -c1-40|sed -r 's/[^a-z0-9-]+/-/g'` # OKS /.venv/bin/oks-cli profile add --profile-name "default" --access-key $OKS_ACCESS_KEY --secret-key $OKS_SECRET_KEY --region $OKS_REGION @@ -53,8 +45,10 @@ ip=`curl -s -S --retry 5 --retry-all-errors https://api.ipify.org` export OSC_ALLOW_FROM="$ip/32" mip=`kubectl run --image curlimages/curl:8.14.1 getip --restart=Never -ti --rm -q -- curl -s -S --retry 5 --retry-all-errors https://api.ipify.org` export OSC_ALLOW_FROM_CAPI="$mip/32" -clusterctl generate cluster $OSC_CLUSTER_NAME --kubernetes-version $KUBERNETES_VERSION --control-plane-machine-count=1 --worker-machine-count=$WORKER_COUNT -n $OSC_CLUSTER_NAME -i outscale --flavor secure-opensource > clusterapi.yaml -#clusterctl generate cluster $OSC_CLUSTER_NAME --kubernetes-version $KUBERNETES_VERSION --control-plane-machine-count=1 --worker-machine-count=$WORKER_COUNT -n $OSC_CLUSTER_NAME -i outscale > clusterapi.yaml +export OSC_NAT_IP_POOL=caposc +export OSC_IMAGE_OPENSOURCE=true +clusterctl generate cluster $OSC_CLUSTER_NAME --kubernetes-version $KUBERNETES_VERSION --control-plane-machine-count=1 --worker-machine-count=$WORKER_COUNT -n $OSC_CLUSTER_NAME --from https://github.com/outscale/cluster-api-provider-outscale/blob/ci-cleanup/templates/cluster-template-secure.yaml > clusterapi.yaml +# clusterctl generate cluster $OSC_CLUSTER_NAME --kubernetes-version $KUBERNETES_VERSION --control-plane-machine-count=1 --worker-machine-count=$WORKER_COUNT -n $OSC_CLUSTER_NAME -i outscale --flavor secure-opensource > clusterapi.yaml kubectl delete ns $OSC_CLUSTER_NAME --ignore-not-found --force kubectl create ns $OSC_CLUSTER_NAME diff --git a/hack/json-format/Cargo.toml b/hack/json-format/Cargo.toml deleted file mode 100755 index cacb8ec54..000000000 --- a/hack/json-format/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "json_format_generator" -version = "0.1.0" -edition = "2021" -license = "BSD-3-Clause" -description = "json-format-generator generate json based on json, parameters" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[[bin]] -name = "json_format" -path = "src/main.rs" - -[lib] -name = "json_format" -path = "src/lib.rs" - -[[test]] -name = "integration" -path = "tests/integration_test.rs" - -[dependencies] -serde = { version = "1.0.148", features = ["derive"] } -serde_json = { version = "1.0.89" } -clap = { version = "4.0.29", features = ["derive"] } -chrono = "0.4.23" -config-file = "0.2.3" -serde_yaml = "0.9.14" -logs = "0.7.1" -log = "0.4.17" -lazy_static = "1.4.0" -regex = "1.7.0" diff --git a/hack/json-format/Makefile b/hack/json-format/Makefile deleted file mode 100644 index 39d5a72e0..000000000 --- a/hack/json-format/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2022 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -TARGET=target/x86_64-unknown-linux-musl/release/json-format -KUBERNETES_SERIES ?= v1.22 -KUBERNETES_SEMVER ?= v1.22.1 -INPUT ?= kubernetes.json -OUTPUT ?= overwrite-1.22.json -WORKING_BINARY_DIRECTORY ?= $(shell pwd)/target/x86_64-unknown-linux-musl/release -FORMAT ?= params -all: help - -.PHONY: help -help: - @echo "help:" - @echo "- make build: build the binary of cluster-api" - @echo "- make test: run all tests" - -build: $(TARGET) - -target/x86_64-unknown-linux-musl/release/json-format: src/*.rs - cargo build --target x86_64-unknown-linux-musl --release - -.PHONY: test -test: build cargo-test format-test integration-test - @echo all tests OK - -.PHONY: integration-test -integration-test: - ./run-integration-test.sh -f $(FORMAT) -k $(KUBERNETES_SERIES) -r $(KUBERNETES_SEMVER) -w $(WORKING_BINARY_DIRECTORY) -i $(INPUT) -o $(OUTPUT) - -.PHONY: cargo-test -cargo-test: - cargo test - -.PHONY: format-test -format-test: - cargo fmt --check - cargo clippy - diff --git a/hack/json-format/run-integration-test.sh b/hack/json-format/run-integration-test.sh deleted file mode 100755 index 378cdc83d..000000000 --- a/hack/json-format/run-integration-test.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/bash -# Copyright 2022 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o nounset -set -o pipefail - -ROOT=$(pwd) - -# check_json_format_installed checks that json_format is installed. -function check_json_format_installed() { - kubernetes_output_json="$check_working_binary_directory/json_format" - - if [[ -f "$kubernetes_output_json" ]]; then - echo "json-format is found" - else - echo "json-format is not found" - exit 1 - fi -} - - -# check_file_exist checks that json output exist. -function check_file_exist() { - kubernetes_output_json="$ROOT/$check_output" - if [[ -f "$kubernetes_output_json" ]]; then - echo "kubernetes_output_json is found" - else - echo "kubernetes_output_json is not found" - exit 1 - fi -} - -# check_content checks that every json parameters of output json file. -function check_content() { - kubernetes_deb_version=$(jq .kubernetes_deb_version "$ROOT"/"$check_output") - echo "$kubernetes_deb_version" - kubernetes_rpm_version=$(jq .kubernetes_rpm_version "$ROOT"/"$check_output") - echo "$kubernetes_rpm_version" - kubernetes_semver=$(jq .kubernetes_semver "$ROOT"/"$check_output") - kubernetes_series=$(jq .kubernetes_series "$ROOT"/"$check_output") - if [[ $kubernetes_deb_version == '"1.22.1-1.1"' ]]; then - echo "Find kubernetes_deb_version" - else - echo "Can not find kubernetes_deb_version" - exit 1 - fi - if [[ $kubernetes_rpm_version == '"1.22.1"' ]]; then - echo "Find kubernetes_rpm_version" - else - echo "Can not find kubernetes_rpm_version" - exit 1 - fi - if [[ $kubernetes_semver == '"v1.22.1"' ]]; then - echo "Find kubernetes_semver" - else - echo "Can not find kubernetes_semver" - exit 1 - fi - if [[ $kubernetes_series == '"v1.22"' ]]; then - echo "Find kubernetes_series" - else - echo "Can not find kubernetes_series" - exit 1 - fi -} - -# run_json_format set default values and run json_format -function run_json_format() { - check_format=${format:-} - if [ -z "${check_format}" ]; then - echo "format is unset"; - echo "Set default values" - check_format="params" - else - echo "format is set to '$check_format'" - fi - check_kubernetes_series=${kubernetes_series:-} - if [ -z "${check_kubernetes_series}" ]; then - echo "kubenetes_series is unset"; - echo "Set default values" - check_kubernetes_series="v1.22" - else - echo "kubernetes_series is set to '$check_kubernetes_series'" - fi - - check_kubernetes_semver=${kubernetes_semver:-} - if [ -z "${check_kubernetes_semver}" ]; then - echo "kubernetes_semver is unset"; - echo "Set default values" - check_kubernetes_semver="v1.22.1" - else - echo "kubernetes_semver is set to '$check_kubernetes_semver'" - fi - check_input=${input:-} - if [ -z "${check_input}" ]; then - echo "input is unset"; - echo "Set default values" - check_input="kubernetes.json" - else - echo "input is set to '$check_input'" - fi - check_output=${output:-} - if [ -z "${check_output}" ]; then - echo "output is unset"; - echo "Set default values" - check_output="overwrite-1.22.json" - else - echo "output is set to '$check_output'" - fi - check_working_binary_directory=${working_binary_directory:-} - if [ -z "${check_working_binary_directory}" ]; then - echo "working_directory is unset"; - echo "Set default values" - check_working_binary_directory=$ROOT/target/x86_64-unknown-linux-musl/release - else - echo "working_binary_directory is set to '$check_working_binary_directory'" - fi - "$check_working_binary_directory"/json_format --format $check_format --kubernetes-series $check_kubernetes_series --kubernetes-semver $check_kubernetes_semver --input $check_input --output $check_output - echo "$check_working_binary_directory/json_format --format $check_format --kubernetes-series $check_kubernetes_series --kubernetes-semver $check_kubernetes_semver --input $check_input --output $check_output" -} - -# usage show the usage of the script with parameters. -function usage { - echo "./run-integration-test.sh -f format -k kubernetes_series -r kubernetes_semver -i input -o output --> shows usage" -} - -optstring=":k:r:f:i:o:w:" -while getopts ${optstring} arg; do - case ${arg} in - f) - format=${OPTARG} - ;; - k) - kubernetes_series=${OPTARG} - ;; - r) - kubernetes_semver=${OPTARG} - ;; - i) - input=${OPTARG} - ;; - o) - output=${OPTARG} - ;; - w) - working_binary_directory=${OPTARG} - ;; - *) - echo "showing usage!" - usage;; - esac -done - -run_json_format -check_json_format_installed -check_file_exist -check_content diff --git a/hack/json-format/src/core.rs b/hack/json-format/src/core.rs deleted file mode 100644 index 26136dc20..000000000 --- a/hack/json-format/src/core.rs +++ /dev/null @@ -1,182 +0,0 @@ -use chrono::prelude::*; -use log::warn; -use serde::{Deserialize, Serialize}; -use std::error::Error; -use std::fmt; - -#[derive(Serialize, Deserialize, Debug)] -#[serde(untagged)] -pub enum Data { - KubernetesImage(KubernetesImage), -} - -pub struct Datas { - pub datas: Vec, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct KubernetesImage { - pub build_timestamp: Option, - pub kubernetes_deb_version: Option, - pub kubernetes_rpm_version: Option, - pub kubernetes_semver: Option, - pub kubernetes_series: Option, -} - -impl DataTrait for KubernetesImage { - // set_format set kubernetes spec based on kubernetes version spec - fn set_format(&mut self) -> Result<(), DataError> { - let time_now = Utc::now(); - let timestamp = time_now.timestamp(); - self.build_timestamp = Some(timestamp.to_string()); - let kubernetes_version = String::from( - self.kubernetes_semver - .to_owned() - .as_deref() - .unwrap_or("v1.22.1"), - ); - let kubernetes_deb_version = String::from(&kubernetes_version.replace("v", "")) + "-1.1"; - self.kubernetes_deb_version = Some(kubernetes_deb_version); - let kubernetes_rpm_version = String::from(&kubernetes_version.replace("v", "")); - self.kubernetes_rpm_version = Some(kubernetes_rpm_version); - println!( - "kubernetes json build timestamp: {}", - String::from( - self.build_timestamp - .to_owned() - .as_deref() - .unwrap_or("nightly") - ) - ); - println!( - "kubernetes semvers: {}", - self.kubernetes_semver - .to_owned() - .as_deref() - .unwrap_or("v1.22.1") - ); - println!( - "kubernetes series: {}", - self.kubernetes_series - .to_owned() - .as_deref() - .unwrap_or("v1.22") - ); - println!( - "kubernetes rpm version: {:?}", - self.kubernetes_rpm_version - .to_owned() - .as_deref() - .unwrap_or("1.22.1-1.1") - ); - println!( - "kubernetes deb version: {:?}", - self.kubernetes_deb_version - .to_owned() - .as_deref() - .unwrap_or("1.22.1") - ); - Ok(()) - } -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct DataError { - pub output: String, -} - -impl fmt::Display for DataError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.output) - } -} -impl Error for DataError { - fn description(&self) -> &str { - &self.output - } -} -impl Datas { - // set_format set format for kubernetes image - pub fn set_format(&mut self) -> Result<(), DataError> { - for data in self.datas.iter_mut() { - match data { - Data::KubernetesImage(kubernetes_image) => kubernetes_image.set_format()?, - } - } - Ok(()) - } - // json set data to json format with string - pub fn json(&self) -> serde_json::Result { - let mut out = String::new(); - for data in &self.datas { - match serde_json::to_string(data) { - Ok(serialized) => out.push_str(serialized.as_str()), - Err(e) => { - warn!("trouble to serialize json: {}", e); - continue; - } - } - out.push('\n'); - } - out.pop(); - Ok(out) - } -} - -trait DataTrait { - fn set_format(&mut self) -> Result<(), DataError>; -} - -#[cfg(test)] -mod datas_test { - use super::*; - - #[test] - // set_format_test validate set_format function - fn set_format_test() { - let kubernetes_image = KubernetesImage { - build_timestamp: Some("".to_string()), - kubernetes_deb_version: Some("".to_string()), - kubernetes_rpm_version: Some("".to_string()), - kubernetes_semver: Some("v1.22.1".to_string()), - kubernetes_series: Some("v1.22".to_string()), - }; - let data = Data::KubernetesImage(kubernetes_image); - let mut datas = Vec::::new(); - datas.push(data); - let mut data_struct = Datas { datas: datas }; - if let Err(error) = data_struct.set_format() { - warn!("can not set format {}", error); - } - for kubernetes_datas in data_struct.datas { - let Data::KubernetesImage(kubernetes) = kubernetes_datas; - println!("value: {:#?}", kubernetes); - assert_eq!( - kubernetes.kubernetes_rpm_version, - Some("1.22.1".to_string()) - ) - } - } - - #[test] - // json_test validate json function - fn json_test() { - let kubernetes_image = KubernetesImage { - build_timestamp: Some("1670519118".to_string()), - kubernetes_deb_version: Some("1.22.1-00".to_string()), - kubernetes_rpm_version: Some("1.22.1-0".to_string()), - kubernetes_semver: Some("v1.22.1".to_string()), - kubernetes_series: Some("v1.22".to_string()), - }; - let data = Data::KubernetesImage(kubernetes_image); - - let mut datas = Vec::::new(); - datas.push(data); - let data_struct = Datas { datas: datas }; - let output = match data_struct.json() { - Ok(json_format) => json_format, - Err(error) => error.to_string(), - }; - assert_eq!(output, "{\"build_timestamp\":\"1670519118\",\"kubernetes_deb_version\":\"1.22.1-00\",\"kubernetes_rpm_version\":\"1.22.1-0\",\"kubernetes_semver\":\"v1.22.1\",\"kubernetes_series\":\"v1.22\"}"); - } -} diff --git a/hack/json-format/src/input.rs b/hack/json-format/src/input.rs deleted file mode 100644 index 0f6d90eab..000000000 --- a/hack/json-format/src/input.rs +++ /dev/null @@ -1,114 +0,0 @@ -use crate::core::{self, Datas}; -use lazy_static::lazy_static; -use regex::Regex; -use serde::{Deserialize, Serialize}; -use std::error; -use std::process::exit; - -#[derive(Deserialize, Serialize, Debug, Clone)] -pub struct KubernetesVersions { - pub kubernetes_semver: String, - pub kubernetes_series: String, -} - -#[derive(Deserialize, Serialize, Debug, Clone)] -pub struct KubernetesSpecs { - pub build_timestamp: Option, - pub kubernetes_deb_version: Option, - pub kubernetes_rpm_version: Option, - pub kubernetes_semver: Option, - pub kubernetes_series: Option, -} - -#[derive(Deserialize, Serialize, Debug, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Input { - pub kubernetes: Vec, -} -// from will turn input into data -impl From for core::Datas { - fn from(input: Input) -> Self { - let mut datas = core::Datas { datas: Vec::new() }; - input.fill_data_kubernetes(&mut datas); - datas - } -} - -impl Input { - // new will create vector of kubernetes version based on params - pub fn new( - kubernetes_semver: &str, - kubernetes_series: &str, - format: &str, - ) -> Result> { - let data = match format { - "params" => { - let mut kubernetes = Vec::::new(); - let kubernetes_version = KubernetesVersions { - kubernetes_semver: kubernetes_semver.to_string(), - kubernetes_series: kubernetes_series.to_string(), - }; - kubernetes.push(kubernetes_version); - Input { kubernetes } - } - _ => { - println!("Unknown format {:#?}", format); - exit(1); - } - }; - Ok(data) - } - // fill_data_kubernetes add in data kubernetes spec for image-builder - fn fill_data_kubernetes(&self, datas: &mut Datas) { - for kubernetes_version in &self.kubernetes { - let specs = match KubernetesSpecs::new(kubernetes_version) { - Some(specs) => specs, - None => continue, - }; - let core_kubernetes = core::KubernetesImage { - kubernetes_semver: specs.kubernetes_semver, - kubernetes_series: specs.kubernetes_series, - kubernetes_deb_version: specs.kubernetes_deb_version, - kubernetes_rpm_version: specs.kubernetes_rpm_version, - build_timestamp: specs.build_timestamp, - }; - datas - .datas - .push(core::Data::KubernetesImage(core_kubernetes)) - } - } -} -impl KubernetesSpecs { - // new will create kubernetesSpec for imageBuilder based on kubernetes params - fn new(kubernetes: &KubernetesVersions) -> Option { - let kubernetes_semver = &kubernetes.kubernetes_semver; - let kubernetes_series = &kubernetes.kubernetes_series; - lazy_static! { - static ref REG_KUBERNETES_SEMVER: Regex = - Regex::new(r"^v\d{1}.\d{2}.\d{1,2}$").unwrap(); - static ref REG_KUBERNETES_SERIES: Regex = Regex::new(r"^v\d{1}.\d{2}$").unwrap(); - } - match REG_KUBERNETES_SEMVER.is_match(kubernetes_semver.as_str()) { - true => println!("{} has good format", kubernetes_semver), - false => { - println!("{} has bad format", kubernetes_semver); - exit(1); - } - } - match REG_KUBERNETES_SERIES.is_match(kubernetes_series.as_str()) { - true => println!("{} has good format", kubernetes_series), - false => { - println!("{} has bad format", kubernetes_series); - exit(1); - } - } - let out = KubernetesSpecs { - kubernetes_semver: Some(String::from(kubernetes_semver)), - kubernetes_series: Some(String::from(kubernetes_series)), - kubernetes_deb_version: None, - kubernetes_rpm_version: None, - build_timestamp: None, - }; - Some(out) - } -} diff --git a/hack/json-format/src/lib.rs b/hack/json-format/src/lib.rs deleted file mode 100644 index 2c30563c7..000000000 --- a/hack/json-format/src/lib.rs +++ /dev/null @@ -1,106 +0,0 @@ -use clap::Parser; -use log::error; -use serde::{Deserialize, Serialize}; -use std::error; -use std::process::exit; -mod core; -mod input; - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct KubernetesVersion { - pub kubernetes_output: String, -} -// create_kubernete_json create json file for image-builder based on kubernetes version parameters -pub fn create_kubernetes_json() -> KubernetesVersion { - #[derive(Parser, Debug)] - #[command(author, version, about, long_about=None)] - struct Args { - #[arg(long, default_value_t = String::from("params"))] - format: String, - #[arg(long, short = 'i')] - input: Option, - #[arg(long, short = 'o')] - output: Option, - #[arg(long, short = 'r')] - kubernetes_semver: Option, - #[arg(long, short = 'v')] - kubernetes_series: Option, - } - let args = Args::parse(); - let mut datas: core::Datas; - let input = match args.format.as_str() { - "params" => { - let kubernetes_default_semver = "v1.22.1"; - let kubernetes_semver = match args.kubernetes_semver.as_deref() { - Some(kubernetes_semver) => kubernetes_semver, - None => kubernetes_default_semver, - }; - let kubernetes_default_series = "v1.22"; - let kubernetes_series = match args.kubernetes_series.as_deref() { - Some(kubernetes_series) => kubernetes_series, - None => kubernetes_default_series, - }; - - match input::Input::new(kubernetes_semver, kubernetes_series, "params") { - Ok(kubernetes_versions) => kubernetes_versions, - Err(err) => { - println!("{:#?}", err); - exit(1); - } - } - } - _ => { - println!("Unknown format {:#?}", args.input); - exit(1); - } - }; - - datas = core::Datas::from(input); - if let Err(error) = datas.set_format() { - error!("can not set format {}", error); - exit(1); - } - - let output: String = match datas.json() { - Ok(json_format) => json_format, - Err(error) => { - error!("{}", error); - exit(1); - } - }; - if let Some(output_file) = args.output.as_deref() { - write_to_json(output_file, output).unwrap_or_else(|error| { - error!("Can not create json file {:?}", error); - exit(1); - }); - } else { - println!("{}", output); - } - KubernetesVersion { - kubernetes_output: match datas.json() { - Ok(json_format) => json_format, - Err(error) => { - error!("{}", error); - exit(1); - } - }, - } -} - -pub fn main() { - create_kubernetes_json(); -} -// write_to_json write json file -pub fn write_to_json(output_path: &str, output_data: String) -> Result<(), Box> { - let output_json_data: core::Data = serde_json::from_str(output_data.as_str()).unwrap(); - match std::fs::write( - output_path, - serde_json::to_string_pretty(&output_json_data).unwrap(), - ) { - Ok(file) => Ok(file), - Err(err) => { - error!("Can not create json file {}", err); - exit(1); - } - } -} diff --git a/hack/json-format/src/main.rs b/hack/json-format/src/main.rs deleted file mode 100644 index 49b64ad36..000000000 --- a/hack/json-format/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - json_format::main() -} diff --git a/hack/json-format/tests/integration_test.rs b/hack/json-format/tests/integration_test.rs deleted file mode 100644 index 88d291e11..000000000 --- a/hack/json-format/tests/integration_test.rs +++ /dev/null @@ -1,11 +0,0 @@ -extern crate json_format; -use json_format::create_kubernetes_json; - -#[test] -// success check create_kubernetes_json is a success -fn success() { - let kubernetes_version = create_kubernetes_json(); - let mut kubernetes_image = kubernetes_version.kubernetes_output; - let _ = kubernetes_image.drain(1..32); - assert_eq!(kubernetes_image, "{\"kubernetes_deb_version\":\"1.22.1-1.1\",\"kubernetes_rpm_version\":\"1.22.1\",\"kubernetes_semver\":\"v1.22.1\",\"kubernetes_series\":\"v1.22\"}"); -} diff --git a/templates/cluster-template-secure.yaml b/templates/cluster-template-secure.yaml index e02874d33..ce55e3fcf 100644 --- a/templates/cluster-template-secure.yaml +++ b/templates/cluster-template-secure.yaml @@ -27,6 +27,7 @@ spec: subregionName: ${OSC_SUBREGION_NAME} loadBalancer: loadbalancername: "${CLUSTER_NAME}-k8s" + natPublicIpPool: ${OSC_NAT_IP_POOL:=""} allowFromIPRanges: - ${OSC_ALLOW_FROM} - ${OSC_ALLOW_FROM_CAPI} @@ -66,15 +67,16 @@ spec: node: image: name: "${OSC_IMAGE_NAME}" - accountId: "${OSC_IMAGE_ACCOUNT_ID}" + accountId: ${OSC_IMAGE_ACCOUNT_ID:=""} + outscaleOpenSource: ${OSC_IMAGE_OPENSOURCE:=false} vm: rootDisk: rootDiskSize: ${OSC_VOLUME_SIZE} - rootDiskIops: ${OSC_IOPS} - rootDiskType: "${OSC_VOLUME_TYPE}" + rootDiskIops: ${OSC_IOPS:=0} + rootDiskType: ${OSC_VOLUME_TYPE:=gp2} keypairName: "${OSC_KEYPAIR_NAME}" subregionName: ${OSC_SUBREGION_NAME} - vmType: "${OSC_VM_TYPE}" + vmType: ${OSC_VM_TYPE} --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OscMachineTemplate @@ -86,15 +88,16 @@ spec: node: image: name: "${OSC_IMAGE_NAME}" - accountId: "${OSC_IMAGE_ACCOUNT_ID}" + accountId: ${OSC_IMAGE_ACCOUNT_ID:=""} + outscaleOpenSource: ${OSC_IMAGE_OPENSOURCE:=false} vm: keypairName: "${OSC_KEYPAIR_NAME}" rootDisk: rootDiskSize: ${OSC_VOLUME_SIZE} - rootDiskIops: ${OSC_IOPS} - rootDiskType: "${OSC_VOLUME_TYPE}" + rootDiskIops: ${OSC_IOPS:=0} + rootDiskType: ${OSC_VOLUME_TYPE:=gp2} role: controlplane - vmType: "${OSC_VM_TYPE}" + vmType: ${OSC_VM_TYPE} --- apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 kind: KubeadmConfigTemplate diff --git a/templates/cluster-template.yaml b/templates/cluster-template.yaml index 8466219ce..1d70f796b 100644 --- a/templates/cluster-template.yaml +++ b/templates/cluster-template.yaml @@ -66,8 +66,8 @@ spec: vm: rootDisk: rootDiskSize: ${OSC_VOLUME_SIZE} - rootDiskIops: ${OSC_IOPS} - rootDiskType: "${OSC_VOLUME_TYPE}" + rootDiskIops: ${OSC_IOPS:=} + rootDiskType: "${OSC_VOLUME_TYPE:=gp2}" keypairName: "${OSC_KEYPAIR_NAME}" subregionName: ${OSC_SUBREGION_NAME} vmType: "${OSC_VM_TYPE}" @@ -86,8 +86,8 @@ spec: keypairName: "${OSC_KEYPAIR_NAME}" rootDisk: rootDiskSize: ${OSC_VOLUME_SIZE} - rootDiskIops: ${OSC_IOPS} - rootDiskType: "${OSC_VOLUME_TYPE}" + rootDiskIops: ${OSC_IOPS:=} + rootDiskType: "${OSC_VOLUME_TYPE:=gp2}" role: controlplane vmType: "${OSC_VM_TYPE}" --- diff --git a/test/e2e/common.go b/test/e2e/common.go index 0af5cd371..204f7eab9 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -9,73 +9,22 @@ package e2e import ( "context" "fmt" - "path/filepath" - . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/ginkgo/v2" //nolint corev1 "k8s.io/api/core/v1" - - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" - "sigs.k8s.io/cluster-api/util" ) const ( KubernetesVersion = "KUBERNETES_VERSION" ) -func Byf(format string, a ...interface{}) { - By(fmt.Sprintf(format, a...)) -} - -// setupSpecNamespace create the namespace -func setupSpecNamespace(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string) (*corev1.Namespace, context.CancelFunc) { - Byf("Creating a namespace for hosting the %q test spec", specName) - namespace, cancelWatches := framework.CreateNamespaceAndWatchEvents(ctx, framework.CreateNamespaceAndWatchEventsInput{ - Creator: clusterProxy.GetClient(), - ClientSet: clusterProxy.GetClientSet(), - Name: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), - LogFolder: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName()), - }) - - return namespace, cancelWatches -} - // Create the namespace func createNamespace(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, timeout string, interval string) *corev1.Namespace { - Byf("Creating a namespace %s for bootstrap cluster", specName) + By(fmt.Sprintf("Creating a namespace %s for bootstrap cluster", specName)) namespace := framework.CreateNamespace(ctx, framework.CreateNamespaceInput{ Creator: clusterProxy.GetClient(), Name: specName, }, timeout, interval) return namespace } - -// dumpSpecResourcesAndCleanup dump all ressource and delete cluster and namespace -func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cancelWatches context.CancelFunc, cluster *clusterv1.Cluster, intervalsGetter func(spec, key string) []interface{}, skipCleanup bool) { - Byf("Dumping logs from the %q workload cluster", cluster.Name) - - clusterProxy.CollectWorkloadClusterLogs(ctx, cluster.Namespace, cluster.Name, filepath.Join(artifactFolder, "clusters", cluster.Name)) - - Byf("Dumping all the Cluster API resources in the %q namespace", namespace.Name) - - framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{ - Lister: clusterProxy.GetClient(), - Namespace: namespace.Name, - LogPath: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName(), "resources"), - }) - - if !skipCleanup { - Byf("Deleting cluster %s/%s", cluster.Namespace, cluster.Name) - framework.DeleteAllClustersAndWait(ctx, framework.DeleteAllClustersAndWaitInput{ - ClusterProxy: clusterProxy, - Namespace: namespace.Name, - }, intervalsGetter(specName, "wait-delete-cluster")...) - - Byf("Deleting namespace used for hosting the %q test spec", specName) - framework.DeleteNamespace(ctx, framework.DeleteNamespaceInput{ - Deleter: clusterProxy.GetClient(), - Name: namespace.Name, - }) - } - cancelWatches() -} diff --git a/test/e2e/config/outscale.yaml b/test/e2e/config/outscale.yaml index 3a9208993..32a6bb08f 100644 --- a/test/e2e/config/outscale.yaml +++ b/test/e2e/config/outscale.yaml @@ -90,16 +90,16 @@ variables: EXP_MACHINE_POOL: "true" CLUSTER_TOPOLOGY: "true" EXP_RUNTIME_SDK: "true" - ETCD_VERSION_UPGRADE_TO: "3.5.10-0" - COREDNS_VERSION_UPGRADE_TO: "v1.10.1" + ETCD_VERSION_UPGRADE_TO: "${ETCD_VERSION_UPGRADE_TO:=3.6.4-0}" + COREDNS_VERSION_UPGRADE_TO: "${COREDNS_VERSION_UPGRADE_TO:=v1.11.4}" IP_FAMILY: "IPv4" - KUBERNETES_VERSION_MANAGEMENT: "v1.30.14" - KUBERNETES_VERSION: "v1.30.14" - KUBERNETES_VERSION_UPGRADE_FROM: "v1.30.14" - KUBERNETES_VERSION_UPGRADE_TO: "v1.31.10" + KUBERNETES_VERSION_MANAGEMENT: "${KUBERNETES_VERSION_MANAGEMENT:=v1.30.14}" + KUBERNETES_VERSION: "${KUBERNETES_VERSION:=v1.30.14}" + KUBERNETES_VERSION_UPGRADE_FROM: "${KUBERNETES_VERSION_UPGRADE_FROM:=v1.30.14}" + KUBERNETES_VERSION_UPGRADE_TO: "${KUBERNETES_VERSION_UPGRADE_TO:=v1.31.10}" TEMPLATE_PATH: "${PWD}/test/e2e/data/infrastructure-outscale/cluster-template.yaml" - KUBERNETES_IMAGE_UPGRADE_FROM: "${IMG_UPGRADE_FROM:ubuntu-2204-kubernetes-v1.30.14-2025-08-28}" - KUBERNETES_IMAGE_UPGRADE_TO: "${IMG_UPGRADE_TO:ubuntu-2204-kubernetes-v1.31.12-2025-08-27}" + KUBERNETES_IMAGE_UPGRADE_FROM: "${IMG_UPGRADE_FROM:=ubuntu-2204-kubernetes-v1.30.14-2025-08-28}" + KUBERNETES_IMAGE_UPGRADE_TO: "${IMG_UPGRADE_TO:=ubuntu-2204-kubernetes-v1.31.12-2025-08-27}" IMAGE_ACCOUNT_ID: "${IMAGE_ACCOUNT_ID}" CONTROL_PLANE_MACHINE_TEMPLATE_UPGRADE_TO: "cp-k8s-upgrade-and-conformance" WORKERS_MACHINE_TEMPLATE_UPGRADE_TO: "worker-k8s-upgrade-and-conformance" diff --git a/test/e2e/conformance_test.go b/test/e2e/conformance_test.go index 5edf00bad..985763344 100644 --- a/test/e2e/conformance_test.go +++ b/test/e2e/conformance_test.go @@ -13,8 +13,8 @@ import ( capi_e2e "sigs.k8s.io/cluster-api/test/e2e" ) -var _ = Describe("[conformance] Test kubernetes conformance", func() { - Context("Run the k8s conformance", func() { +var _ = Describe("[conformance][all] Test kubernetes conformance", func() { + Context("Run the k8s conformance on a standard cluster", func() { capi_e2e.K8SConformanceSpec(context.TODO(), func() capi_e2e.K8SConformanceSpecInput { return capi_e2e.K8SConformanceSpecInput{ E2EConfig: e2eConfig, diff --git a/test/e2e/node_test.go b/test/e2e/node_test.go index 662ba3711..3e74a5253 100644 --- a/test/e2e/node_test.go +++ b/test/e2e/node_test.go @@ -15,7 +15,7 @@ import ( ) var _ = Describe("Node drain", func() { - Context("[node-drain][all] Run node drain test", func() { + Context("[node-drain] Run node drain test", func() { // FIXME: NodeDrainTimeoutSpec expects a topology template, disabling for now. capi_e2e.NodeDrainTimeoutSpec(context.TODO(), func() capi_e2e.NodeDrainTimeoutSpecInput { return capi_e2e.NodeDrainTimeoutSpecInput{ E2EConfig: e2eConfig, diff --git a/test/e2e/repository.go b/test/e2e/repository.go index 286cc9ead..a46bcbf63 100644 --- a/test/e2e/repository.go +++ b/test/e2e/repository.go @@ -14,7 +14,8 @@ import ( "path/filepath" "strings" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint + . "github.com/onsi/gomega" //nolint clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/yaml" @@ -102,7 +103,7 @@ func CreateRepository(ctx context.Context, input CreateRepositoryInput) string { } func (i *CreateRepositoryInput) RegisterClusterResourceSetConfigMapTransformation(manifestPath, envSubstVar string) { - Byf("Reading the ClusterResourceSet manifest %s", manifestPath) + By("Reading the ClusterResourceSet manifest " + manifestPath) manifestData, err := os.ReadFile(manifestPath) //nolint:gosec Expect(err).ToNot(HaveOccurred(), "Failed to read the ClusterResourceSet manifest file") Expect(manifestData).ToNot(BeEmpty(), "ClusterResourceSet manifest file should not be empty") diff --git a/test/e2e/e2e_test.go b/test/e2e/scale_test.go similarity index 68% rename from test/e2e/e2e_test.go rename to test/e2e/scale_test.go index 367a86f0f..a5ca12645 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/scale_test.go @@ -16,14 +16,15 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util" ) -var _ = Describe("[e2e][all] Running the Cluster API E2E tests", func() { +var _ = Describe("[e2e][all] Scaling a cluster", func() { var ( ctx = context.TODO() - specName = "e2e" + specName = "scaling" namespace *corev1.Namespace cancelWatches context.CancelFunc result *clusterctl.ApplyClusterTemplateAndWaitResult @@ -34,14 +35,14 @@ var _ = Describe("[e2e][all] Running the Cluster API E2E tests", func() { Expect(e2eConfig).ToNot(BeNil(), "Invalid argument. e2eConfig can't be nil when calling %s spec", specName) Expect(clusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. clusterctlConfigPath must be an existing file when calling %s spec", specName) Expect(bootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. bootstrapClusterProxy can't be nil when calling %s spec", specName) - Expect(os.MkdirAll(artifactFolder, 0o755)).To(Succeed(), "Invalid argument. artifactFolder can't be created for %s spec", specName) + Expect(os.MkdirAll(artifactFolder, 0750)).To(Succeed(), "Invalid argument. artifactFolder can't be created for %s spec", specName) Expect(e2eConfig.Variables).To(HaveKey(KubernetesVersion)) clusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6)) // Setup a Namespace where to host objects for this spec and create a watcher for the namespace events. - namespace, cancelWatches = setupSpecNamespace(ctx, specName, bootstrapClusterProxy, artifactFolder) + namespace, cancelWatches = framework.SetupSpecNamespace(ctx, specName, bootstrapClusterProxy, artifactFolder, nil) result = new(clusterctl.ApplyClusterTemplateAndWaitResult) }) @@ -85,32 +86,11 @@ var _ = Describe("[e2e][all] Running the Cluster API E2E tests", func() { WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), }, result) - }) - }) - - Context("Creating a HA control-plane cluster", func() { - It("Should create a cluster with 3 control planes and 2 worker nodes", func() { - clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ - ClusterProxy: bootstrapClusterProxy, - ConfigCluster: clusterctl.ConfigClusterInput{ - LogFolder: filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()), - ClusterctlConfigPath: clusterctlConfigPath, - KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(), - InfrastructureProvider: infraProvider, - Namespace: namespace.Name, - ClusterName: clusterName, - KubernetesVersion: e2eConfig.Variables[KubernetesVersion], - ControlPlaneMachineCount: ptr.To(int64(3)), - WorkerMachineCount: ptr.To(int64(2)), - }, - WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"), - WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), - WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), - }, result) + By("PASSED!") }) }) AfterEach(func() { - dumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, cancelWatches, result.Cluster, e2eConfig.GetIntervals, skipCleanup) + framework.DumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, clusterctlConfigPath, artifactFolder, namespace, cancelWatches, result.Cluster, e2eConfig.GetIntervals, skipCleanup) }) }) diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index b80f99dcf..e79220de8 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -6,11 +6,10 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "k8s.io/utils/ptr" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" ) -var _ = Describe("[ugrade][all] Running the Cluster API upgrade tests", func() { +var _ = Describe("[upgrade][all] Running the Cluster API upgrade tests", func() { ctx := context.TODO() BeforeEach(func() { @@ -36,20 +35,4 @@ var _ = Describe("[ugrade][all] Running the Cluster API upgrade tests", func() { } }) }) - - Context("Running KCP upgrade in a HA cluster", func() { - capi_e2e.ClusterUpgradeConformanceSpec(ctx, func() capi_e2e.ClusterUpgradeConformanceSpecInput { - return capi_e2e.ClusterUpgradeConformanceSpecInput{ - E2EConfig: e2eConfig, - ClusterctlConfigPath: clusterctlConfigPath, - InfrastructureProvider: &infraProvider, - BootstrapClusterProxy: bootstrapClusterProxy, - ArtifactFolder: artifactFolder, - ControlPlaneMachineCount: ptr.To[int64](3), - WorkerMachineCount: ptr.To[int64](1), - SkipCleanup: skipCleanup, - SkipConformanceTests: true, - } - }) - }) })