Compare commits
3 Commits
master
...
test-scrip
Author | SHA1 | Date | |
---|---|---|---|
e659731d7b | |||
8c81cfecf0 | |||
bf4dedb221 |
12
build.py
12
build.py
@ -432,12 +432,22 @@ class DockerBuilder:
|
|||||||
else:
|
else:
|
||||||
registry = ""
|
registry = ""
|
||||||
alt_image = "alt"
|
alt_image = "alt"
|
||||||
|
|
||||||
|
if self.branch == "c10f2":
|
||||||
|
base_image_prefix = "c10f"
|
||||||
|
label_vendor = "BaseALT LLC"
|
||||||
|
else:
|
||||||
|
base_image_prefix = self.branch
|
||||||
|
label_vendor = "ALT Linux Team"
|
||||||
|
|
||||||
rendered = JINJA_ENV.from_string(template).render(
|
rendered = JINJA_ENV.from_string(template).render(
|
||||||
alt_image=alt_image,
|
alt_image=alt_image,
|
||||||
branch=self.branch,
|
branch=self.branch,
|
||||||
|
base_image_prefix=base_image_prefix,
|
||||||
install_packages=install_packages,
|
install_packages=install_packages,
|
||||||
organization=organization,
|
organization=organization,
|
||||||
registry=registry,
|
registry=registry,
|
||||||
|
label_vendor=label_vendor,
|
||||||
pkg_versions=PKG_VERSIONS,
|
pkg_versions=PKG_VERSIONS,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
@ -785,7 +795,7 @@ class DockerBuilder:
|
|||||||
".",
|
".",
|
||||||
]
|
]
|
||||||
|
|
||||||
if image.annotations is not None:
|
if image.annotations is not None and self.branch != "c10f2":
|
||||||
build_cmd = [
|
build_cmd = [
|
||||||
"podman",
|
"podman",
|
||||||
"build",
|
"build",
|
||||||
|
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="cert-manager-acmesolver"
|
|||||||
LABEL org.opencontainers.image.description="HTTP server used to solve ACME challenges."
|
LABEL org.opencontainers.image.description="HTTP server used to solve ACME challenges."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="cert-manager-cainjector"
|
|||||||
LABEL org.opencontainers.image.description="cert-manager CA injector is a Kubernetes addon to automate the injection of CA data into webhooks and APIServices from cert-manager certificates."
|
LABEL org.opencontainers.image.description="cert-manager CA injector is a Kubernetes addon to automate the injection of CA data into webhooks and APIServices from cert-manager certificates."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="cert-manager-controller"
|
|||||||
LABEL org.opencontainers.image.description="Automatically provision and manage TLS certificates in Kubernetes."
|
LABEL org.opencontainers.image.description="Automatically provision and manage TLS certificates in Kubernetes."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="cert-manager-startupapicheck"
|
|||||||
LABEL org.opencontainers.image.description="Check that cert-manager started successfully."
|
LABEL org.opencontainers.image.description="Check that cert-manager started successfully."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="cert-manager-webhook"
|
|||||||
LABEL org.opencontainers.image.description="The webhook component provides API validation, mutation and conversion functionality for cert-manager."
|
LABEL org.opencontainers.image.description="The webhook component provides API validation, mutation and conversion functionality for cert-manager."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
LABEL org.opencontainers.image.source="https://github.com/cert-manager/cert-manager"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ LABEL org.opencontainers.image.title="coredns"
|
|||||||
LABEL org.opencontainers.image.description="CoreDNS is a DNS server that chains plugins"
|
LABEL org.opencontainers.image.description="CoreDNS is a DNS server that chains plugins"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/coredns/coredns"
|
LABEL org.opencontainers.image.source="https://github.com/coredns/coredns"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
{% if pkg_versions and "k8s/coredns" in pkg_versions %}
|
{% if pkg_versions and "k8s/coredns" in pkg_versions %}
|
||||||
{% set num_version_parts = (pkg_versions["k8s/coredns"].split('.') | length) %}
|
{% set num_version_parts = (pkg_versions["k8s/coredns"].split('.') | length) %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ LABEL org.opencontainers.image.title="etcd"
|
|||||||
LABEL org.opencontainers.image.description="Distributed reliable key-value store for the most critical data of a distributed system"
|
LABEL org.opencontainers.image.description="Distributed reliable key-value store for the most critical data of a distributed system"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/etcd-io/etcd"
|
LABEL org.opencontainers.image.source="https://github.com/etcd-io/etcd"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
ARG PKG_VERSION
|
ARG PKG_VERSION
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ LABEL org.opencontainers.image.title="flannel-cni-plugin" \
|
|||||||
org.opencontainers.image.description="CNI network plugin that is powered by flannel" \
|
org.opencontainers.image.description="CNI network plugin that is powered by flannel" \
|
||||||
org.opencontainers.image.source="https://github.com/flannel-io/cni-plugin" \
|
org.opencontainers.image.source="https://github.com/flannel-io/cni-plugin" \
|
||||||
org.opencontainers.image.licenses="Apache-2.0" \
|
org.opencontainers.image.licenses="Apache-2.0" \
|
||||||
org.opencontainers.image.vendor="ALT Linux Team"
|
org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
{{ install_packages("cni-plugin-flannel") }}
|
{{ install_packages("cni-plugin-flannel") }}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ LABEL org.opencontainers.image.title="flannel"
|
|||||||
LABEL org.opencontainers.image.description="Network fabric for containers"
|
LABEL org.opencontainers.image.description="Network fabric for containers"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/flannel-io/flannel"
|
LABEL org.opencontainers.image.source="https://github.com/flannel-io/flannel"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
{{ install_packages(
|
{{ install_packages(
|
||||||
"iproute2",
|
"iproute2",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="kube-apiserver"
|
|||||||
LABEL org.opencontainers.image.description="The Kubernetes API server validates and configures data for the api objects which include pods, services, replicationcontrollers, and others."
|
LABEL org.opencontainers.image.description="The Kubernetes API server validates and configures data for the api objects which include pods, services, replicationcontrollers, and others."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="kube-controller-manager"
|
|||||||
LABEL org.opencontainers.image.description="The Kubernetes controller manager is a daemon that embeds the core control loops shipped with Kubernetes."
|
LABEL org.opencontainers.image.description="The Kubernetes controller manager is a daemon that embeds the core control loops shipped with Kubernetes."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="kube-proxy"
|
|||||||
LABEL org.opencontainers.image.description="The Kubernetes network proxy runs on each node."
|
LABEL org.opencontainers.image.description="The Kubernetes network proxy runs on each node."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="kube-scheduler"
|
|||||||
LABEL org.opencontainers.image.description="The Kubernetes scheduler is a control plane process which assigns Pods to Nodes."
|
LABEL org.opencontainers.image.description="The Kubernetes scheduler is a control plane process which assigns Pods to Nodes."
|
||||||
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
LABEL org.opencontainers.image.source="https://github.com/kubernetes/kubernetes"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
|
FROM {{ registry }}{{ base_image_prefix }}/{{ alt_image }}:latest
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ LABEL org.opencontainers.image.title="kubelet" \
|
|||||||
org.opencontainers.image.description="An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod." \
|
org.opencontainers.image.description="An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod." \
|
||||||
org.opencontainers.image.source="https://github.com/kubernetes/kubernetes" \
|
org.opencontainers.image.source="https://github.com/kubernetes/kubernetes" \
|
||||||
org.opencontainers.image.licenses="Apache-2.0" \
|
org.opencontainers.image.licenses="Apache-2.0" \
|
||||||
org.opencontainers.image.vendor="ALT Linux Team" \
|
org.opencontainers.image.vendor="{{ label_vendor }}" \
|
||||||
|
@ -5,7 +5,7 @@ MAINTAINER alt-cloud
|
|||||||
LABEL org.opencontainers.image.title="pause" \
|
LABEL org.opencontainers.image.title="pause" \
|
||||||
org.opencontainers.image.description="Simple pause image" \
|
org.opencontainers.image.description="Simple pause image" \
|
||||||
org.opencontainers.image.licenses="GPLv2" \
|
org.opencontainers.image.licenses="GPLv2" \
|
||||||
org.opencontainers.image.vendor="ALT Linux Team"
|
org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
{{ install_packages("kubernetes-pause") }}
|
{{ install_packages("kubernetes-pause") }}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ LABEL org.opencontainers.image.title="trivy-node-collector"
|
|||||||
LABEL org.opencontainers.image.description="Open source collector who collect Node information (fs and process data) and output in a table/json format"
|
LABEL org.opencontainers.image.description="Open source collector who collect Node information (fs and process data) and output in a table/json format"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/aquasecurity/k8s-node-collector"
|
LABEL org.opencontainers.image.source="https://github.com/aquasecurity/k8s-node-collector"
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
||||||
LABEL org.opencontainers.image.vendor="ALT Linux Team"
|
LABEL org.opencontainers.image.vendor="{{ label_vendor }}"
|
||||||
|
|
||||||
{{ install_packages(
|
{{ install_packages(
|
||||||
"k8s-trivy-node-collector",
|
"k8s-trivy-node-collector",
|
||||||
|
192
test.py
Executable file
192
test.py
Executable file
@ -0,0 +1,192 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import yaml
|
||||||
|
from jinja2 import Template
|
||||||
|
|
||||||
|
from build import AltAPIError
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def api_get_package_versions_from_task(task_id: str) -> dict[str, str]:
|
||||||
|
api_url = f"https://rdb.altlinux.org/api/task/packages/{task_id}"
|
||||||
|
response = requests.get(api_url)
|
||||||
|
if response.status_code != 200:
|
||||||
|
raise AltAPIError(
|
||||||
|
f"failed to retrieve kubernetes versions from task: task_id {task_id}"
|
||||||
|
)
|
||||||
|
|
||||||
|
result = response.json()
|
||||||
|
|
||||||
|
packages = {}
|
||||||
|
for subtask in result["subtasks"]:
|
||||||
|
packages[subtask["source"]["name"]] = subtask["source"]["version"]
|
||||||
|
|
||||||
|
return packages
|
||||||
|
|
||||||
|
def api_get_latest_flannel_tag(branch: str):
|
||||||
|
api_url = f"https://registry.altlinux.org/v2/{branch}/flannel/tags/list"
|
||||||
|
response = requests.get(api_url)
|
||||||
|
if response.status_code != 200:
|
||||||
|
raise AltAPIError(
|
||||||
|
f"failed to get latest flannel version for branch {branch}"
|
||||||
|
)
|
||||||
|
|
||||||
|
result = response.json()
|
||||||
|
|
||||||
|
return result["tags"][-1]
|
||||||
|
|
||||||
|
def run(cmd: list[str]):
|
||||||
|
global DRY_RUN
|
||||||
|
|
||||||
|
logger.debug("%s", cmd)
|
||||||
|
if not DRY_RUN:
|
||||||
|
subprocess.run(cmd, check=True)
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
log_levels = ["debug", "info", "warning", "error", "critical"]
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"--log-level",
|
||||||
|
default="debug",
|
||||||
|
choices=log_levels,
|
||||||
|
help="log messages above specified level",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--dry-run",
|
||||||
|
action="store_true",
|
||||||
|
help="don't run commands",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--skip-packages",
|
||||||
|
nargs="+",
|
||||||
|
help="log messages above specified level",
|
||||||
|
)
|
||||||
|
parser.add_argument("branch")
|
||||||
|
parser.add_argument("task_id")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global DRY_RUN
|
||||||
|
|
||||||
|
args = parse_args()
|
||||||
|
DRY_RUN = args.dry_run
|
||||||
|
|
||||||
|
numeric_level = getattr(logging, args.log_level.upper(), logging.DEBUG)
|
||||||
|
logging.basicConfig(
|
||||||
|
level=numeric_level, format="%(asctime)s - %(levelname)s\t- %(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
package_versions = api_get_package_versions_from_task(args.task_id)
|
||||||
|
test_registry = "10.4.5.110:5000"
|
||||||
|
image_forge_dir = Path(".").resolve()
|
||||||
|
tests_dir = Path("../kubernetes-tests").resolve()
|
||||||
|
|
||||||
|
registry_prefix = args.branch
|
||||||
|
if args.branch == "c10f2":
|
||||||
|
registry_prefix = "c10f"
|
||||||
|
|
||||||
|
srpm_to_images = yaml.safe_load(Path("srpm_to_images.yaml").read_text())
|
||||||
|
|
||||||
|
temp_tasks_config = tempfile.NamedTemporaryFile(mode="w+", delete=False, delete_on_close=False)
|
||||||
|
temp_tasks_config.write(f"""\
|
||||||
|
[{args.branch}]
|
||||||
|
{args.task_id} = [{",".join([f'"{image}"' for pkg_name in package_versions if pkg_name in srpm_to_images for image in srpm_to_images[pkg_name]])}]
|
||||||
|
""")
|
||||||
|
temp_tasks_config.close()
|
||||||
|
|
||||||
|
k8s_dir = image_forge_dir / "org" / "k8s"
|
||||||
|
image_to_version_template: dict[str, str | list[str]] = {}
|
||||||
|
for image_dir in k8s_dir.iterdir():
|
||||||
|
info_file = image_dir / "info.yaml"
|
||||||
|
info = yaml.safe_load(info_file.read_text())
|
||||||
|
image_to_version_template[f"{image_dir.parent.name}/{image_dir.name}"] = info.get("version_template", None)
|
||||||
|
|
||||||
|
run([
|
||||||
|
"podman",
|
||||||
|
"login",
|
||||||
|
test_registry,
|
||||||
|
"--username", "admin",
|
||||||
|
"--password", "123"
|
||||||
|
])
|
||||||
|
|
||||||
|
flannel_tag = api_get_latest_flannel_tag(registry_prefix)
|
||||||
|
run(["skopeo", "copy", "-a", f"docker://registry.altlinux.org/{registry_prefix}/flannel:{flannel_tag}", f"docker://{test_registry}/{registry_prefix}/flannel:{flannel_tag}"])
|
||||||
|
|
||||||
|
if args.skip_packages is not None:
|
||||||
|
package_versions = {name: version for name, version in package_versions.items() if name not in args.skip_packages}
|
||||||
|
|
||||||
|
for pkg_name, pkg_version in package_versions.items():
|
||||||
|
os.chdir(image_forge_dir)
|
||||||
|
|
||||||
|
if pkg_name not in srpm_to_images:
|
||||||
|
continue
|
||||||
|
|
||||||
|
cmd = [
|
||||||
|
"./build.py",
|
||||||
|
"--branch", args.branch,
|
||||||
|
"--registry", "registry.altlinux.org",
|
||||||
|
"--overwrite-organization", registry_prefix,
|
||||||
|
"--skip-arches", "riscv64", "loong64",
|
||||||
|
"--skip-stage", "push",
|
||||||
|
"--log-level", "debug",
|
||||||
|
"--tasks", temp_tasks_config.name,
|
||||||
|
"-i",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cmd += srpm_to_images[pkg_name]
|
||||||
|
|
||||||
|
version_for_template = pkg_version[:4]
|
||||||
|
if pkg_name.startswith("coredns-for-kubernetes") or pkg_name.startswith("etcd-for-kubernetes"):
|
||||||
|
version_for_template = pkg_name[-4:]
|
||||||
|
|
||||||
|
versions_arg = {image: version_for_template for image in srpm_to_images[pkg_name]}
|
||||||
|
|
||||||
|
cmd += [
|
||||||
|
"--package-versions",
|
||||||
|
json.dumps(versions_arg),
|
||||||
|
]
|
||||||
|
|
||||||
|
run(cmd)
|
||||||
|
|
||||||
|
for image in srpm_to_images[pkg_name]:
|
||||||
|
version_template = image_to_version_template[image]
|
||||||
|
|
||||||
|
tags = []
|
||||||
|
if version_template is not None:
|
||||||
|
if isinstance(version_template, str):
|
||||||
|
tags.append(Template(version_template).render(version=pkg_version).strip())
|
||||||
|
elif isinstance(version_template, list):
|
||||||
|
for template in version_template:
|
||||||
|
tags.append(Template(template).render(version=pkg_version).strip())
|
||||||
|
else:
|
||||||
|
tags = [pkg_version]
|
||||||
|
|
||||||
|
image_name = image[4:]
|
||||||
|
for tag in tags:
|
||||||
|
run([
|
||||||
|
"podman",
|
||||||
|
"manifest",
|
||||||
|
"push",
|
||||||
|
f"registry.altlinux.org/{registry_prefix}/{image_name}:{tag}",
|
||||||
|
f"docker://{test_registry}/{registry_prefix}/{image_name}:{tag}"
|
||||||
|
])
|
||||||
|
|
||||||
|
os.chdir(tests_dir)
|
||||||
|
for pkg_name, pkg_version in package_versions.items():
|
||||||
|
if pkg_name.startswith("kubernetes"):
|
||||||
|
run(["./run.sh", args.branch, pkg_version, flannel_tag, test_registry, args.task_id, "iptables"])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
122
test.sh
Executable file
122
test.sh
Executable file
@ -0,0 +1,122 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -efu
|
||||||
|
|
||||||
|
dry_run=0
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run)
|
||||||
|
dry_run=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
r()
|
||||||
|
{
|
||||||
|
if [[ $dry_run == 1 ]]; then
|
||||||
|
echo "$@"
|
||||||
|
else
|
||||||
|
"$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
branch=$1
|
||||||
|
task_id=$2
|
||||||
|
|
||||||
|
# kubernetes_package_versions=()
|
||||||
|
declare -A kubernetes_package_versions
|
||||||
|
api_url="https://rdb.altlinux.org/api/task/packages/$task_id"
|
||||||
|
test_registry=10.4.5.110:5000
|
||||||
|
image_forge_dir=$PWD
|
||||||
|
tests_dir=$(realpath ../kubernetes-tests)
|
||||||
|
kubernetes_images=(k8s/kube-apiserver k8s/kube-controller-manager k8s/kube-scheduler k8s/kube-proxy k8s/kubelet)
|
||||||
|
temp_tasks_config=$(mktemp)
|
||||||
|
|
||||||
|
registry_prefix=$branch
|
||||||
|
if [[ $branch == c10f2 ]]; then
|
||||||
|
registry_prefix=c10f
|
||||||
|
fi
|
||||||
|
|
||||||
|
api_response=$(curl -s "$api_url")
|
||||||
|
|
||||||
|
while read -r subtask; do
|
||||||
|
package_name=$(jq -r '.source.name' <<< "$subtask")
|
||||||
|
package_version=$(jq -r '.source.version' <<< "$subtask")
|
||||||
|
if [[ $package_name =~ ^kubernetes1\.[0-9]{2}$ ]]; then
|
||||||
|
kubernetes_package_versions[$package_name]=$package_version
|
||||||
|
elif [[ $package_name =~ ^etcd-for-kubernetes ]]; then
|
||||||
|
kubernetes_package_versions[$package_name]=$package_version
|
||||||
|
fi
|
||||||
|
done < <(jq -c '.subtasks[]' <<< "$api_response")
|
||||||
|
|
||||||
|
printf -v kubernetes_images_joined '"%s", ' "${kubernetes_images[@]}"
|
||||||
|
cat <<EOF > "$temp_tasks_config"
|
||||||
|
[$branch]
|
||||||
|
$task_id = [${kubernetes_images_joined%, }]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
r podman login "$test_registry" --username admin --password 123
|
||||||
|
|
||||||
|
flannel_tag=$(curl -s "https://registry.altlinux.org/v2/$registry_prefix/flannel/tags/list" | jq -r '.tags[-1]')
|
||||||
|
r skopeo copy -a "docker://registry.altlinux.org/$registry_prefix/flannel:$flannel_tag" "docker://$test_registry/$registry_prefix/flannel:$flannel_tag"
|
||||||
|
|
||||||
|
if [[ ${!kubernetes_package_versions[*]} =~ cni-plugin-flannel ]]; then
|
||||||
|
r ./build.py \
|
||||||
|
--branch "$branch" \
|
||||||
|
--registry registry.altlinux.org \
|
||||||
|
--overwrite-organization "$registry_prefix" \
|
||||||
|
--skip-arches riscv64 loong64 \
|
||||||
|
--skip-stage push \
|
||||||
|
--log-level debug \
|
||||||
|
--tasks "$temp_tasks_config" \
|
||||||
|
-i k8s/flannel-cni-plugin
|
||||||
|
|
||||||
|
r podman manifest push "registry.altlinux.org/$registry_prefix/flannel-cni-plugin:v$version" "docker://$test_registry/$registry_prefix/$image_name:v$version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for name in "${!kubernetes_package_versions[@]}"; do
|
||||||
|
version=${kubernetes_package_versions[$name]}
|
||||||
|
images=()
|
||||||
|
versions='{'
|
||||||
|
if [[ $name =~ ^kubernetes1\.[0-9]{2}$ ]]; then
|
||||||
|
images+=("${kubernetes_images[@]}")
|
||||||
|
for image in "${kubernetes_images[@]}"; do
|
||||||
|
versions+="\"$image\":\"${version::4}\","
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [[ $name =~ ^etcd-for-kubernetes(1\.[0-9]{2})$ ]]; then
|
||||||
|
images+=("k8s/etcd")
|
||||||
|
versions+="\"k8s/etcd\":\"${BASH_REMATCH[1]::4}\","
|
||||||
|
fi
|
||||||
|
versions="${versions%,}}"
|
||||||
|
|
||||||
|
cd "$image_forge_dir"
|
||||||
|
r ./build.py \
|
||||||
|
--branch "$branch" \
|
||||||
|
--registry registry.altlinux.org \
|
||||||
|
--overwrite-organization "$registry_prefix" \
|
||||||
|
--skip-arches riscv64 loong64 \
|
||||||
|
--skip-stage push \
|
||||||
|
--log-level debug \
|
||||||
|
--tasks "$temp_tasks_config" \
|
||||||
|
-i "${images[@]}" \
|
||||||
|
--package-versions "$versions"
|
||||||
|
|
||||||
|
for image in "${images[@]}"; do
|
||||||
|
image_name=${image:4}
|
||||||
|
r podman manifest push "registry.altlinux.org/$registry_prefix/$image_name:v$version" "docker://$test_registry/$registry_prefix/$image_name:v$version"
|
||||||
|
if [[ $image_name == etcd ]]; then
|
||||||
|
r podman manifest push "registry.altlinux.org/$registry_prefix/$image_name:v$version" "docker://$test_registry/$registry_prefix/$image_name:$version-0"
|
||||||
|
r podman manifest push "registry.altlinux.org/$registry_prefix/$image_name:v$version" "docker://$test_registry/$registry_prefix/$image_name:$version"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ =~ ^kubernetes1\.[0-9]{2}$ ]]; then
|
||||||
|
cd "$tests_dir"
|
||||||
|
r ./run.sh "$branch" "$version" "$flannel_tag" "$test_registry" "$task_id" iptables
|
||||||
|
fi
|
Reference in New Issue
Block a user