Skip to content

Commit

Permalink
Merge pull request #1230 from s1061123/update-kind
Browse files Browse the repository at this point in the history
Update kind e2e
  • Loading branch information
dougbtv committed Feb 15, 2024
2 parents ba18cf5 + 03fcb34 commit ca5a4c9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 55 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/kind-e2e.yml
Expand Up @@ -48,9 +48,6 @@ jobs:
sudo apt-get install -y j2cli
echo $(j2 --version)
- name: Setup registry
run: docker run -d --restart=always -p "5000:5000" --name "kind-registry" registry:2

- name: Build latest-amd64
uses: docker/build-push-action@v5
with:
Expand All @@ -60,10 +57,6 @@ jobs:
file: ${{ matrix.docker-file }}
platforms: linux/amd64

# docker buildx push is failed due to https://github.com/docker/buildx/issues/94
- name: Push to local registry
run: docker push localhost:5000/multus:e2e

- name: Get kind/kubectl/koko
working-directory: ./e2e
run: ./get_tools.sh
Expand All @@ -74,7 +67,7 @@ jobs:

- name: Setup cluster
working-directory: ./e2e
run: MULTUS_MANIFEST=${{ matrix.multus-manifest }} ./setup_cluster.sh
run: MULTUS_MANIFEST=${{ matrix.multus-manifest }} MULTUS_DOCKERFILE=none ./setup_cluster.sh

- name: Test simple pod
working-directory: ./e2e
Expand Down Expand Up @@ -108,5 +101,3 @@ jobs:
- name: cleanup cluster and registry
run: |
kind delete cluster
docker kill kind-registry
docker rm kind-registry
2 changes: 1 addition & 1 deletion e2e/get_tools.sh
Expand Up @@ -5,7 +5,7 @@ if [ ! -d bin ]; then
mkdir bin
fi

curl -Lo ./bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.20.0/kind-$(uname)-amd64"
curl -Lo ./bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.22.0/kind-$(uname)-amd64"
chmod +x ./bin/kind
curl -Lo ./bin/kubectl https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./bin/kubectl
Expand Down
45 changes: 5 additions & 40 deletions e2e/setup_cluster.sh
Expand Up @@ -14,32 +14,17 @@ MULTUS_MANIFEST="${MULTUS_MANIFEST:-multus-daemonset-thick.yml}"
# define the dockerfile to build multus.
# Acceptable values are `Dockerfile`. `Dockerfile.thick`.
# Defaults to `Dockerfile.thick`.
MULTUS_DOCKERFILE="${MULTUS_MANIFEST:-Dockerfile.thick}"
MULTUS_DOCKERFILE="${MULTUS_DOCKERFILE:-Dockerfile.thick}"

kind_network='kind'
reg_name='kind-registry'
reg_port='5000'
running="$($OCI_BIN inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
# run registry and push the multus image
$OCI_BIN run -d --restart=always -p "${reg_port}:5000" --name "${reg_name}" registry:2
$OCI_BIN build -t localhost:5000/multus:e2e -f ../images/${MULTUS_DOCKERFILE} ..
$OCI_BIN push localhost:5000/multus:e2e
if [ "${MULTUS_DOCKERFILE}" != "none" ]; then
$OCI_BIN build -t localhost:5000/multus:e2e -f ../images/${MULTUS_DOCKERFILE} ..
fi
reg_host="${reg_name}"
if [ "${kind_network}" = "bridge" ]; then
reg_host="$($OCI_BIN inspect -f '{{.NetworkSettings.IPAddress}}' "${reg_name}")"
fi
echo "Registry Host: ${reg_host}"

# deploy cluster with kind
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
endpoint = ["http://${reg_host}:${reg_port}"]
nodes:
- role: control-plane
- role: worker
Expand All @@ -52,28 +37,8 @@ nodes:
- role: worker
EOF

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: local-registry-hosting
namespace: kube-public
data:
localRegistryHosting.v1: |
host: "localhost:${reg_port}"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
EOF

containers=$($OCI_BIN network inspect ${kind_network} -f "{{range .Containers}}{{.Name}} {{end}}")
needs_connect="true"
for c in $containers; do
if [ "$c" = "${reg_name}" ]; then
needs_connect="false"
fi
done
if [ "${needs_connect}" = "true" ]; then
$OCI_BIN network connect "${kind_network}" "${reg_name}" || true
fi
# load multus image from container host to kind node
kind load docker-image localhost:5000/multus:e2e

worker1_pid=$($OCI_BIN inspect --format "{{ .State.Pid }}" kind-worker)
worker2_pid=$($OCI_BIN inspect --format "{{ .State.Pid }}" kind-worker2)
Expand Down
3 changes: 0 additions & 3 deletions e2e/teardown.sh
@@ -1,10 +1,7 @@
#!/bin/sh
#set -o errexit

reg_name='kind-registry'
export PATH=${PATH}:./bin

# delete cluster kind
kind delete cluster
docker kill ${reg_name}
docker rm ${reg_name}
1 change: 0 additions & 1 deletion e2e/templates/multus-daemonset-thick.yml.j2
Expand Up @@ -133,7 +133,6 @@ spec:
containers:
- name: kube-multus
image: localhost:5000/multus:e2e
imagePullPolicy: Always
command: [ "/usr/src/multus-cni/bin/multus-daemon" ]
resources:
requests:
Expand Down

0 comments on commit ca5a4c9

Please sign in to comment.