Skip to content

Commit

Permalink
Merge pull request #1768 from cgwalters/bootkube-before-kubelet
Browse files Browse the repository at this point in the history
bootkube: Run before kubelet.service, start it during script
  • Loading branch information
openshift-merge-robot authored Oct 24, 2019
2 parents ce0d637 + 5aceea9 commit 52a0a8a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
14 changes: 1 addition & 13 deletions data/data/bootstrap/files/usr/local/bin/bootkube.sh.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

. /usr/local/bin/release-image.sh

Expand Down Expand Up @@ -37,18 +37,6 @@ MDNS_PUBLISHER_IMAGE=$(image_for mdns-publisher)
HAPROXY_IMAGE=$(image_for haproxy-router)
BAREMETAL_RUNTIMECFG_IMAGE=$(image_for baremetal-runtimecfg)

# Now, as early as possible we replace the pause image and reload crio to use it, to ensure
# that we're using the pause image from our payload just like the primary cluster.
# The config should match the one generated by the MCO ideally:
# https://github.com/openshift/machine-config-operator/blob/e861ccb12f09c7c768d51fdf0a17879fcc9a87d5/templates/master/01-master-container-runtime/_base/files/crio.yaml
# But for now we're just changing the key bits: image and command.
# Perhaps down the line we change this to run something like:
# podman run machine-config-daemon bootstrap ... (passing the release image and the host rootfs)
sed --in-place --expression "s,pause_image *=.*,pause_image = \"${MACHINE_CONFIG_INFRA_IMAGE}\"," /etc/crio/crio.conf
sed --in-place --expression 's,pause_command *=.*,pause_command = "/usr/bin/pod",' /etc/crio/crio.conf
# Note crio today has a reload command but it just dies from the SIGHUP sent...
systemctl restart cri-o.service

mkdir --parents ./{bootstrap-manifests,manifests}

if [ ! -f openshift-manifests.done ]
Expand Down
16 changes: 16 additions & 0 deletions data/data/bootstrap/files/usr/local/bin/crio-configure.sh.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
# Before kubelet.service and crio.service start, ensure
# that we're using the pause image from our payload just like the primary cluster.
# The config should match the one generated by the MCO ideally:
# https://github.com/openshift/machine-config-operator/blob/e861ccb12f09c7c768d51fdf0a17879fcc9a87d5/templates/master/01-master-container-runtime/_base/files/crio.yaml
# But for now we're just changing the key bits: image and command.
# Perhaps down the line we change this to run something like:
# podman run machine-config-daemon bootstrap ... (passing the release image and the host rootfs)

. /usr/local/bin/release-image.sh

MACHINE_CONFIG_INFRA_IMAGE=$(image_for pod)

sed --in-place --expression "s,pause_image *=.*,pause_image = \"${MACHINE_CONFIG_INFRA_IMAGE}\"," /etc/crio/crio.conf
sed --in-place --expression 's,pause_command *=.*,pause_command = "/usr/bin/pod",' /etc/crio/crio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ done

echo "Gathering bootstrap journals ..."
mkdir -p "${ARTIFACTS}/bootstrap/journals"
for service in release-image bootkube kubelet crio approve-csr
for service in release-image crio-configure bootkube kubelet crio approve-csr
do
journalctl --boot --no-pager --output=short --unit="${service}" > "${ARTIFACTS}/bootstrap/journals/${service}.log"
done
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Download the release image. This script is executed as a oneshot
# service by systemd, because we cannot make use of Requires and a
# simple service: https://github.com/systemd/systemd/issues/1312.
Expand All @@ -15,3 +16,4 @@ while ! podman pull --quiet "$RELEASE_IMAGE"
do
echo "Pull failed. Retrying $RELEASE_IMAGE..."
done

4 changes: 2 additions & 2 deletions data/data/bootstrap/systemd/units/bootkube.service
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Unit]
Description=Bootstrap a Kubernetes cluster
Requires=release-image.service
Requires=crio-configure.service
Wants=kubelet.service
After=kubelet.service release-image.service
After=kubelet.service crio-configure.service
ConditionPathExists=!/opt/openshift/.bootkube.done

[Service]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Configure CRI-O to use the pause image
After=release-image.service
Requires=release-image.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/crio-configure.sh
RemainAfterExit=true
3 changes: 2 additions & 1 deletion data/data/bootstrap/systemd/units/kubelet.service.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service
Wants=rpc-statd.service crio.service
After=crio.service

[Service]
Type=notify
Expand Down

0 comments on commit 52a0a8a

Please sign in to comment.