mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-08-08 23:37:11 +00:00
Mask and stop services that compete with apt operations or are not needed for Kubernetes nodes: - apt-news.service/timer: fetches APT news, holds apt lock - esm-cache.service: Ubuntu Pro cache updates - snapd.service/socket: Snap package manager - lxd-installer.socket: LXD container helper - ubuntu-advantage.service: Ubuntu Pro auto-attach - unattended-upgrades.service: automatic security updates - motd-news.timer: MOTD news fetching - update-notifier-motd.timer: "new Ubuntu version" checks - update-notifier-download.timer: failed package retry This addresses CI timeouts where apt-news.service running concurrently with apt-get update caused the master node to take ~5 minutes for package index downloads (vs ~5-9 seconds on worker nodes). Signed-off-by: Davanum Srinivas <davanum@gmail.com>
99 lines
3.0 KiB
YAML
99 lines
3.0 KiB
YAML
#cloud-config
|
|
|
|
write_files:
|
|
- path: /etc/systemd/system/kube-node-installation.service
|
|
permissions: 0644
|
|
owner: root
|
|
content: |
|
|
[Unit]
|
|
Description=Download and install k8s binaries and configurations
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
ExecStartPre=/bin/mkdir -p /home/kubernetes/bin
|
|
ExecStartPre=/bin/mount --bind /home/kubernetes/bin /home/kubernetes/bin
|
|
ExecStartPre=/bin/mount -o remount,exec /home/kubernetes/bin
|
|
ExecStartPre=/usr/bin/curl --fail --retry 5 --retry-delay 3 --silent --show-error -H "X-Google-Metadata-Request: True" -o /home/kubernetes/bin/configure.sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh
|
|
ExecStartPre=/bin/chmod 544 /home/kubernetes/bin/configure.sh
|
|
ExecStart=/home/kubernetes/bin/configure.sh
|
|
StandardOutput=journal+console
|
|
|
|
[Install]
|
|
WantedBy=kubernetes.target
|
|
|
|
- path: /etc/systemd/system/kube-node-configuration.service
|
|
permissions: 0644
|
|
owner: root
|
|
content: |
|
|
[Unit]
|
|
Description=Configure kubernetes node
|
|
After=kube-node-installation.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
ExecStartPre=/bin/chmod 544 /home/kubernetes/bin/configure-helper.sh
|
|
ExecStart=/home/kubernetes/bin/configure-helper.sh
|
|
StandardOutput=journal+console
|
|
|
|
[Install]
|
|
WantedBy=kubernetes.target
|
|
|
|
- path: /etc/systemd/system/kube-logrotate.timer
|
|
permissions: 0644
|
|
owner: root
|
|
content: |
|
|
[Unit]
|
|
Description=Hourly kube-logrotate invocation
|
|
|
|
[Timer]
|
|
OnCalendar=hourly
|
|
|
|
[Install]
|
|
WantedBy=kubernetes.target
|
|
|
|
- path: /etc/systemd/system/kube-logrotate.service
|
|
permissions: 0644
|
|
owner: root
|
|
content: |
|
|
[Unit]
|
|
Description=Kubernetes log rotation
|
|
After=kube-node-configuration.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=-/usr/sbin/logrotate /etc/logrotate.conf
|
|
|
|
[Install]
|
|
WantedBy=kubernetes.target
|
|
|
|
- path: /etc/systemd/system/kubernetes.target
|
|
permissions: 0644
|
|
owner: root
|
|
content: |
|
|
[Unit]
|
|
Description=Kubernetes
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
|
|
- path: /etc/modprobe.d/sunrpc.conf
|
|
permissions: 0644
|
|
owner: root
|
|
# The GKE metadata server uses ports 987-989, so the sunrpc range should be restricted to be below.
|
|
content: |
|
|
options sunrpc max_resvport=986
|
|
|
|
runcmd:
|
|
- systemctl mask apt-news.service apt-news.timer esm-cache.service snapd.service snapd.socket lxd-installer.socket ubuntu-advantage.service unattended-upgrades.service motd-news.timer update-notifier-motd.timer update-notifier-download.timer || true
|
|
- systemctl stop unattended-upgrades.service || true
|
|
- systemctl daemon-reload
|
|
- systemctl enable kube-node-installation.service
|
|
- systemctl enable kube-node-configuration.service
|
|
- systemctl enable kube-logrotate.timer
|
|
- systemctl enable kube-logrotate.service
|
|
- systemctl enable kubernetes.target
|
|
- systemctl start kubernetes.target
|