Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds cri-dockerd initd service #1766

Merged
merged 7 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/download/lima.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const limaRepo = 'https://github.com/rancher-sandbox/lima-and-qemu';
const limaTag = 'v1.21';

const alpineLimaRepo = 'https://github.com/lima-vm/alpine-lima';
const alpineLimaTag = 'v0.2.8';
const alpineLimaTag = 'v0.2.9';
const alpineLimaEdition = 'rd';
const alpineLimaVersion = '3.14.3';

Expand Down
2 changes: 1 addition & 1 deletion scripts/download/wsl.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import path from 'path';
import { download } from '../lib/download.mjs';

export default async function main() {
const v = '0.19';
const v = '0.20';

await download(
`https://github.com/rancher-sandbox/rancher-desktop-wsl-distro/releases/download/v${ v }/distro-${ v }.tar`,
Expand Down
21 changes: 21 additions & 0 deletions src/assets/scripts/service-cri-dockerd.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/sbin/openrc-run

# This script is used to manage cri-dockerd via OpenRC.

# shellcheck shell=ksh

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


supervisor=supervise-daemon
command=/usr/local/bin/cri-dockerd
command_args="--container-runtime-endpoint unix:///run/cri-dockerd.sock"

CRI_DOCKERD_LOGFILE="${CRI_DOCKERD_LOGFILE:-${LOG_DIR:-/var/log}/${RC_SVCNAME}.log}"
output_log="'${CRI_DOCKERD_LOGFILE}'"
error_log="'${CRI_DOCKERD_LOGFILE}'"

depend() {
need docker
}
5 changes: 4 additions & 1 deletion src/assets/scripts/service-k3s.initd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ fi
ENGINE="${ENGINE:-containerd}"

depend() {
if [ "${ENGINE}" == "moby" ]; then
Nino-K marked this conversation as resolved.
Show resolved Hide resolved
need cri-dockerd
fi
after network-online
want cgroups
}
Expand All @@ -46,7 +49,7 @@ name=k3s
command=/usr/local/bin/k3s
command_args="server --https-listen-port ${PORT} ${ADDITIONAL_ARGS:-}"
if [ "${ENGINE}" == "moby" ]; then
command_args="${command_args} --docker"
command_args="${command_args} --container-runtime-endpoint /run/cri-dockerd.sock"
elif [ "${ENGINE}" == "containerd" ]; then
command_args="${command_args} --container-runtime-endpoint /run/k3s/containerd/containerd.sock"
fi
Expand Down
8 changes: 7 additions & 1 deletion 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 @@ -153,7 +154,7 @@ interface SPNetworkDataType {
const console = Logging.lima;
const DEFAULT_DOCKER_SOCK_LOCATION = '/var/run/docker.sock';
const MACHINE_NAME = '0';
const IMAGE_VERSION = '0.2.8';
const IMAGE_VERSION = '0.2.9';
const ALPINE_EDITION = 'rd';
const ALPINE_VERSION = '3.14.3';

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
8 changes: 7 additions & 1 deletion 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 @@ -63,7 +64,7 @@ const DISTRO_BLACKLIST = [
];

/** The version of the WSL distro we expect. */
const DISTRO_VERSION = '0.19';
const DISTRO_VERSION = '0.20';

/**
* The list of directories that are in the data distribution (persisted across
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