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

Add support for building local kind Node image #6399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hjiajing
Copy link
Contributor

@hjiajing hjiajing commented Jun 5, 2024

When triggering Manually upstream conformance test on Linux, if the input kubernetes version is "latest", the job will build kind Node image with the latest Kubernetes source code, and create Kind Cluster with local Node image.

@hjiajing hjiajing requested a review from luolanzone June 5, 2024 02:15
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Prepare local Machine for Conformance test
run: |
if [ "${{ inputs.k8s-version }}" != "latest" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support both branch and tags like 'v1.30.0-rc.0', 'v1.31.0-alpha.0' from K8s repo. The purpose to build local Kind image is to run comformance test against the latest one or different release candidates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, replaced this if condition with a regex.

Comment on lines 669 to 672
# When k8s-version is "latest", build node image with the latest k8s version
if [[ "$K8S_VERSION" == "latest" ]]; then
echo "=== Building kind node image with the latest k8s version ==="
kind_node_image="kindest/node:latest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# When k8s-version is "latest", build node image with the latest k8s version
if [[ "$K8S_VERSION" == "latest" ]]; then
echo "=== Building kind node image with the latest k8s version ==="
kind_node_image="kindest/node:latest"
# When k8s-version is "latest", build node image with the latest K8s version
if [[ "$K8S_VERSION" == "latest" ]]; then
echo "=== Building Kind node image with the latest K8s version ==="
kind_node_image="kindest/node:latest"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ci/run-k8s-e2e-tests.sh Show resolved Hide resolved
conformance_image_options=()
# If the K8s version is 'latest', we need to find the latest conformance image.
if [ ${{ inputs.k8s-version == 'latest' }} ]; then
conformance_image_options+=(--conformance-image "registry.k8s.io/conformance:$(skopeo list-tags docker://registry.k8s.io/conformance | jq -r '.Tags[]' | sort -V | tail -n 1)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
conformance_image_options+=(--conformance-image "registry.k8s.io/conformance:$(skopeo list-tags docker://registry.k8s.io/conformance | jq -r '.Tags[]' | sort -V | tail -n 1)")
latest_tag=$(skopeo list-tags docker://registry.k8s.io/conformance | jq -r '.Tags[]' | sort -V | tail -n 1)
# Add the conformance image option
conformance_image_options+=(--conformance-image "registry.k8s.io/conformance:$latest_tag")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, thanks for then comment.

@@ -665,6 +666,14 @@ if version_lt "$kind_version" "0.12.0" && [[ "$KUBE_PROXY_MODE" == "none" ]]; th
exit 1
fi

# When k8s-version is not vx.y.z, we need to build the K8s node image in local.
if [[ ! $K8S_VERSION =~ ^(v)?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it mean we can only support local K8s node image building when the K8s version like v1.30.0-alpha, v1.31.0-rc1?
How do we support a future version like v1.31.0 when the Kind haven't supported it yet in its release?
For example, Kind 0.23 only supports following images by default:
https://github.com/kubernetes-sigs/kind/releases/tag/v0.23.0

Images pre-built for this release:

    v1.30.0: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
    v1.29.4: kindest/node:v1.29.4@sha256:3abb816a5b1061fb15c6e9e60856ec40d56b7b52bcea5f5f1350bc6e2320b6f8
    v1.28.9: kindest/node:v1.28.9@sha256:dca54bc6a6079dd34699d53d7d4ffa2e853e46a20cd12d619a09207e35300bd0
    v1.27.13: kindest/node:v1.27.13@sha256:17439fa5b32290e3ead39ead1250dca1d822d94a10d26f1981756cd51b24b9d8
    v1.26.15: kindest/node:v1.26.15@sha256:84333e26cae1d70361bb7339efb568df1871419f2019c80f9a12b7e2d485fe19
    v1.25.16: kindest/node:v1.25.16@sha256:5da57dfc290ac3599e775e63b8b6c49c0c85d3fec771cd7d55b45fae14b38d3b

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we cannot guarantee Kind will release the latest K8s Node, so I used docker pull command to check whether the Node image exists or not. If not, then we will try to build image in local.

Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, two nits

.github/workflows/conformance.yml Outdated Show resolved Hide resolved
.github/workflows/conformance.yml Show resolved Hide resolved
ci/kind/kind-setup.sh Outdated Show resolved Hide resolved
@luolanzone
Copy link
Contributor

@hjiajing please update the PR details info.

When trigger Manually  upstream conformance test on Linux, if the input
kubernetes version has no corresponding kind Node image, the job will build
kind Node image with the Kubernetes source code.

Signed-off-by: Jiajing Hu <hjiajing@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants