Skip to content

Commit

Permalink
Merge pull request #22 from alexzhc/main
Browse files Browse the repository at this point in the history
add support for rocky linux and alma linux; add support for RHEL9 and…
  • Loading branch information
alexzhc authored Sep 19, 2022
2 parents b19c887 + b93c146 commit 6c455e8
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 75 deletions.
23 changes: 13 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
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
CHART_VER ?= 0.3.3
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

# Pick a commit according to date from: https://github.com/LINBIT/drbd-headers/commits/master
# For utils 9.21.4: fc45d779096ae5943ea3f56934a1f9b48ffb8e41
DRBD_HEADERS_SHA ?= c757cf357edef67751b8f45a6ea894d287180087 # for utils 9.12.1
DRBD_HEADERS_SHA ?= c757cf357edef67751b8f45a6ea894d287180087# for utils 9.12.1

KVER := $(shell uname -r)
DIST ?= rhel7
ENTRY ?= /pkgs/entrypoint.adapter.sh
IMG ?= shipper rhel7 rhel8 rhel9 bionic focal jammy
REG ?= daocloud.io/daocloud # Test Registry
REG ?= daocloud.io/daocloud# Test-only Registry

drbd9:
cd docker-drbd9 && \
Expand Down Expand Up @@ -42,7 +43,7 @@ shipper:
--build-arg DRBD_VER=$(DRBD_VER) \
--build-arg DRBD_UTILS_VER=$(DRBD_UTILS_VER) \
--build-arg DRBD_HEADERS_SHA=$(DRBD_HEADERS_SHA) \
-t drbd9-shipper:v$(DRBD_VER)
-t drbd9-shipper:v$(DRBD_VER)_$(CHART_VER)

cleanup:
docker volume rm pkgs || true
Expand All @@ -58,7 +59,7 @@ test-docker:
docker volume rm pkgs || true
docker run --rm \
-v pkgs:/pkgs \
drbd9-shipper:v$(DRBD_VER)
drbd9-shipper:v$(DRBD_VER)_$(CHART_VER)
docker run --rm \
-v pkgs:/pkgs \
--privileged \
Expand All @@ -80,11 +81,13 @@ test:
--set registry=daocloud.io/daocloud

push:
for i in $(IMG) ; do \
for j in $(REG); do \
docker tag drbd9-$$i:v$(DRBD_VER) $$j/drbd9-$$i:v$(DRBD_VER); \
docker push $$j/drbd9-$$i:v$(DRBD_VER); \
for i in $(REG) ; do \
for j in $(IMG); do \
[ $$j = "shipper" ] && ver=$(DRBD_VER)_$(CHART_VER) || ver=$(DRBD_VER); \
docker tag drbd9-$$j:v$${ver} $$i/drbd9-$$j:v$${ver}; \
docker push $$i/drbd9-$$j:v$${ver}; \
done \
done


all: drbd9 compiler-centos7 compiler-centos8 shipper push
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
`entrypoint.adapter.sh` wraps around the official containerized DRBD kernel module loader script `entry.sh` to achieve the following goals:

1. Adapt host OS type automatically;
2. Drop drbd kernel modules and drbd-utils to the host;
2. Drop `drbd kernel modules` and `drbd-utils` to the host;
3. Use pre-built kernel modules for stock RHEL/CentOS hosts;
4. Use dynamically built kernel modules for un-stock RHEL/CentOS hosts and Ubuntu hosts;
5. Provide two deployment mode: Job (default) and DaemonSet
5. Provide two deployment modes: Job (default) and DaemonSet

![flowchart](flowchart.drawio.svg)

Expand All @@ -30,8 +30,8 @@ LINBIT/drbd <https://github.com/LINBIT/drbd/tree/drbd-9.1/docker>

## OS Distro Support

