diff --git a/Makefile b/Makefile index 4fd7a88..9404ebf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -CHART_VER ?= 0.4.0 +CHART_VER ?= 0.4.1 DRBD_VER ?= 9.0.32-1# another tested value is: 9.1.11 DRBD_UTILS_VER ?= 9.12.1# another tested value is: 9.21.4 diff --git a/docker-drbd9/Dockerfile.bionic b/docker-drbd9/Dockerfile.bionic index d21b5e7..a47abf6 100644 --- a/docker-drbd9/Dockerfile.bionic +++ b/docker-drbd9/Dockerfile.bionic @@ -11,8 +11,6 @@ RUN apt-get update && apt-get install -y kmod gnupg wget make gcc patch curl && COPY /drbd.tar.gz / COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/Dockerfile.flatcar b/docker-drbd9/Dockerfile.flatcar index 10e0ca6..c031e9a 100644 --- a/docker-drbd9/Dockerfile.flatcar +++ b/docker-drbd9/Dockerfile.flatcar @@ -2,8 +2,6 @@ FROM gentoo/stage3 MAINTAINER Roland Kammerer COPY /drbd.tar.gz / -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh ENTRYPOINT /entry.sh diff --git a/docker-drbd9/Dockerfile.focal b/docker-drbd9/Dockerfile.focal index 858b3f5..91fea7f 100644 --- a/docker-drbd9/Dockerfile.focal +++ b/docker-drbd9/Dockerfile.focal @@ -11,8 +11,6 @@ RUN apt-get update && apt-get install -y kmod gnupg wget make gcc patch curl && COPY /drbd.tar.gz / COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/Dockerfile.jammy b/docker-drbd9/Dockerfile.jammy index a04c8d6..1899d1d 100644 --- a/docker-drbd9/Dockerfile.jammy +++ b/docker-drbd9/Dockerfile.jammy @@ -10,8 +10,6 @@ RUN apt-get update && apt-get install -y kmod gnupg wget make gcc patch elfutils COPY /drbd.tar.gz / COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/Dockerfile.kylin10 b/docker-drbd9/Dockerfile.kylin10 index 2856e27..4a816cf 100644 --- a/docker-drbd9/Dockerfile.kylin10 +++ b/docker-drbd9/Dockerfile.kylin10 @@ -38,8 +38,6 @@ RUN wget --no-check-certificate https://pkg.linbit.com/downloads/drbd/"$([[ $DRB COPY /pkgs /pkgs COPY /drbdUtils.tar.gz / COPY /install-drbdutils.sh / -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh ENTRYPOINT /entry.sh diff --git a/docker-drbd9/Dockerfile.rhel7 b/docker-drbd9/Dockerfile.rhel7 index f9239d7..3f6e988 100644 --- a/docker-drbd9/Dockerfile.rhel7 +++ b/docker-drbd9/Dockerfile.rhel7 @@ -26,8 +26,6 @@ RUN wget --no-check-certificate https://pkg.linbit.com/downloads/drbd/"$([[ $DRB # =lbbuild COPY /drbd.tar.gz / COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/Dockerfile.rhel8 b/docker-drbd9/Dockerfile.rhel8 index 6049458..f84060c 100644 --- a/docker-drbd9/Dockerfile.rhel8 +++ b/docker-drbd9/Dockerfile.rhel8 @@ -47,8 +47,6 @@ RUN wget --no-check-certificate https://pkg.linbit.com/downloads/drbd/"$([[ $DRB # these are now the kmod pkgs: COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/Dockerfile.rhel9 b/docker-drbd9/Dockerfile.rhel9 index 6e44dcc..3dd96b5 100644 --- a/docker-drbd9/Dockerfile.rhel9 +++ b/docker-drbd9/Dockerfile.rhel9 @@ -37,8 +37,6 @@ RUN curl -fsSL https://pkg.linbit.com/downloads/drbd/"$([[ $DRBD_VERSION =~ ^9.0 # these are now the kmod pkgs: COPY /pkgs /pkgs -COPY /entrypoint.adapter.sh / -RUN chmod +x /entrypoint.adapter.sh COPY /entry.sh / RUN chmod +x /entry.sh diff --git a/docker-drbd9/entrypoint.adapter.sh b/docker-drbd9/entrypoint.adapter.sh deleted file mode 100755 index de4ba97..0000000 --- a/docker-drbd9/entrypoint.adapter.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -x -## Maintainer Alex Zheng -## This is a wrapper scripts to have drbd9 containers automatically adapt host distros - -## Check if image matches os type -which lbdisttool.py - -image_dist="$(lbdisttool.py -l | awk -F'.' '{print $1}' )" -host_dist="$(lbdisttool.py -l --os-release /etc/host-release | awk -F'.' '{print $1}' )" - -# For Kylin v10 -if [ -z $image_dist ] \ - && grep -i "kylin .* v10" /etc/os-release; then - echo "Image distro is Kylin V10" - image_dist=kylin10 -fi - -if [ -z $host_dist ] \ - && uname -r | grep -i '.ky10.' \ - && grep -i "kylin .* v10" /etc/host-release; then - echo "Host distro is Kylin V10" - host_dist=kylin10 -fi - -# For DaemonSet: Gracefully exit for distro mismatch, so that next initContainer may start -# For Job: Exit failure -if [[ $host_dist != $image_dist ]]; then - echo "Image type does not match OS type, skip !" - [[ $LB_SKIP == 'yes' ]] && exit 0 || exit 1 -fi - -## Unload current drbd modules from kernel if it is lower than the target version -# (only possible if no [drbd_xxx] process is running) -RUNNING_DRBD_VERSION=$( cat /proc/drbd | awk '/^version:/ {print $2}' ) - -if [ -z $RUNNING_DRBD_VERSION ]; then - echo "No DRBD Module is loaded" -elif [[ $RUNNING_DRBD_VERSION == $DRBD_VERSION ]] || \ - [[ $( printf "$RUNNING_DRBD_VERSION\n$DRBD_VERSION" | sort -V | tail -1 ) != $DRBD_VERSION ]] -then - echo "The loaded DRBD module version is already $RUNNING_DRBD_VERSION" -else - echo "The loaded DRBD module version $RUNNING_DRBD_VERSION is lower than $DRBD_VERSION" - if [[ $LB_UPGRADE == 'yes' ]] || [[ $RUNNING_DRBD_VERSION =~ ^8 ]]; then - for i in drbd_transport_tcp drbd; do - if lsmod | grep -w $i; then - rmmod $i || true - fi - done - fi -fi - -## Main Logic -# If no shipped module is found, then compile from source -echo "OS_KERNEL:$1" -export DRBD_EXIST='no' -export DRBD_RMP_INSTALL='no' -export OS_KERNEL=$1 -if [[ $host_dist == 'kylin10' ]]; then - LB_HOW=compile -else - LB_HOW=shipped_modules -fi -if [[ $LB_HOW == 'shipped_modules' ]]; then - source /entry.sh - echo "Successfully loaded shipped module" -elif [[ $LB_HOW == 'compile' ]]; then - source /entry.sh - echo "Successfully loaded compiled module" -fi - -echo "DRBD IS ALREADY EXIST (yes or no):$DRBD_EXIST" -echo "DRBD INSTALL BY PRM (yes or no) :$DRBD_RMP_INSTALL" -#If the installation through rpm is successful, exit directly. -if [[ "$DRBD_RMP_INSTALL" == 'yes' ]];then - echo "Successfully installed rbd using rpm package" - exit 0 -fi - -# Drop modules to the host so it can independently load from OS -if [[ $LB_DROP == yes ]]; then - - # drop modules - if [[ $host_dist =~ rhel|kylin10 ]]; then - KODIR="/lib/modules/$(uname -r)/extra/drbd" - elif [[ $host_dist =~ bionic|focal|jammy ]]; then - KODIR="/lib/modules/$(uname -r)/updates/dkms/drbd" - else - KODIR="/lib/modules/$(uname -r)/drbd" - fi - mkdir -vp "$KODIR" - cp -vf /tmp/ko/*.ko "${KODIR}/" - - # register modules - depmod -a - - # onboot load modules - cp -vf /pkgs/drbd.modules-load.conf /etc/modules-load.d/drbd.conf - cp -vf /pkgs/drbd.modules /etc/sysconfig/modules/ - - # drop drbd utils and set up conf directories - cp -vf /pkgs/utils/* /usr-local-bin - cat /pkgs/drbd.conf > /etc/drbd.conf - cp -vf /pkgs/global_common.conf /etc/drbd.d/ - -fi - -# Check if DRBD is loaded correctly -if [[ $( cat /proc/drbd | awk '/^version/ {print $2}' ) != $DRBD_VERSION ]]; then - echo "ERROR: DRBD is NOT loaded with the right version" - exit 1 -fi - -# Check if hostname is the same as k8s node name -# With `hostNetwork`, container `hostname` cmd result is from host /proc/sys/kernel/hostname and /proc/sys/kernel/domainname -if [[ $LB_CHECK_HOSTNAME == 'yes' ]] && [[ $(hostname) != $NODE_NAME ]]; then - echo "ERROR: Hostname does not match K8s node name!" - exit 1 -fi - -exit 0 diff --git a/helm/drbd-adapter/Chart.yaml b/helm/drbd-adapter/Chart.yaml index 18af084..e2bef0d 100644 --- a/helm/drbd-adapter/Chart.yaml +++ b/helm/drbd-adapter/Chart.yaml @@ -4,10 +4,10 @@ description: A DRBD kernel loader that auto-adapts OS distros type: application -version: v0.4.0 +version: v0.4.1 appVersion: v9.0.32 -## +### diff --git a/helm/drbd-adapter/templates/daemonset.yaml b/helm/drbd-adapter/templates/daemonset.yaml index e6e5de8..081f722 100644 --- a/helm/drbd-adapter/templates/daemonset.yaml +++ b/helm/drbd-adapter/templates/daemonset.yaml @@ -56,7 +56,7 @@ spec: image: {{ $.Values.registry }}/drbd9-{{ $dist }}:{{ $tag }} imagePullPolicy: {{ $.Values.imagePullPolicy }} command: - - /entrypoint.adapter.sh + - /pkgs/entrypoint.adapter.sh - {{ $kernelVersion }} securityContext: privileged: true diff --git a/helm/drbd-adapter/templates/job.yaml b/helm/drbd-adapter/templates/job.yaml index c39f040..55724ef 100644 --- a/helm/drbd-adapter/templates/job.yaml +++ b/helm/drbd-adapter/templates/job.yaml @@ -58,7 +58,7 @@ spec: image: {{ $.Values.registry }}/drbd9-{{ $distro }}:{{ $tag }} imagePullPolicy: {{ $.Values.imagePullPolicy }} command: - - /entrypoint.adapter.sh + - /pkgs/entrypoint.adapter.sh - {{ $kernelVersion }} securityContext: privileged: true