github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/pkg/filesystem/rootfs/containerd/scripts/init.sh (about)

     1  #!/bin/bash
     2  # Copyright © 2021 Alibaba Group Holding Ltd.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -e
    17  set -x
    18  
    19  #STORAGE=${1:-/var/lib/docker} compatible docker
    20  REGISTRY_DOMAIN=${2-sea.hub}
    21  REGISTRY_PORT=${3-5000}
    22  
    23  # Install containerd
    24  chmod a+x containerd.sh
    25  sh containerd.sh "$REGISTRY_DOMAIN" "$REGISTRY_PORT"
    26  
    27  # Modify kubelet conf
    28  mkdir -p /etc/systemd/system/kubelet.service.d
    29  
    30  if grep "SystemdCgroup = true" /etc/containerd/config.toml &>/dev/null; then
    31    driver=systemd
    32  else
    33    driver=cgroupfs
    34  fi
    35  
    36  cat >/etc/systemd/system/kubelet.service.d/containerd.conf <<eof
    37  [Service]
    38  Environment="KUBELET_EXTRA_ARGS=--container-runtime=remote --cgroup-driver=${driver} --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock --image-service-endpoint=unix:///run/containerd/containerd.sock"
    39  eof
    40  
    41  chmod a+x init-kube.sh
    42  sh init-kube.sh