Skip to content

Commit

Permalink
templates: Introduce kubelet-dependencies.target
Browse files Browse the repository at this point in the history
The primary motivation here is to eventually stop pulling
container images `Before=network-online.target` because it
creates complicated dependency loops.

We introduce a new `kubelet-dependencies.target` - both `crio.service`
and `kubelet.service` are `After+Requires=kubelet-dependencies.target`.

This also makes it cleaner for pre-kubelet services, which can
just order themselves `Before=kubelet-dependencies.target`.

This is just a small preparatory PR to introduce the target unit.
The real bigger change will come when we move services
like `ovs-configuration.service` and `node-valid-hostname.service`
to actually be `After=network-online.target` + `Before=kubelet-dependendies.target`.

Crucially, this will unblock services like `machine-config-daemon-pull.service`
that want to fetch containers *before* `kubelet.service` but want to be
`After=network-online.target`.
  • Loading branch information
cgwalters committed Aug 15, 2023
1 parent 40dfd9b commit e7ad4e3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
5 changes: 5 additions & 0 deletions templates/common/_base/units/crio.service.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: crio.service
dropins:
- name: 05-mco-ordering.conf
contents: |
[Unit]
After=kubelet-dependencies.target
Requires=kubelet-dependencies.target
- name: 10-mco-default-madv.conf
contents: |
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ contents: |
Description=Dynamically sets the system reserved for the kubelet
Wants=network-online.target
After=network-online.target ignition-firstboot-complete.service
Before=kubelet.service crio.service
[Service]
# Need oneshot to delay kubelet
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/node-sizing-enabled.env
ExecStart=/bin/bash /usr/local/sbin/dynamic-system-reserved-calc.sh ${NODE_SIZING_ENABLED} ${SYSTEM_RESERVED_MEMORY} ${SYSTEM_RESERVED_CPU} ${SYSTEM_RESERVED_ES}
[Install]
RequiredBy=kubelet.service
RequiredBy=kubelet-dependencies.target
8 changes: 8 additions & 0 deletions templates/common/_base/units/kubelet-dependencies.target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: kubelet-dependencies.target
contents: |
[Unit]
Description=Dependencies necessary to run kubelet
Documentation=https://github.com/openshift/machine-config-operator/
Requires=basic.target network-online.target
Wants=NetworkManager-wait-online.service crio-wipe.service
Wants=rpc-statd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ enabled: true
contents: |
[Unit]
Description=Kubernetes Kubelet
Wants=rpc-statd.service network-online.target
Requires=crio.service kubelet-auto-node-size.service
After=network-online.target crio.service kubelet-auto-node-size.service
Requires=crio.service kubelet-dependencies.target
After=kubelet-dependencies.target
After=ostree-finalize-staged.service
[Service]
Expand Down

0 comments on commit e7ad4e3

Please sign in to comment.