Skip to content

Commit 9cacaac

Browse files
committed
feat(workflow): support multi runtime
1 parent 0ffc834 commit 9cacaac

3 files changed

Lines changed: 100 additions & 43 deletions

File tree

_scripts/install.sh

Lines changed: 97 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ init_registry() {
3939
function clean_before_exit {
4040
# delay before exiting, so stdout/stderr flushes through the logging system
4141
rm -rf /tmp/drycc-values.yaml
42-
configure_registries runtime
42+
configure_containerd runtime
4343
sleep 3
4444
}
4545
trap clean_before_exit EXIT
@@ -88,55 +88,88 @@ function configure_os {
8888
}
8989

9090
function configure_registries {
91-
mkdir -p /etc/rancher/k3s
92-
if [[ -f "${REGISTRIES_FILE}" ]]; then
93-
cat "${REGISTRIES_FILE}" > /etc/rancher/k3s/registries.yaml
94-
elif [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]]; then
91+
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]]; then
9592
if [[ "$1" == "runtime" ]] ; then
96-
cat << EOF > "/etc/rancher/k3s/registries.yaml"
97-
configs:
98-
"registry.drycc.cc":
99-
auth:
100-
username: anonymous
101-
password: anonymous
102-
mirrors:
103-
"docker.io":
104-
endpoint:
105-
- "https://hub-mirror.c.163.com"
106-
- "https://registry-1.docker.io"
93+
cat << EOF >> "/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl"
94+
[plugins.cri.registry.mirrors]
95+
[plugins.cri.registry.mirrors."docker.io"]
96+
endpoint = ["https://docker-mirror.drycc.cc", "https://registry-1.docker.io"]
10797
EOF
10898
else
109-
cat << EOF > "/etc/rancher/k3s/registries.yaml"
110-
configs:
111-
"registry.drycc.cc":
112-
auth:
113-
username: anonymous
114-
password: anonymous
115-
mirrors:
116-
"docker.io":
117-
endpoint:
118-
- "https://docker-mirror.drycc.cc"
119-
- "https://registry-1.docker.io"
120-
"quay.io":
121-
endpoint:
122-
- "https://quay-mirror.drycc.cc"
123-
- "https://quay.io"
124-
"gcr.io":
125-
endpoint:
126-
- "https://gcr-mirror.drycc.cc"
127-
- "https://gcr.io"
128-
"k8s.gcr.io":
129-
endpoint:
130-
- "https://k8s-mirror.drycc.cc"
131-
- "https://k8s.gcr.io"
99+
cat << EOF >> "/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl"
100+
[plugins.cri.registry.mirrors]
101+
[plugins.cri.registry.mirrors."docker.io"]
102+
endpoint = ["https://docker-mirror.drycc.cc", "https://registry-1.docker.io"]
103+
[plugins.cri.registry.mirrors."quay.io"]
104+
endpoint = ["https://quay-mirror.drycc.cc", "https://quay.io"]
105+
[plugins.cri.registry.mirrors."gcr.io"]
106+
endpoint = ["https://quay-mirror.drycc.cc", "https://gcr.io"]
107+
[plugins.cri.registry.mirrors."k8s.gcr.io"]
108+
endpoint = ["https://k8s-mirror.drycc.cc", "https://k8s.gcr.io"]
132109
EOF
133110
fi
134111
fi
135112
}
136113

