Skip to content

Commit

Permalink
Adds other versions of Whereabouts
Browse files Browse the repository at this point in the history
Added support for versions 0.5.4 and 0.6.1. Added rockcraft.yaml
files based on their Dockerfiles.

Adds /host folder in the rocks. The /install-cni.sh script requires
this folder. It does mkdir it, but the bitnami helm chart creates
the daemonsets with read-only filesystem, making it impossible to
create the folder.
  • Loading branch information
claudiubelu committed Jul 18, 2024
1 parent 78a0ba7 commit 965f8d3
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 5 deletions.
50 changes: 50 additions & 0 deletions 0.5.4/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dockerfile: https://github.com/k8snetworkplumbingwg/whereabouts/blob/v0.5.4/Dockerfile
name: whereabouts
summary: Whereabouts rock
description: |
A rock containing Whereabouts, an IP Address Management (IPAM) CNI plugin
that assigns IP addresses cluster-wide.
license: Apache-2.0
version: 0.5.4

base: [email protected]
build-base: [email protected]

platforms:
amd64:
arm64:

environment:
APP_VERSION: 0.5.4

# Services to be loaded by the Pebble entrypoint
services:
install-cni:
override: replace
startup: enabled
command: bash /install-cni.sh
on-success: shutdown
on-failure: shutdown

parts:
build-binary:
plugin: nil
source: https://github.com/k8snetworkplumbingwg/whereabouts.git
source-type: git
source-tag: v${CRAFT_PROJECT_VERSION}
source-depth: 1
build-snaps:
- go/1.16/stable
build-environment:
- GOARCH: $CRAFT_ARCH_BUILD_FOR
override-build: |
bash -x "hack/build-go.sh"
cp bin/* "${CRAFT_PART_INSTALL}/"
cp script/install-cni.sh "${CRAFT_PART_INSTALL}/"
bitnami-compatibility:
plugin: nil
override-build: |
# install-cni.sh requires this folder to exist.
mkdir -p "${CRAFT_PART_INSTALL}/bitnami/whereabouts/host"
ln -sf /bitnami/whereabouts/host "${CRAFT_PART_INSTALL}/host"
50 changes: 50 additions & 0 deletions 0.6.1/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dockerfile: https://github.com/k8snetworkplumbingwg/whereabouts/blob/v0.6.1Dockerfile
name: whereabouts
summary: Whereabouts rock
description: |
A rock containing Whereabouts, an IP Address Management (IPAM) CNI plugin
that assigns IP addresses cluster-wide.
license: Apache-2.0
version: 0.6.1

base: [email protected]
build-base: [email protected]

platforms:
amd64:
arm64:

environment:
APP_VERSION: 0.6.1

# Services to be loaded by the Pebble entrypoint
services:
install-cni:
override: replace
startup: enabled
command: bash /install-cni.sh
on-success: shutdown
on-failure: shutdown

parts:
build-binary:
plugin: nil
source: https://github.com/k8snetworkplumbingwg/whereabouts.git
source-type: git
source-tag: v${CRAFT_PROJECT_VERSION}
source-depth: 1
build-snaps:
- go/1.19/stable
build-environment:
- GOARCH: $CRAFT_ARCH_BUILD_FOR
override-build: |
bash -x "hack/build-go.sh"
cp bin/* "${CRAFT_PART_INSTALL}/"
cp script/install-cni.sh "${CRAFT_PART_INSTALL}/"
bitnami-compatibility:
plugin: nil
override-build: |
# install-cni.sh requires this folder to exist.
mkdir -p "${CRAFT_PART_INSTALL}/bitnami/whereabouts/host"
ln -sf /bitnami/whereabouts/host "${CRAFT_PART_INSTALL}/host"
File renamed without changes.
28 changes: 23 additions & 5 deletions tests/sanity/test_whereabouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
]


@pytest.mark.abort_on_fail
def test_whereabouts_rock():
def _test_whereabouts_rock(image_variable, expected_files):
"""Test Whereabouts rock."""
image_variable = "ROCK_WHEREABOUTS"
image = os.getenv(image_variable)
assert image is not None, f"${image_variable} is not set"

# check rock filesystem
docker_util.ensure_image_contains_paths(image, ROCK_EXPECTED_FILES)
docker_util.ensure_image_contains_paths(image, expected_files)

# check binary name and version.
version = docker_util.get_image_version(image)
process = docker_util.run_in_docker(image, True, "/whereabouts", "version")
output = process.stderr
assert "whereabouts" in output and "0.6.3" in output
assert "whereabouts" in output and version in output

# check other binary. It expects KUBERNETES_SERVICE_HOST to be defined.
process = docker_util.run_in_docker(image, False, "/ip-control-loop")
Expand All @@ -35,3 +35,21 @@ def test_whereabouts_rock():
# check script. It expects serviceaccount token to exist.
process = docker_util.run_in_docker(image, False, "/install-cni.sh")
"cat: /var/run/secrets/kubernetes.io/serviceaccount/token: No such file or directory" in process.stderr

# whereabouts:0.5.4 also has a /ip-reconciler
if version == "0.5.4":
process = docker_util.run_in_docker(image, False, "/ip-reconciler")
expected_message = "failed to instantiate the Kubernetes client"
assert expected_message in process.stderr


def test_whereabouts_rock_0_6_3():
_test_whereabouts_rock("ROCK_WHEREABOUTS_0_6_3", ROCK_EXPECTED_FILES)


def test_whereabouts_rock_0_6_1():
_test_whereabouts_rock("ROCK_WHEREABOUTS_0_6_1", ROCK_EXPECTED_FILES)


def test_whereabouts_rock_0_5_4():
_test_whereabouts_rock("ROCK_WHEREABOUTS_0_5_4", ROCK_EXPECTED_FILES + ["/ip-reconciler"])

0 comments on commit 965f8d3

Please sign in to comment.