* RHEL/CentOS 7
* RHEL/CentOS 8
* RHEL/CentOS/RockyLinux/AlmaLinux 7
* RHEL/CentOS/RockyLinux/AlmaLinux 8
* Kylin V10
* Ubuntu 18 Bionic
* Ubuntu 20 Focal
Expand Down Expand Up @@ -62,8 +62,8 @@ $ yum install -y kernel-devel-$(uname -r)
$ apt-get install -y linux-headers-$(uname -r)
```

> **Note:**
>
> **Note:**
>
> For major releases of stock RHEL/CentOS 7 and 8, `kernel-devel` is not needed
### OS Distros
Expand Down Expand Up @@ -189,7 +189,7 @@ Remove `nodeAffinity`

#### Job

Set `deployOnMaster: "no"`
Set `deployOnMasters: "no"`

## Common Issues

Expand Down
4 changes: 3 additions & 1 deletion docker-drbd9/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ DRBD_VER=${1:-9.0.32-1}

sed -i "s/^ENV DRBD_VERSION.*/ENV DRBD_VERSION ${DRBD_VER}/" Dockerfile.*

[ -f ./drbd.tar.gz ] || wget https://pkg.linbit.com/downloads/drbd/"$([[ $DRBD_VER =~ ^9.0 ]] && echo 9.0 || echo 9 )"/drbd-${DRBD_VER}.tar.gz -O ./drbd.tar.gz
rm -f ./drbd.tar.gz

wget https://pkg.linbit.com/downloads/drbd/"$([[ $DRBD_VER =~ ^9.0 ]] && echo 9.0 || echo 9 )"/drbd-${DRBD_VER}.tar.gz -O ./drbd.tar.gz

shift
for i in $@; do
Expand Down
Binary file removed docker-drbd9/drbd.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-shipper/entrypoint.adapter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if [[ $LB_DROP == yes ]]; then
cp -vf /pkgs/drbd.modules /etc/sysconfig/modules/

# drop drbd utils and set up conf directories
cp -vf /pkgs/utils/* /usr-local/bin/
cp -vf /pkgs/utils/* /usr-local-bin/
cat /pkgs/drbd.conf > /etc/drbd.conf
cp -vf /pkgs/global_common.conf /etc/drbd.d/

Expand Down
1 change: 1 addition & 0 deletions docker-shipper/kernel-devels.centos8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rhel8.6 4.18.0-372.9.1 https://download.rockylinux.org/pub/rocky/8/BaseOS/x86_64/os/Packages/k/kernel-devel-4.18.0-372.9.1.el8.x86_64.rpm
rhel8.5 4.18.0-348 https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-348.el8.x86_64.rpm
rhel8.4 4.18.0-305.3.1 https://vault.centos.org/8.4.2105/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-305.3.1.el8.x86_64.rpm
rhel8.3 4.18.0-240 https://vault.centos.org/8.3.2011/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-240.el8.x86_64.rpm
Expand Down
2 changes: 1 addition & 1 deletion helm/drbd-adapter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.1
version: 0.3.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
12 changes: 7 additions & 5 deletions helm/drbd-adapter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
spec:
initContainers:
- name: shipper
image: {{ $.Values.registry }}/drbd9-shipper:{{ $.Values.drbdVersion }}
image: {{ $.Values.registry }}/drbd9-shipper:{{ $.Values.drbdVersion }}_{{ $.Chart.Version }}
imagePullPolicy: {{ $.Values.imagePullPolicy }}
volumeMounts:
- name: pkgs
Expand Down Expand Up @@ -84,8 +84,8 @@ spec:
readOnly: true
- name: lib-modules
mountPath: /lib/modules
- name: usr-local
mountPath: /usr-local
- name: usr-local-bin
mountPath: /usr-local-bin
- name: etc-drbd-conf
mountPath: /etc/drbd.conf
- name: etc-drbd-d
Expand Down Expand Up @@ -127,18 +127,20 @@ spec:
- name: os-release
hostPath:
path: /etc/os-release
type: FileOrCreate
- name: centos-release
hostPath:
path: /etc/centos-release
type: FileOrCreate
- name: usr-src
hostPath:
path: /usr/src
- name: lib-modules
hostPath:
path: /lib/modules
- name: usr-local
- name: usr-local-bin
hostPath:
path: /usr/local
path: /usr/local/bin
- name: etc-drbd-conf
hostPath:
path: /etc/drbd.conf
Expand Down
51 changes: 11 additions & 40 deletions helm/drbd-adapter/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
{{ $osImage := lower $node.status.nodeInfo.osImage }}
{{ $tag := $.Values.drbdVersion }}
{{ $distro := "unsupported" }}
{{ if regexMatch "(red hat enterprise|centos) .*7" $osImage }}
{{ if regexMatch "(red hat enterprise|centos|almalinux|rocky linux) .*7" $osImage }}
{{ $distro = "rhel7" }}
{{ else if regexMatch "(red hat enterprise|centos) .*8" $osImage }}
{{ else if regexMatch "(red hat enterprise|centos|almalinux|rocky linux) .*8" $osImage }}
{{ $distro = "rhel8" }}
{{ else if regexMatch "(red hat enterprise|centos|almalinux|rocky linux) .*9" $osImage }}
{{ $distro = "rhel9" }}
{{ else if regexMatch "ubuntu .*18" $osImage }}
{{ $distro = "bionic" }}
{{ else if regexMatch "ubuntu .*20" $osImage }}
Expand All @@ -16,7 +18,7 @@
{{ $distro = "jammy" }}
{{ $tag = "v9.1.11" }}
{{ end }}
{{ if and (ne $.Values.deployOnMaster "yes") (or (hasKey $node.metadata.labels "node-role.kubernetes.io/master") (hasKey $node.metadata.labels "node-role.kubernetes.io/control-plane"))}}
{{ if and (ne $.Values.deployOnMasters "yes") (or (hasKey $node.metadata.labels "node-role.kubernetes.io/master") (hasKey $node.metadata.labels "node-role.kubernetes.io/control-plane"))}}
{{ else }}
---
apiVersion: batch/v1
Expand All @@ -42,7 +44,7 @@ spec:
terminationGracePeriodSeconds: 0
containers:
- name: shipper
image: {{ $.Values.registry }}/drbd9-shipper:{{ $tag }}
image: {{ $.Values.registry }}/drbd9-shipper:{{ $.Values.drbdVersion }}_{{ $.Chart.Version }}
imagePullPolicy: {{ $.Values.imagePullPolicy }}
volumeMounts:
- name: pkgs
Expand Down Expand Up @@ -83,8 +85,8 @@ spec:
readOnly: true
- name: lib-modules
mountPath: /lib/modules
- name: usr-local
mountPath: /usr-local
- name: usr-local-bin
mountPath: /usr-local-bin
- name: etc-drbd-conf
mountPath: /etc/drbd.conf
- name: etc-drbd-d
Expand All @@ -103,51 +105,20 @@ spec:
- name: os-release
hostPath:
path: /etc/os-release
- name: centos-release
hostPath:
path: /etc/centos-release
- name: usr-src
hostPath:
path: /usr/src
- name: lib-modules
hostPath:
path: /lib/modules
- name: usr-local
hostPath:
path: /usr/local
- name: etc-drbd-conf
hostPath:
path: /etc/drbd.conf
type: FileOrCreate
- name: etc-drbd-d
hostPath:
path: /etc/drbd.d
type: DirectoryOrCreate
- name: var-lib-drbd
hostPath:
path: /var/lib/drbd
type: DirectoryOrCreate
- name: etc-modules-load
hostPath:
path: /etc/modules-load.d
volumes:
- name: pkgs
emptyDir: {}
- name: os-release
hostPath:
path: /etc/os-release
- name: centos-release
hostPath:
path: /etc/centos-release
type: FileOrCreate
- name: usr-src
hostPath:
path: /usr/src
- name: lib-modules
hostPath:
path: /lib/modules
- name: usr-local
- name: usr-local-bin
hostPath:
path: /usr/local
path: /usr/local/bin
- name: etc-drbd-conf
hostPath:
path: /etc/drbd.conf
Expand Down
20 changes: 10 additions & 10 deletions helm/drbd-adapter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ checkHostname: "yes"

# only apply to "deployKind: job"
# by default NOT deploying on masters (yes|no)
deployOnMaster: "no"
deployOnMasters: "no"

# only apply to "deployKind: daemonset"
# by default drop binary files to the host: (yes|no),
drop: "yes"

# avoid master nodes, you may defind more here to avoid more nodes
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/master
operator: DoesNotExist
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
affinity: {}
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: node-role.kubernetes.io/master
# operator: DoesNotExist
# - key: node-role.kubernetes.io/control-plane
# operator: DoesNotExist

0 comments on commit 6c455e8

Please sign in to comment.