mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 13:14:33 +00:00
kata-deploy: Use host's systemctl
when interacting with systemd. We have occasionally faced issues with compatibility between the systemctl version used inside the kata-deploy container and the systemd version on the host. Instead of using a containerized systemctl with bind mounted sockets, nsenter the host and run systemctl from there. This provides less coupling between the kata-deploy container and the host. Fixes: #7511 Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
This commit is contained in:
parent
29855ed0c6
commit
3230dec950
@ -14,6 +14,7 @@ spec:
|
|||||||
name: kubelet-kata-cleanup
|
name: kubelet-kata-cleanup
|
||||||
spec:
|
spec:
|
||||||
serviceAccountName: kata-deploy-sa
|
serviceAccountName: kata-deploy-sa
|
||||||
|
hostPID: true
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
katacontainers.io/kata-runtime: cleanup
|
katacontainers.io/kata-runtime: cleanup
|
||||||
containers:
|
containers:
|
||||||
@ -38,18 +39,6 @@ spec:
|
|||||||
value: "false"
|
value: "false"
|
||||||
securityContext:
|
securityContext:
|
||||||
privileged: true
|
privileged: true
|
||||||
volumeMounts:
|
|
||||||
- name: dbus
|
|
||||||
mountPath: /var/run/dbus/system_bus_socket
|
|
||||||
- name: systemd
|
|
||||||
mountPath: /run/systemd/system
|
|
||||||
volumes:
|
|
||||||
- name: dbus
|
|
||||||
hostPath:
|
|
||||||
path: /var/run/dbus/system_bus_socket
|
|
||||||
- name: systemd
|
|
||||||
hostPath:
|
|
||||||
path: /run/systemd/system
|
|
||||||
updateStrategy:
|
updateStrategy:
|
||||||
rollingUpdate:
|
rollingUpdate:
|
||||||
maxUnavailable: 1
|
maxUnavailable: 1
|
||||||
|
@ -14,6 +14,7 @@ spec:
|
|||||||
name: kata-deploy
|
name: kata-deploy
|
||||||
spec:
|
spec:
|
||||||
serviceAccountName: kata-deploy-sa
|
serviceAccountName: kata-deploy-sa
|
||||||
|
hostPID: true
|
||||||
containers:
|
containers:
|
||||||
- name: kube-kata
|
- name: kube-kata
|
||||||
image: quay.io/kata-containers/kata-deploy:latest
|
image: quay.io/kata-containers/kata-deploy:latest
|
||||||
@ -47,10 +48,6 @@ spec:
|
|||||||
mountPath: /etc/containerd/
|
mountPath: /etc/containerd/
|
||||||
- name: kata-artifacts
|
- name: kata-artifacts
|
||||||
mountPath: /opt/kata/
|
mountPath: /opt/kata/
|
||||||
- name: dbus
|
|
||||||
mountPath: /var/run/dbus/system_bus_socket
|
|
||||||
- name: systemd
|
|
||||||
mountPath: /run/systemd/system
|
|
||||||
- name: local-bin
|
- name: local-bin
|
||||||
mountPath: /usr/local/bin/
|
mountPath: /usr/local/bin/
|
||||||
volumes:
|
volumes:
|
||||||
@ -64,12 +61,6 @@ spec:
|
|||||||
hostPath:
|
hostPath:
|
||||||
path: /opt/kata/
|
path: /opt/kata/
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
- name: dbus
|
|
||||||
hostPath:
|
|
||||||
path: /var/run/dbus/system_bus_socket
|
|
||||||
- name: systemd
|
|
||||||
hostPath:
|
|
||||||
path: /run/systemd/system
|
|
||||||
- name: local-bin
|
- name: local-bin
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /usr/local/bin/
|
path: /usr/local/bin/
|
||||||
|
@ -25,6 +25,10 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function host_systemctl() {
|
||||||
|
nsenter --target 1 --mount systemctl "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
function print_usage() {
|
function print_usage() {
|
||||||
echo "Usage: $0 [install/cleanup/reset]"
|
echo "Usage: $0 [install/cleanup/reset]"
|
||||||
}
|
}
|
||||||
@ -71,11 +75,11 @@ function get_container_runtime() {
|
|||||||
die "invalid node name"
|
die "invalid node name"
|
||||||
fi
|
fi
|
||||||
if echo "$runtime" | grep -qE 'containerd.*-k3s'; then
|
if echo "$runtime" | grep -qE 'containerd.*-k3s'; then
|
||||||
if systemctl is-active --quiet rke2-agent; then
|
if host_systemctl is-active --quiet rke2-agent; then
|
||||||
echo "rke2-agent"
|
echo "rke2-agent"
|
||||||
elif systemctl is-active --quiet rke2-server; then
|
elif host_systemctl is-active --quiet rke2-server; then
|
||||||
echo "rke2-server"
|
echo "rke2-server"
|
||||||
elif systemctl is-active --quiet k3s-agent; then
|
elif host_systemctl is-active --quiet k3s-agent; then
|
||||||
echo "k3s-agent"
|
echo "k3s-agent"
|
||||||
else
|
else
|
||||||
echo "k3s"
|
echo "k3s"
|
||||||
@ -136,8 +140,8 @@ function configure_cri_runtime() {
|
|||||||
configure_containerd
|
configure_containerd
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
systemctl daemon-reload
|
host_systemctl daemon-reload
|
||||||
systemctl restart "$1"
|
host_systemctl restart "$1"
|
||||||
|
|
||||||
wait_till_node_is_ready
|
wait_till_node_is_ready
|
||||||
}
|
}
|
||||||
@ -371,10 +375,10 @@ function cleanup_containerd() {
|
|||||||
|
|
||||||
function reset_runtime() {
|
function reset_runtime() {
|
||||||
kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime-
|
kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime-
|
||||||
systemctl daemon-reload
|
host_systemctl daemon-reload
|
||||||
systemctl restart "$1"
|
host_systemctl restart "$1"
|
||||||
if [ "$1" == "crio" ] || [ "$1" == "containerd" ]; then
|
if [ "$1" == "crio" ] || [ "$1" == "containerd" ]; then
|
||||||
systemctl restart kubelet
|
host_systemctl restart kubelet
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wait_till_node_is_ready
|
wait_till_node_is_ready
|
||||||
|
Loading…
Reference in New Issue
Block a user