diff --git a/build-scripts/components/metallb/repository b/build-scripts/components/metallb/repository new file mode 100644 index 0000000000..90737d74b7 --- /dev/null +++ b/build-scripts/components/metallb/repository @@ -0,0 +1 @@ +https://metallb.github.io/metallb diff --git a/build-scripts/components/metrics-server/repository b/build-scripts/components/metrics-server/repository new file mode 100644 index 0000000000..280b7a1b98 --- /dev/null +++ b/build-scripts/components/metrics-server/repository @@ -0,0 +1 @@ +https://kubernetes-sigs.github.io/metrics-server diff --git a/build-scripts/hack/update-component-versions.py b/build-scripts/hack/update-component-versions.py index 75b7a5086d..25edf2ba04 100755 --- a/build-scripts/hack/update-component-versions.py +++ b/build-scripts/hack/update-component-versions.py @@ -23,6 +23,7 @@ DIR = Path(__file__).absolute().parent COMPONENTS = DIR.parent / "components" +MANIFESTS = DIR.parent.parent / "k8s" / "manifests" / "charts" # Version marker for latest Kubernetes version. Expected to be one of: # @@ -36,6 +37,14 @@ # Helm release branch to track. The most recent tag in the branch will be used. HELM_RELEASE_BRANCH = "release-3.14" +# MetalLB Helm repository and chart version +METALLB_HELM_REPO = "https://metallb.github.io/metallb" +METALLB_CHART_VERSION = "0.14.5" + +# Metrics Server Helm repository +METRICS_SERVER_REPO = "https://kubernetes-sigs.github.io/metrics-server" +METRICS_SERVER_CHART_VERSION = "3.12.1" + def get_kubernetes_version() -> str: """Update Kubernetes version based on the specified marker file""" @@ -64,7 +73,9 @@ def get_containerd_version() -> str: """Update containerd version using latest tag of specified branch""" containerd_repo = util.read_file(COMPONENTS / "containerd/repository") - with util.git_repo(containerd_repo, CONTAINERD_RELEASE_BRANCH, shallow=False) as dir: + with util.git_repo( + containerd_repo, CONTAINERD_RELEASE_BRANCH, shallow=False + ) as dir: # Get the latest tagged release from the current branch return util.parse_output(["git", "describe", "--tags", "--abbrev=0"], cwd=dir) @@ -86,6 +97,20 @@ def get_helm_version() -> str: return util.parse_output(["git", "describe", "--tags", "--abbrev=0"], cwd=dir) +def pull_metallb_chart() -> None: + LOG.info("Pulling MetalLB chart @ %s", METALLB_CHART_VERSION) + metallb_chart_repo = util.read_file(COMPONENTS / "metallb/repository") + util.helm_pull("metallb", metallb_chart_repo, METALLB_CHART_VERSION, MANIFESTS) + + +def pull_metrics_server_chart() -> None: + LOG.info("Pulling Metrics Server chart @ %s", METRICS_SERVER_CHART_VERSION) + metallb_chart_repo = util.read_file(COMPONENTS / "metrics-server/repository") + util.helm_pull( + "metrics-server", metallb_chart_repo, METRICS_SERVER_CHART_VERSION, MANIFESTS + ) + + def update_component_versions(dry_run: bool): for component, get_version in [ ("kubernetes", get_kubernetes_version), @@ -101,6 +126,14 @@ def update_component_versions(dry_run: bool): if not dry_run: Path(path).write_text(version.strip() + "\n") + for component, pull_helm_chart in [ + ("metallb", pull_metallb_chart), + ("metrics-server", pull_metrics_server_chart), + ]: + LOG.info("Updating chart for %s", component) + if not dry_run: + pull_helm_chart() + def main(): parser = argparse.ArgumentParser( diff --git a/build-scripts/hack/update-metrics-server-chart.sh b/build-scripts/hack/update-metrics-server-chart.sh deleted file mode 100755 index 7d8dc352bd..0000000000 --- a/build-scripts/hack/update-metrics-server-chart.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -VERSION="3.12.0" -DIR=`realpath $(dirname "${0}")` - -CHARTS_PATH="$DIR/../../k8s/components/charts" - -cd "$CHARTS_PATH" - -helm pull --repo https://kubernetes-sigs.github.io/metrics-server/ metrics-server --version $VERSION diff --git a/build-scripts/hack/util.py b/build-scripts/hack/util.py index 871d5b47c1..84acc8eb8b 100644 --- a/build-scripts/hack/util.py +++ b/build-scripts/hack/util.py @@ -3,6 +3,7 @@ import tempfile import subprocess import logging +import yaml from urllib.request import urlopen from pathlib import Path @@ -48,3 +49,9 @@ def read_file(path: Path) -> str: def read_url(url: str) -> str: return urlopen(url).read().decode().strip() + +def helm_pull(chart_name: str, repo_url: str, version: str, destination: Path) -> None: + parse_output(["helm", "repo", "add", chart_name, repo_url]) + parse_output(["helm", "pull", f"{chart_name}/{chart_name}", "--version", version, "--destination", destination]) + + LOG.info("Pulled helm repository %s @ %s as %s to %s", repo_url, version, chart_name, destination)