From: Francisco Manuel Garcia Botella Date: Thu, 9 May 2024 11:15:18 +0000 (+0200) Subject: k8s: Add dockerfile to create an image to compile k8s plugin in any debian/ubuntu... X-Git-Tag: Release-15.0.3~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5923732a5d8a0d8fe411e568a0fbafa38e9af5b1;p=thirdparty%2Fbacula.git k8s: Add dockerfile to create an image to compile k8s plugin in any debian/ubuntu distribution --- diff --git a/bacula/src/plugins/fd/kubernetes-backend/docker/Dockerfile b/bacula/src/plugins/fd/kubernetes-backend/docker/Dockerfile new file mode 100644 index 000000000..f1b540f39 --- /dev/null +++ b/bacula/src/plugins/fd/kubernetes-backend/docker/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:bullseye + +COPY ./requirements.txt /mnt/ + +RUN apt update && \ + DEBIAN_FRONTEND=noninteractive apt install -y build-essential postgresql libpq-dev libwrap0-dev python3 nano cython3 python3-pip openssh-client rsync libssl-dev && \ + pip install pyinstaller && \ + pip install -r /mnt/requirements.txt + +COPY ./docker-entrypoint.sh / + +RUN chmod +x /docker-entrypoint.sh + +WORKDIR /mnt/regress/ + + +ENTRYPOINT ["/docker-entrypoint.sh"] +# To compile: + # Add Makefile rule: + # async: + # rsync -av -i ../bacula/src/ build/src/ + # Change directory to: /mnt/regress/ + # Execute: + # make async && -C build/src/plugins/fd install-kubernetes && make -C build/src/plugins/fd/kubernetes-backend clean && make -C build/src/plugins/fd/kubernetes-backend install-kubernetes + # Binary in: ~/regress/bin/k8s_backend \ No newline at end of file diff --git a/bacula/src/plugins/fd/kubernetes-backend/docker/README b/bacula/src/plugins/fd/kubernetes-backend/docker/README new file mode 100644 index 000000000..968d80408 --- /dev/null +++ b/bacula/src/plugins/fd/kubernetes-backend/docker/README @@ -0,0 +1,97 @@ +# Target + +This docker image is to compile k8s plugin independent of ubuntu/debian platform. I had problems with libc library, so to isolate this problem, we create this docker image. + +If you want change this version, modify the image tag and dockerfile FROM. + +**Note:** The difference between Ubuntu and Debian in this compilation is that `rm` binary is allocated in other place: + - Ubuntu: `/usr/bin/rm` + - Debian: `/bin/rm` + +So, the Makefile will be modified to avoid errors. + +# Create the Docker image + +We need copy the requirements to docker context folder. For this reason, we do: +```bash +cp -a ../requirements.txt . +``` + +```bash +docker build -t k8s_compilation:jammy . +``` + +# Pre-Run docker container + +To compile in docker container, we need modify the `regress config file` to adapt. + +Add BACULA_SOURCE: + +```bash +# Where to get the source to be tested +BACULA_SOURCE="/mnt/bacula/" +``` + +Discomment --disable-sd-dedup: +```bash +# DEDUP allows to disable deduplication on the SD +# If you don't have TokyoCabinet +DEDUP=--disable-sd-dedup +#DEDUP= +``` + + +Set postgresql database: +```bash +# Set your database here +#WHICHDB="--with-sqlite3=${SQLITE3_DIR}" +WHICHDB="--with-postgresql" +#WHICHDB="--with-mysql" +``` + +We need compile with this config because unless we can't compile k8s. + + +Also we need modify the `regress/Makefile` and add the next rule at the end of file: + +``` +async: + rsync -av -i ../bacula/src/ build/src/ +``` + +# Run docker container +In root project (bacula-bee folder), execute: + +```bash +docker run --rm -it -v $(pwd):/mnt k8s_compilation:jammy /bin/bash +``` + +# Compile k8s plugin + +Execute: +```bash +make async +``` + +```bash +make -C build/src/plugins/fd install-kubernetes +``` + +```bash +make -C build/src/plugins/fd/kubernetes-backend clean +``` + +```bash +make -C build/src/plugins/fd/kubernetes-backend install-kubernetes +``` + +Or in one command: +```bash +make async; make -C build/src/plugins/fd install-kubernetes; make -C build/src/plugins/fd/kubernetes-backend clean; make -C build/src/plugins/fd/kubernetes-backend install-kubernetes +``` + +# Get the k8s_backend binary + +Will be in `~/regress/bin/k8s_backend`. + +The last action to do in this file is change the permissions or owner. \ No newline at end of file diff --git a/bacula/src/plugins/fd/kubernetes-backend/docker/docker-entrypoint.sh b/bacula/src/plugins/fd/kubernetes-backend/docker/docker-entrypoint.sh new file mode 100755 index 000000000..dfad74981 --- /dev/null +++ b/bacula/src/plugins/fd/kubernetes-backend/docker/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +TMP_DIR="/mnt/regress/tmp" + +if [ ! -d "$TMP_DIR" ]; then + make setup +else + echo "The directory /mnt/regress/tmp already exists. So, we do not make setup" +fi + +/bin/bash diff --git a/bacula/src/plugins/fd/kubernetes-backend/docker/requirements.txt b/bacula/src/plugins/fd/kubernetes-backend/docker/requirements.txt new file mode 100644 index 000000000..d452db71b --- /dev/null +++ b/bacula/src/plugins/fd/kubernetes-backend/docker/requirements.txt @@ -0,0 +1,26 @@ +# -*- coding: UTF-8 -*- +# +# Bacula® - The Network Backup Solution +# +# Copyright (C) 2000-2019 Bacula Systems SA +# All rights reserved. +# +# The main author of Bacula is Kern Sibbald, with contributions from many +# others, a complete list can be found in the file AUTHORS. +# +# Licensees holding a valid Bacula Systems SA license may use this file +# and others of this release in accordance with the proprietary license +# agreement provided in the LICENSE file. Redistribution of any part of +# this release is not permitted. +# +# Bacula® is a registered trademark of Kern Sibbald. +# +# Copyright (c) 2019 by Inteos sp. z o.o. +# All rights reserved. IP transfered to Bacula Systems according to agreement. +# Author: Radosław Korzeniewski, radekk@inteos.pl, Inteos Sp. z o.o. +# + +pyyaml == 6.0 +kubernetes <= 26.1.0 +urllib3 == 1.26.16 +requests == 2.27.1