Compare commits

13 Commits

10 changed files with 291 additions and 21 deletions

View File

@ -0,0 +1,74 @@
#!/usr/bin/env python3
import argparse
import json
import subprocess
vers_path = ".gitea/workflows/k8s_vers.json"
def run(args):
result = subprocess.run(
args,
capture_output = True,
text = True
)
if result.stderr is not None:
print(result.stderr)
return False
print(result.stdout)
return True
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--branch",
help="used to pick the appropriate VM template to clone",
choices=["sisyphus", "c10f2", "p10", "p11"],
)
parser.add_argument(
"--other-build-args",
help="other build arg as a string",
)
parser.add_argument(
"--workspace",
help="workspace, path to builing script",
)
return parser.parse_args()
def main() -> None:
args = parse_args()
if args.branch is None or args.branch == "":
raise RuntimeError("Empty branch setting. Check your choise --branch.")
data = {}
with open(f"{args.workspace}/{vers_path}", "r") as f:
data = json.load(f)
i = 0
for br in data.get("branches"):
if br.get("name") == args.branch:
break
i += 1
vers_branch = data.get("branches")[i].get("versions")
if vers_branch == None :
raise RuntimeError(f"Unknown branch: {args.branch!r}. In {vers_path} no k8s-versions list.")
images_to_rebuild="k8s/kube-apiserver k8s/kube-scheduler k8s/kube-controller-manager k8s/kube-proxy k8s/kubelet k8s/coredns k8s/etcd"
for ver in vers_branch:
kube_ver = ver.get("kube-version")
dns_ver = ver.get("coredns")
if kube_ver != None and dns_ver != None:
packs_string=f"-b {args.branch} " + "--package-versions '{\"k8s/kube-apiserver\":" + f"\"{kube_ver}\",\"k8s/kube-scheduler\":\"{kube_ver}\",\"k8s/kube-controller-manager\":\"{kube_ver}\",\"k8s/kube-proxy\":\"{kube_ver}\",\"k8s/kubelet\":\"{kube_ver}\",\"k8s/coredns\":\"{dns_ver}\",\"k8s/etcd\":\"{kube_ver}\"" + "}'"
if ver.get("latest") != None and ver.get("latest"):
packs_string=f"-o k8s --latest {args.branch} "+packs_string
else:
packs_string=f"-i {images_to_rebuild} "+packs_string
subprocess.run(f"{args.workspace}/build.py {args.other_build_args} {packs_string}", shell=True)
subprocess.run("podman rmi -f --all", shell=True)
if __name__ == "__main__":
main()

View File

@ -0,0 +1,72 @@
{
"branches": [
{
"name": "p10",
"versions": [
{
"kube-version": "1.27",
"coredns": "1.10.1"
},
{
"kube-version": "1.28",
"coredns": "1.10.1",
"latest": true
}
]
},
{
"name": "p11",
"versions": [
{
"kube-version": "1.31",
"coredns": "1.11.3"
},
{
"kube-version": "1.32",
"coredns": "1.11.3"
},
{
"kube-version": "1.33",
"coredns": "1.33",
"latest": true
}
]
},
{
"name": "c10f2",
"versions": [
{
"kube-version": "1.31",
"coredns": "1.11.3"
},
{
"kube-version": "1.32",
"coredns": "1.11.3"
},
{
"kube-version": "1.33",
"coredns": "1.33",
"latest": true
}
]
},
{
"name": "sisyphus",
"versions": [
{
"kube-version": "1.31",
"coredns": "1.11.3"
},
{
"kube-version": "1.32",
"coredns": "1.11.3"
},
{
"kube-version": "1.33",
"coredns": "1.33",
"latest": true
}
]
}
]
}

View File

@ -32,20 +32,20 @@ do
if [ -n "$test" ]; then
command="podman run --rm --entrypoint=\"$entrypoint\" $url/$imgpath -c \"$test\""
else
if [[ "$IM" == distroless-toybox ]]; then
command="podman run --rm $url/$imgpath toysh -c true"
if [ "$IM" = distroless-toybox ]; then
command="podman run -q --rm $url/$imgpath toysh -c true"
fi
if [ "$IM" = distroless-true ]; then
command="podman run --rm $url/$imgpath \"true\""
command="podman run -q --rm $url/$imgpath \"true\""
fi
if [ "$IM" = distroless-gotop ]; then
command="podman run --rm $url/$imgpath \"--version\""
command="podman run -q --rm $url/$imgpath \"--version\""
fi
if [ "$IM" = flannel-cni-plugin ]; then
command="podman run --rm $url/$imgpath \"/flannel\""
command="podman run -q --rm $url/$imgpath \"/flannel\""
fi
if [ "$IM" == pause ]; then
command="podman run --rm $url/$imgpath \"/pause\" \"-v\""
command="podman run -q --rm $url/$imgpath \"/pause\" \"-v\""
fi
fi
echo $command
@ -58,7 +58,7 @@ do
then
if [[ -n $(cat $IM.log) ]]
then errors="TEST ERROR OF IMAGE $IM: $(cat $IM.log); $errors"
else errors="TEST ERROR OF IMAGE $IM: test returned empty error, but exit status was nozero; $errors"
#else errors="TEST ERROR OF IMAGE $IM: test returned empty error, but exit status was nozero; $errors"
fi
fi
haserr=false

