-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bake k0s as a systemd sysext image. #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, some feedback:
- do you want some units to be started when the sysext is loaded? If yes, you might need to add this kind of command:
sysext-bakery/create_containerd_sysext.sh
Lines 69 to 70 in 045a4f9
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.d" { echo "[Unit]"; echo "Upholds=containerd.service"; } > "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.d/10-containerd-service.conf" - could you write some documentation on how to use this sysext (e.g does it need provisioning with Ignition to create files / enable units / etc.)
create_k0s_sysext.sh
Outdated
# The github release uses different arch identifiers, we map them here | ||
# and rely on bake.sh to map them back to what systemd expects | ||
if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "x86-64" ]; then | ||
URL="https://github.com/k0sproject/k0s/releases/download/${VERSION}/k0s-${VERSION}-amd64" | ||
elif [ "${ARCH}" = "arm64" ] || [ "${ARCH}" = "aarch64" ]; then | ||
URL="https://github.com/k0sproject/k0s/releases/download/${VERSION}/k0s-${VERSION}-arm64" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just set the correct ARCH and only assign one URL. Something like that:
# The github release uses different arch identifiers, we map them here | |
# and rely on bake.sh to map them back to what systemd expects | |
if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "x86-64" ]; then | |
URL="https://github.com/k0sproject/k0s/releases/download/${VERSION}/k0s-${VERSION}-amd64" | |
elif [ "${ARCH}" = "arm64" ] || [ "${ARCH}" = "aarch64" ]; then | |
URL="https://github.com/k0sproject/k0s/releases/download/${VERSION}/k0s-${VERSION}-arm64" | |
fi | |
# The github release uses different arch identifiers, we map them here | |
# and rely on bake.sh to map them back to what systemd expects | |
if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "x86-64" ]; then | |
ARCH="amd64" | |
fi | |
if [ "${ARCH}" = "arm64" ] || [ "${ARCH}" = "aarch64" ]; then | |
ARCH="arm64" | |
fi | |
URL="https://github.com/k0sproject/k0s/releases/download/${VERSION}/k0s-${VERSION}-${ARCH}" |
create_k0s_sysext.sh
Outdated
popd | ||
|
||
mkdir -p "${SYSEXTNAME}"/usr/local/lib/systemd/system/ | ||
cat > "${SYSEXTNAME}"/etc/systemd/system/k0s.service << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cat > "${SYSEXTNAME}"/etc/systemd/system/k0s.service << EOF | |
cat > "${SYSEXTNAME}"/usr/local/lib/systemd/system/k0s.service << EOF |
/etc
content is not applied when the sysext is merged to the OS (only /usr
and /opt
).
create_k0s_sysext.sh
Outdated
WantedBy=multi-user.target | ||
EOF | ||
|
||
cat > "${SYSEXTNAME}"/etc/systemd/system/k0scontroller.service << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cat > "${SYSEXTNAME}"/etc/systemd/system/k0scontroller.service << EOF | |
cat > "${SYSEXTNAME}"/usr/local/lib/systemd/system/k0scontroller.service << EOF |
Same as above.
create_k0s_sysext.sh
Outdated
WantedBy=multi-user.target | ||
EOF | ||
|
||
cat > "${SYSEXTNAME}"/etc/systemd/system/k0sworker.service << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There will be no systemd units automatically enabled. As will be written in the documentation: ii. not opting for k0s embedded componets will lead to other systemd units being enabled by the user(via Ignition) ->(
Ok |
@tormath1 I've committed the requested changes. Please take a look. |
1. the sysext plus the configuration files /etc/k0s/k0s.yaml and/or /etc/default/k0s | ||
2. the systemd units | ||
|
||
After you enable k0s syext following the guide deacribed on Consuming the published images, follow the next steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you enable k0s syext following the guide deacribed on Consuming the published images, follow the next steps: | |
After you enabled k0s sysext following the guide described on consuming the published images, follow the next steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs to be pushed with executable mode:
diff --git a/create_k0s_sysext.sh b/create_k0s_sysext.sh
old mode 100644
new mode 100755
EnvironmentFile=-/etc/default/k0s | ||
StartLimitInterval=5 | ||
StartLimitBurst=10 | ||
ExecStart=/bin/sh -c '[ -n "${CRI_SOCKET}" ] && exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --cri-socket=${CRI_SOCKET} || exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work:
./create_k0s_sysext.sh: line 41: CRI_SOCKET: unbound variable
You need to escape those values (individually or globally with \EOF
)
EnvironmentFile=-/etc/default/k0s | ||
StartLimitInterval=5 | ||
StartLimitBurst=10 | ||
ExecStart=/bin/sh -c '[ -n "${CRI_SOCKET}" ] && exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --cri-socket=${CRI_SOCKET} || exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecStart=/bin/sh -c '[ -n "${CRI_SOCKET}" ] && exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --cri-socket=${CRI_SOCKET} || exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml' | |
ExecStart=/bin/sh -c '[ -n "${CRI_SOCKET}" ] && exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --cri-socket="${CRI_SOCKET}" || exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml' |
(Same for the other units)
EnvironmentFile=-/etc/default/k0s | ||
StartLimitInterval=5 | ||
StartLimitBurst=10 | ||
ExecStart=/usr/local/bin/k0s worker --cri-socket=$CRI_SOCKET --token-file=/etc/k0s/worker-token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecStart=/usr/local/bin/k0s worker --cri-socket=$CRI_SOCKET --token-file=/etc/k0s/worker-token | |
ExecStart=/usr/local/bin/k0s worker --cri-socket="${CRI_SOCKET}" --token-file=/etc/k0s/worker-token |
|
||
After you enable k0s syext following the guide deacribed on Consuming the published images, follow the next steps: | ||
|
||
1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this mandatory? One might not know by advance the private IP address.
EnvironmentFile=-/etc/default/k0s | ||
StartLimitInterval=5 | ||
StartLimitBurst=10 | ||
ExecStart=/bin/sh -c '[ -n "${CRI_SOCKET}" ] && exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --cri-socket=${CRI_SOCKET} --token-file=/etc/k0s/controller-token|| exec /usr/local/bin/k0s controller --config=/etc/k0s/k0s.yaml --token-file=/etc/k0s/controller-token' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Who's supposed to generate this
/etc/k0s/controller-token
?
Should we start the k0s.service
before ? If yes, it should be documented.
Adding |
Bake k0s as a systemd sysext image.
This PR aims to bake k0s as a systemd sysext and also provide a systemd unit file to manage k0s.
How to use
[ describe what reviewers need to do in order to validate this PR ]
Testing done
[Describe the testing you have done before submitting this PR. Please include both the commands you issued as well as the output you got.]
changelog/
directory (user-facing change, bug fix, security fix, update)/boot
and/usr
size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.