114+
function download_runtime {
115+
# download crun
116+
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]] ; then
117+
crun_base_url="https://github.com/containers"
118+
else
119+
crun_base_url="https://github.com/containers"
120+
fi
121+
crun_version=$(curl -Ls ${crun_base_url}/crun/releases|grep /containers/crun/releases/tag/ | sed -E 's/.*\/containers\/crun\/releases\/tag\/([0-9\.]{1,}(-rc.[0-9]{1,})?)".*/\1/g' | head -1)
122+
crun_download_url=${crun_base_url}/crun/releases/download/${crun_version}/crun-${crun_version}-linux-${ARCH}
123+
curl -sfL "${crun_download_url}" -o /usr/local/bin/crun
124+
chmod a+rx /usr/local/bin/crun
125+
126+
# download runsc
127+
gvisor_download_url=https://storage.googleapis.com/gvisor/releases/release/latest/$(uname -m)
128+
curl -sfL "${gvisor_download_url}/runsc" -o /usr/local/bin/runsc
129+
curl -sfL "${gvisor_download_url}/containerd-shim-runsc-v1" -o /usr/local/bin/containerd-shim-runsc-v1
130+
chmod a+rx /usr/local/bin/runsc /usr/local/bin/containerd-shim-runsc-v1
131+
}
132+
133+
function configure_runtime {
134+
cat << EOF > "/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl"
135+
[plugins.cri.containerd]
136+
snapshotter = "overlayfs"
137+
default_runtime_name = "crun"
138+
disable_snapshot_annotations = true
139+
140+
[plugins.cri.containerd.runtimes.crun]
141+
runtime_type = "io.containerd.runc.v2"
142+
143+
[plugins.cri.containerd.runtimes.crun.options]
144+
SystemdCgroup = true
145+
146+
[plugins.cri.containerd.runtimes.runc]
147+
runtime_type = "io.containerd.runc.v2"
148+
149+
[plugins.cri.containerd.runtimes.runc.options]
150+
SystemdCgroup = true
151+
152+
[plugins.cri.containerd.runtimes.runsc]
153+
runtime_type = "io.containerd.runsc.v1"
154+
155+
[plugins.cri.containerd.runtimes.runsc.options]
156+
SystemdCgroup = true
157+
EOF
158+
}
159+
160+
function configure_containerd {
161+
mkdir -p /var/lib/rancher/k3s/agent/etc/containerd
162+
if [[ -f "${CONTAINERD_FILE}" ]]; then
163+
cat "${CONTAINERD_FILE}" > /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl
164+
else
165+
configure_runtime
166+
configure_registries $1
167+
fi
168+
}
169+
137170
function configure_mirrors {
138171
echo -e "\\033[32m---> Start configuring mirrors\\033[0m"
139-
configure_registries
172+
configure_containerd
140173
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]] ; then
141174
INSTALL_K3S_MIRROR="${INSTALL_DRYCC_MIRROR}"
142175
k3s_install_url="https://get-k3s.drycc.cc"
@@ -155,6 +188,7 @@ function configure_mirrors {
155188

156189
function install_k3s_server {
157190
configure_os
191+
download_runtime
158192
configure_mirrors
159193
INSTALL_K3S_EXEC="server ${INSTALL_K3S_EXEC} --flannel-backend=none --disable-network-policy --disable=traefik --disable=servicelb --disable-kube-proxy --cluster-cidr=10.233.0.0/16"
160194
if [[ -n "${K3S_DATA_DIR}" ]] ; then
@@ -164,6 +198,27 @@ function install_k3s_server {
164198
INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC --cluster-init"
165199
fi
166200
curl -sfL "${k3s_install_url}" |INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -s -
201+
kubectl apply -f - <<EOF
202+
---
203+
apiVersion: node.k8s.io/v1
204+
kind: RuntimeClass
205+
metadata:
206+
name: crun
207+
handler: crun
208+
---
209+
apiVersion: node.k8s.io/v1
210+
kind: RuntimeClass
211+
metadata:
212+
name: runc
213+
handler: runc
214+
---
215+
apiVersion: node.k8s.io/v1
216+
kind: RuntimeClass
217+
metadata:
218+
name: runsc
219+
handler: runsc
220+
---
221+
EOF
167222
}
168223

169224
function install_k3s_agent {
@@ -367,7 +422,8 @@ controller:
367422
apiReplicas: ${CONTROLLER_API_REPLICAS}
368423
celeryReplicas: ${CONTROLLER_CELERY_REPLICAS}
369424
webhookReplicas: ${CONTROLLER_WEBHOOK_REPLICAS}
370-
imageRegistry: ${DRYCC_REGISTRY}
425+
imageRegistry: ${DRYCC_REGISTRY}
426+
appRuntimeClass: ${CONTROLLER_APP_RUNTIME_CLASS:-""}
371427
appStorageClass: ${CONTROLLER_APP_STORAGE_CLASS:-"drycc-storage"}
372428
373429
redis:

_scripts/uninstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ if [[ -n "${LONGHORN_DATA_PATH}" ]] ; then
2121
fi
2222

2323
rm -rf /etc/rancher
24-
rm -rf /var/lib/longhorn
24+
rm -rf /usr/local/bin/*runsc* /usr/local/bin/crun
2525
rm -rf /usr/local/bin/helm ~/.config/helm

src/quickstart/install-workflow.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ DRYCC_ADMIN_USERNAME | Required item, specify drycc's admi
191191
DRYCC_ADMIN_PASSWORD | Required item, specify drycc's admin password
192192
CERT_MANAGER_ENABLED | Whether to use automatic certificate. It is `true` by default
193193
CHANNEL | By default, `stable` channel will be installed. You can also specify `testing`
194-
REGISTRIES_FILE | The `registers.yaml` file path used by drycc registry
194+
CONTAINERD_FILE | The `config.yaml` file path used by containerd
195195
KUBE_API_SERVER_ADDRESS | Set with the IP address of the loadbalancer that was in front of kube-apiserver, The default is the IP address of the current node
196196
KUBE_API_SERVER_PORT | Set with the PORT of the loadbalancer that was in front of kube-apiserver, which is `6443` by default
197197
METALLB_CONFIG_FILE | The metallb config file path, layer 2 network is used by default
@@ -200,6 +200,7 @@ BUILDER_REPLICAS | Number of builder replicas to deplo
200200
CONTROLLER_API_REPLICAS | Number of controller api replicas to deploy
201201
CONTROLLER_CELERY_REPLICAS | Number of controller celery replicas to deploy
202202
CONTROLLER_WEBHOOK_REPLICAS | Number of controller webhook replicas to deploy
203+
CONTROLLER_APP_RUNTIME_CLASS | RuntimeClass is a feature for selecting the container runtime configuration.
203204
CONTROLLER_APP_STORAGE_CLASS | StorageClass allocated by `drycc volumes`; default storageClass is used by default
204205
REDIS_REPLICAS | Number of redis replicas to deploy
205206
REDIS_PERSISTENCE_SIZE | The size of the persistence space allocated to `redis`, which is `5Gi` by default

0 commit comments

Comments
 (0)