View File

@ -73,7 +73,7 @@ jobs:
run: |
#build base with riskv64 for sisyphus if it is
if [[ "$BR" == "sisyphus" && "$ORG" == "base" ]]; then echo "${{ gitea.workspace }}/build.py --log-level debug -i base/base -b $BR --latest $BR --registry $BUILD_URL"; ${{ gitea.workspace }}/build.py -i base/base -b "$BR" --latest "$BR" --registry "$BUILD_URL"; fi
build_args="-b $BR --log-level debug --latest $BR -o $ORG --registry $BUILD_URL --package-versions {\"alt/etcd\":\"3.5.15\"}"
build_args="-b $BR --log-level debug --latest $BR -o $ORG --registry $BUILD_URL"
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64 --skip-images base/base"; else arches="--arches amd64 386 arm64"; fi
echo "${{ gitea.workspace }}/build.py $build_args $arches"
${{ gitea.workspace }}/build.py $build_args $arches

View File

@ -0,0 +1,104 @@
name: Full building alt images
on:
push:
tags:
- "*_k8s"
jobs:
build-process:
runs-on: alt-sisyphus
outputs:
branch: ${{ env.BRANCH }}
org: ${{ env.ORG }}
url: ${{ env.URL }}
repo: ${{ env.REPO }}
buildres: ${{ steps.build-script.outcome }}
steps:
- name: Check workspace
run: |
repourl=$(echo $GU | cut -d '/' -f 3)
echo "URL=$repourl" >> ${GITHUB_ENV}
echo $repourl
reponame=$(echo $GR | cut -d '/' -f 1)
echo "REPO=$reponame" >> ${GITHUB_ENV}
echo $reponame
env:
GU: ${{ gitea.server_url }}
GR: ${{ gitea.repository }}
- name: Set repo for c10f2 (Temporary)
if: ${{ contains(github.ref_name, 'c10f2') }}
run: |
echo "event tag=${{ github.ref_name }}"
echo "10.4.0.3 update.altsp.su" >> /etc/hosts
echo "cat /etc/hosts"
cat /etc/hosts
- name: Update apt
uses: actions/init-alt-env@v1
- name: Install requires
run: |
echo "apt-get install -y python3-module-tomli python3-module-jinja2 python3-module-yaml python3-module-requests podman buildah jq curl"
apt-get install -y python3-module-tomli python3-module-jinja2 python3-module-yaml python3-module-requests podman buildah jq curl
echo "apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-riscv qemu-user-static-binfmt-loongarch"
apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-riscv qemu-user-static-binfmt-loongarch
- name: Parse target branch and tag from events context, save to env
env:
EV: ${{ toJson(gitea.event) }}
run: |
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1 >> ${GITHUB_ENV}
org=$(echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 2)
echo "ORG=$org" >> ${GITHUB_ENV}
echo "ORG=$org"
- name: Check out current repo
uses: actions/checkout@v4
- name: Change vendor label for c10f
if: ${{ contains(github.ref_name, 'c10f') }}
run: |
echo "sed -i 's/ALT Linux Team/BaseALT LLC/g' ${{ gitea.workspace }}/org/$ORG/*/Dockerfile.template ||:"
sed -i 's/ALT Linux Team/BaseALT LLC/g' ${{ gitea.workspace }}/org/$ORG/*/Dockerfile.template ||:
echo "sed -i 's/ALT Linux Team/BaseALT LLC/g' ${{ gitea.workspace }}/org/$ORG/*/distroless.toml ||:"
sed -i 's/ALT Linux Team/BaseALT LLC/g' ${{ gitea.workspace }}/org/$ORG/*/distroless.toml ||:
env:
ORG: ${{ env.ORG }}
- name: Login podman gitea
run: |
echo "podman login ${{ env.URL }}"
podman login --username $P_USER --password $P_PASS ${{ env.URL }}
env:
P_USER: ${{ secrets.PODMAN_USER }}
P_PASS: ${{ secrets.PODMAN_PASS }}
- name: Run building script
id: build-script
run: |
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64"; else arches="--arches amd64 386 arm64"; fi
build_args="--registry $BUILD_URL $arches"
#run build script
${{ gitea.workspace }}/.gitea/workflows/k8s_buildscript.py --branch "$BR" --other-build-args "$build_args" --workspace "${{ gitea.workspace }}"
env:
ORG: ${{ env.ORG }}
BR: ${{ env.BRANCH }}
BUILD_URL: "gitea.basealt.ru/alt"
continue-on-error: true
- name: Send notification if build crashed
if: ${{ steps.build-script.outcome != 'success' }}
run: |
issueid=1
body="Building images finish with some errors."
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
echo "notification about test error is sent to issue $issueid"
env:
T: ${{ secrets.TOKEN }}
BR: ${{ env.BRANCH }}
URL: ${{ gitea.server_url }}
REPO: ${{ env.REPO }}
- name: Delete event tag
run: |
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
echo "tag $tagname is deleted"
env:
T: ${{ secrets.TOKEN }}
BR: ${{ env.BRANCH }}
URL: ${{ gitea.server_url }}
REPO: ${{ env.REPO }}
EV: ${{ toJson(gitea.event) }}

View File

@ -19,6 +19,8 @@ import yaml
from jinja2 import Environment, BaseLoader
logger = logging.getLogger(__name__)
clean_images_counter = 0
clean_images_limit_count = 5
ORG_DIR = Path("org")
@ -795,6 +797,24 @@ class DockerBuilder:
self.run(cmd)
global clean_images_counter
if clean_images_limit_count <= clean_images_counter:
cmd = [
"podman",
"rmi",
"--all",
"-f",
]
self.run(cmd,
check=False,
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
clean_images_counter = 0
else:
clean_images_counter += 1
class ImagesInfo:
def __init__(self):

View File

@ -1,12 +1,12 @@
["alt/distroless-toybox"]
skip-branches = [ "p10", "c10f2", "c10f1" ]
["base/distroless-toybox"]
skip-branches = [ "p10", "c10f2", "c10f1" ]
["alt/openjdk21"]
skip-arches = [ "386" ]
["alt/zot"]
skip-arches = [ "386" ]
["alt/ansible"]
skip-branches = [ "c10f2", "c10f1", "p10" ]

View File

@ -9,15 +9,16 @@ LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{% if pkg_versions and "k8s/coredns" in pkg_versions %}
{% set version_parts = pkg_versions["k8s/coredns"].split('.') | length %}
{% set num_version_parts = (pkg_versions["k8s/coredns"].split('.') | length) %}
{% else %}
{% set version_parts = 0 %}
{% set num_version_parts = 0 %}
{% endif %}
{% if branch in ["sisyphus"] and version_parts == 2 %}
{% if num_version_parts == 2 %}
ARG PKG_VERSION
{{ install_packages("coredns-for-kubernetes${PKG_VERSION}") }}
{% elif branch in ["sisyphus", "p11", "c10f2"] and version_parts == 3 %}
{% elif num_version_parts == 3 %}
ARG PKG_VERSION
{{ install_packages("coredns${PKG_VERSION}") }}

View File

@ -3,11 +3,10 @@ is_versioned: true
version_template: v{{ version }}
source_packages:
- >
{%- set version_parts = version.split('.') -%}
{%- set version_major = version_parts[1] | int -%}
{%- if branch in ["sisyphus"] and version_parts | length == 2 and version_major >= 33 -%}
{%- set num_version_parts = (version.split('.') | length) -%}
{%- if num_version_parts == 2 -%}
coredns-for-kubernetes{{ version }}
{%- elif branch in ["sisyphus", "p11", "c10f2"] -%}
{%- elif num_version_parts == 3 -%}
coredns{{ version }}
{%- else -%}
coredns

View File

@ -16,6 +16,6 @@ RUN useradd -g qemu -m -d /home/qemu -s /bin/bash -c "qemu user" -u 107 qemu > /
"kubevirt-container-disk"
) }}
RUN cp -f /usr/share/kube-virt/virt-handler/nsswitch.conf /etc/ && cp -f /usr/share/kube-virt/virt-handler/virt_launcher.cil /
RUN cp -f /usr/share/kube-virt/virt-handler/nsswitch.conf /etc/
ENTRYPOINT ["/usr/bin/virt-handle"]