Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Feature containerd option #383

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jobs/kubelet/spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ templates:
config/kubeletconfig.yml.erb: config/kubeletconfig.yml
config/openstack-ca.crt.erb: config/openstack-ca.crt
config/service_key.json.erb: config/service_key.json
monit.erb: monit

packages:
- pid_utils
- kubernetes
Expand All @@ -24,6 +26,10 @@ properties:
description: The token to access Kubernetes API
cloud-provider:
description: "The type of cloud-provider that is being deployed"
container-runtime:
description: "The container runtime job can be containerd or docker"
default: docker

drain-api-token:
description: The token to access Kubernetes API used to drain the kubelet.
http_proxy:
Expand Down Expand Up @@ -54,6 +60,7 @@ properties:
kubelet-drain-force-node:
description: "Forcibly terminate pods if all the pods fail to drain before the timeout."
default: false

k8s-args:
description: "Pass-through options for Kubernetes runtime arguments. See docs https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/ for reference."
example: |
Expand Down
1 change: 1 addition & 0 deletions jobs/kubelet/templates/bin/kubelet_ctl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
NAME="${0##*/}"

export PATH=/var/vcap/packages/kubernetes/bin/:/var/vcap/packages/docker/sbin/:/var/vcap/packages/socat/bin/:$PATH
export PATH=$PATH:/var/vcap/packages/containerd/bin

RUN_DIR=/var/vcap/sys/run/kubernetes
PIDFILE=$RUN_DIR/kubelet.pid
Expand Down
21 changes: 19 additions & 2 deletions jobs/kubelet/templates/bin/post-start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
[ -z "$DEBUG" ] || set -x

kubectl="/var/vcap/packages/kubernetes/bin/kubectl --kubeconfig=/var/vcap/jobs/kubelet/config/kubeconfig"

<% if p("container-runtime").eql? "docker" %>
DOCKER_SOCKET=unix:///var/vcap/sys/run/docker/docker.sock
<% else if p("container-runtime").eql? "containerd" %>
DOCKER_SOCKET=unix:///var/vcap/sys/run/containerd/containerd.sock
<% end %>
<% end %>

CONTAINER_IMAGE_DIR=/var/vcap/packages/kubernetes/container-images

load_container() {
path=$1

echo "loading cached container: ${path}"
if sudo /var/vcap/jobs/kubelet/packages/docker/bin/docker -H ${DOCKER_SOCKET} load < "${path}"; then
<% if p("container-runtime").eql? "containerd" %>
sudo /var/vcap/packages/containerd/bin/ctr -n=k8s.io --address=/var/vcap/sys/run/containerd/containerd.sock images import "${path}";
<% else if p("container-runtime").eql? "docker" %>
sudo /var/vcap/jobs/kubelet/packages/docker/bin/docker -H ${DOCKER_SOCKET} load < "${path}";
<% end %>
<% end %>
result=$?
if [ ${result} ]; then
echo "successfully loaded container: ${path}"
else
echo "failed to load container: ${path}"
Expand All @@ -22,6 +34,11 @@ load_container() {

load_cached_containers() {
for img in ${CONTAINER_IMAGE_DIR}/*.tgz; do
<% if p("container-runtime").eql? "containerd" %>
gunzip -k -f ${img}
done
for img in ${CONTAINER_IMAGE_DIR}/*.tar; do
<% end %>
load_container ${img}
done
}
Expand Down
13 changes: 13 additions & 0 deletions jobs/kubelet/templates/monit.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
check process kubelet
with pidfile /var/vcap/sys/run/kubernetes/kubelet.pid
start program "/var/vcap/jobs/kubelet/bin/kubelet_ctl start"
stop program "/var/vcap/jobs/kubelet/bin/kubelet_ctl stop"
group vcap
<% if p("container-runtime").eql? "docker" %>
depends on docker
<% else %>
<% if p("container-runtime").eql? "containerd" %>
depends on containerd
<% end %>
<% end %>