Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier beyler committed Mar 12, 2020
1 parent 272b357 commit aa130a6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
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
14 changes: 12 additions & 2 deletions jobs/kubelet/templates/bin/post-start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@

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

DOCKER_SOCKET=unix:///var/vcap/sys/run/docker/docker.sock

if p('container-runtime').downcase == "docker"
DOCKER_SOCKET=unix:///var/vcap/sys/run/docker/docker.sock
else if p('container-runtime').downcase == "containerd"
DOCKER_SOCKET=unix:///var/vcap/sys/run/containerd/containerd.sock
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').downcase == "containerd"
result = sudo ctr -n=k8s.io --address=/var/vcap/sys/run/containerd/containerd.sock images import "${path};
if p('container-runtime').downcase == "docker"
result = sudo /var/vcap/jobs/kubelet/packages/docker/bin/docker -H ${DOCKER_SOCKET} load < "${path}";
if $result then
echo "successfully loaded container: ${path}"
else
echo "failed to load container: ${path}"
Expand Down
12 changes: 12 additions & 0 deletions jobs/kubelet/templates/monit.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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").eq? "docker"
depends on docker
%>
<%= if p("container-runtime").eq? "containerd"
depends on containerd
%>

0 comments on commit aa130a6

Please sign in to comment.