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

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

hjiajing
Copy link
Contributor

@hjiajing hjiajing commented Jun 5, 2024

When triggering Manually upstream conformance test on Linux, if the input kubernetes version has no corresponding kind node image, the job will build a kind Node image with the 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 Outdated 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

@luolanzone luolanzone Jun 11, 2024

Choose a reason for hiding this comment

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

Does 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 Outdated 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.

Comment on lines 675 to 680
git clone https://github.com/kubernetes/kubernetes.git ${THIS_DIR}/kubernetes
tag=${K8S_VERSION}
if [[ $K8S_VERSION == "latest" ]]; then
tag="master"
fi
git -C ${THIS_DIR}/kubernetes checkout $tag
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
git clone https://github.com/kubernetes/kubernetes.git ${THIS_DIR}/kubernetes
tag=${K8S_VERSION}
if [[ $K8S_VERSION == "latest" ]]; then
tag="master"
fi
git -C ${THIS_DIR}/kubernetes checkout $tag
tag=${K8S_VERSION}
if [[ $K8S_VERSION == "latest" ]]; then
tag="master"
fi
git clone --branch $tag --depth 1 https://github.com/kubernetes/kubernetes.git ${THIS_DIR}/kubernetes
# time git clone https://github.com/kubernetes/kubernetes.git
real	1m22.043s
user	4m29.718s
sys	0m39.540s

# time git clone --branch v1.30.0 --depth 1 https://github.com/kubernetes/kubernetes.git kubernetes-depth
real	0m11.055s
user	0m5.463s
sys	0m1.935s

# du -sh *
1.4G	kubernetes
387M	kubernetes-depth

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i tried use --branch --depth 1, but I found that when kind tries to build images from master branch, it cannot found workspace information as follows:

hjiajing@ubuntu-dev (master) [130] % ./hack/print-workspace-status.sh                                                                                                                                                              ~/kubernetes
STABLE_BUILD_GIT_COMMIT 3125877de0aefbb642833beaa3a4c189d833e797
STABLE_BUILD_SCM_STATUS clean
STABLE_BUILD_SCM_REVISION
STABLE_BUILD_MAJOR_VERSION
STABLE_BUILD_MINOR_VERSION
STABLE_DOCKER_TAG
STABLE_DOCKER_REGISTRY registry.k8s.io
STABLE_DOCKER_PUSH_REGISTRY staging-k8s.gcr.io
gitCommit 3125877de0aefbb642833beaa3a4c189d833e797
gitTreeState clean
gitVersion
gitMajor
gitMinor
buildDate 2024-07-09T02:48:57Z

But since we decide not to support master branch, we can use --branch --depth now.

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

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

A nit

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

# Build Kind node image with the specified K8s version if it doesn't exist in local and remote registry neither
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "neither", or change to "in either the local or remote registry".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Quan's comment, this part is moved to conformance.yml, this comment is removed.

tnqn
tnqn previously approved these changes Jul 9, 2024
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Jul 9, 2024

The PR description needs update

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 <[email protected]>
@hjiajing
Copy link
Contributor Author

The PR description needs update

Updated, thanks for the reminder.

@tnqn
Copy link
Member

tnqn commented Jul 11, 2024

/skip-all

1 similar comment
@tnqn
Copy link
Member

tnqn commented Jul 11, 2024

/skip-all

@tnqn tnqn merged commit 42a0aaa into antrea-io:main Jul 11, 2024
54 of 58 checks passed
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.

5 participants