Skip to content

Commit

Permalink
add cri-dockerd init.d in wsl and lima
Browse files Browse the repository at this point in the history
Signed-off-by: Nino Kodabande <nkodabande@suse.com>
  • Loading branch information
Nino-K committed Mar 10, 2022
1 parent 7f52a0f commit 0d241de
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/assets/scripts/cri-dockerd.initd
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

# shellcheck shell=ksh

name="Cri-Dockerd"
name="cri-dockerd"
description="Rancher Desktop Shim for Docker Engine"


supervisor=supervise-daemon
command=/usr/bin/cri-dockerd"
# "%t" Runtime directory root This is either /run/ (for the system manager) or the path "$XDG_RUNTIME_DIR" resolves to (for user managers).
command_args="--container-runtime-endpoint %t/cri-dockerd.sock --network-plugin="
command_args="--container-runtime-endpoint /run/cri-dockerd.sock --network-plugin="
CRI_DOCKERD_LOGFILE="${CRI_DOCKERD_LOGFILE:-${LOG_DIR:-/var/log}/${RC_SVCNAME}.log}"
output_log="'${CRI_DOCKERD_LOGFILE}'"
Expand Down
6 changes: 3 additions & 3 deletions src/assets/scripts/service-k3s.initd
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ fi
ENGINE="${ENGINE:-containerd}"

depend() {
after network-online
want cgroups
if [ "${ENGINE}" == "moby" ]; then
after cri-dockerd
need cri-dockerd
fi
after network-online
want cgroups
}

start_pre() {
Expand Down
6 changes: 6 additions & 0 deletions src/k8s-engine/lima.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import DEFAULT_CONFIG from '@/assets/lima-config.yaml';
import NETWORKS_CONFIG from '@/assets/networks-config.yaml';
import FLANNEL_CONFLIST from '@/assets/scripts/10-flannel.conflist';
import CONTAINERD_CONFIG from '@/assets/scripts/k3s-containerd-config.toml';
import SERVICE_CRI_DOCKERD_SCRIPT from '@/assets/scripts/service-cri-dockerd.initd';
import INSTALL_K3S_SCRIPT from '@/assets/scripts/install-k3s';
import SERVICE_K3S_SCRIPT from '@/assets/scripts/service-k3s.initd';
import LOGROTATE_K3S_SCRIPT from '@/assets/scripts/logrotate-k3s';
Expand Down Expand Up @@ -1214,6 +1215,11 @@ export default class LimaBackend extends events.EventEmitter implements K8s.Kube
if (!this.cfg?.options.traefik) {
config.ADDITIONAL_ARGS += ' --disable traefik';
}
await this.writeFile('/etc/init.d/cri-dockerd', SERVICE_CRI_DOCKERD_SCRIPT, 0o755);
await this.writeConf('cri-dockerd', {
LOG_DIR: paths.logs,
ENGINE: this.#currentContainerEngine,
});
await this.writeFile('/etc/init.d/k3s', SERVICE_K3S_SCRIPT, 0o755);
await this.writeConf('k3s', config);
await this.writeFile('/etc/logrotate.d/k3s', LOGROTATE_K3S_SCRIPT);
Expand Down
6 changes: 6 additions & 0 deletions src/k8s-engine/wsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ProgressTracker from './progressTracker';
import FLANNEL_CONFLIST from '@/assets/scripts/10-flannel.conflist';
import CONTAINERD_CONFIG from '@/assets/scripts/k3s-containerd-config.toml';
import INSTALL_K3S_SCRIPT from '@/assets/scripts/install-k3s';
import SERVICE_SCRIPT_CRI_DOCKERD from '@/assets/scripts/service-cri-dockerd.initd';
import SERVICE_SCRIPT_K3S from '@/assets/scripts/service-k3s.initd';
import SERVICE_SCRIPT_DOCKERD from '@/assets/scripts/service-wsl-dockerd.initd';
import LOGROTATE_K3S_SCRIPT from '@/assets/scripts/logrotate-k3s';
Expand Down Expand Up @@ -1212,6 +1213,11 @@ export default class WSLBackend extends events.EventEmitter implements K8s.Kuber
const rotateConf = LOGROTATE_K3S_SCRIPT.replace(/\r/g, '')
.replace('/var/log', logPath);

await this.writeFile('/etc/init.d/cri-dockerd', SERVICE_SCRIPT_CRI_DOCKERD, { permissions: 0o755 });
await this.writeConf('cri-dockerd', {
ENGINE: this.#currentContainerEngine,
LOG_DIR: logPath,
});
await this.writeFile('/etc/init.d/k3s', SERVICE_SCRIPT_K3S, { permissions: 0o755 });
await this.writeFile('/etc/logrotate.d/k3s', rotateConf);
await this.execCommand('mkdir', '-p', '/etc/cni/net.d');
Expand Down

0 comments on commit 0d241de

Please sign in to comment.