Skip to content

Commit ba7a7a2

Browse files
Merge pull request #16303 from dcbw/dind-crio
Automatic merge from submit-queue (batch tested with PRs 16365, 16250, 14945, 16355, 16303) dind: add support for CRI-O runtime via "-c crio" start argument @danwinship @stevekuznetsov @openshift/networking @openshift/sig-networking @marun
2 parents 272279a + da03ccd commit ba7a7a2

11 files changed

+88
-23
lines changed

hack/dind-cluster.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,26 @@ function start() {
6767
local deployed_config_root=$4
6868
local cluster_id=$5
6969
local network_plugin=$6
70-
local wait_for_cluster=$7
71-
local node_count=$8
72-
local additional_args=$9
70+
local container_runtime=$7
71+
local wait_for_cluster=$8
72+
local node_count=$9
73+
local additional_args=${10}
7374

7475
# docker-in-docker's use of volumes is not compatible with SELinux
7576
check-selinux
7677

77-
echo "Starting dind cluster '${cluster_id}' with plugin '${network_plugin}'"
78+
runtime_endpoint=
79+
if [[ "${container_runtime}" = "dockershim" ]]; then
80+
# dockershim is default and doesn't need an endpoint path
81+
runtime_endpoint=
82+
elif [[ "${container_runtime}" = "crio" ]]; then
83+
runtime_endpoint="/var/run/crio.sock"
84+
else
85+
>&2 echo "Invalid container runtime: ${container_runtime}"
86+
exit 1
87+
fi
88+
89+
echo "Starting dind cluster '${cluster_id}' with plugin '${network_plugin}' and runtime '${container_runtime}'"
7890

7991
# Error if a cluster is already configured
8092
check-no-containers "start"
@@ -91,16 +103,19 @@ function start() {
91103

92104
# Initialize the cluster config path
93105
mkdir -p "${config_root}"
94-
echo "OPENSHIFT_NETWORK_PLUGIN=${network_plugin}" > "${config_root}/network-plugin"
95-
echo "OPENSHIFT_ADDITIONAL_ARGS='${additional_args}'" > "${config_root}/additional-args"
106+
echo "OPENSHIFT_NETWORK_PLUGIN=${network_plugin}" > "${config_root}/dind-env"
107+
echo "OPENSHIFT_ADDITIONAL_ARGS='${additional_args}'" >> "${config_root}/dind-env"
96108
copy-runtime "${origin_root}" "${config_root}/"
97109

110+
echo "OPENSHIFT_CONTAINER_RUNTIME=${container_runtime}" >> "${config_root}/dind-env"
111+
echo "OPENSHIFT_REMOTE_RUNTIME_ENDPOINT=${runtime_endpoint}" >> "${config_root}/dind-env"
112+
98113
ovn_kubernetes=
99114
if [[ -d "${ovn_root}" ]]; then
100115
copy-ovn-runtime "${ovn_root}" "${config_root}/"
101116
ovn_kubernetes=1
102117
fi
103-
echo "OPENSHIFT_OVN_KUBERNETES=${ovn_kubernetes}" > "${config_root}/ovn-kubernetes"
118+
echo "OPENSHIFT_OVN_KUBERNETES=${ovn_kubernetes}" >> "${config_root}/dind-env"
104119

105120
# Create containers
106121
start-container "${config_root}" "${deployed_config_root}" "${MASTER_IMAGE}" "${MASTER_NAME}"
@@ -603,6 +618,7 @@ MASTER_IMAGE="openshift/dind-master"
603618
ADDITIONAL_ARGS=""
604619

605620
OVN_ROOT="${OVN_ROOT:-}"
621+
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-dockershim}"
606622

607623
case "${1:-""}" in
608624
start)
@@ -612,7 +628,7 @@ case "${1:-""}" in
612628
NETWORK_PLUGIN=
613629
REMOVE_EXISTING_CLUSTER=
614630
OPTIND=2
615-
while getopts ":bin:rsN:" opt; do
631+
while getopts ":bc:in:rsN:" opt; do
616632
case $opt in
617633
b)
618634
BUILD=1
@@ -632,6 +648,9 @@ case "${1:-""}" in
632648
s)
633649
WAIT_FOR_CLUSTER=
634650
;;
651+
c)
652+
CONTAINER_RUNTIME="${OPTARG}"
653+
;;
635654
\?)
636655
echo "Invalid option: -${OPTARG}" >&2
637656
exit 1
@@ -680,8 +699,8 @@ case "${1:-""}" in
680699
fi
681700

682701
start "${OS_ROOT}" "${OVN_ROOT}" "${CONFIG_ROOT}" "${DEPLOYED_CONFIG_ROOT}" \
683-
"${CLUSTER_ID}" "${NETWORK_PLUGIN}" "${WAIT_FOR_CLUSTER}" \
684-
"${NODE_COUNT}" "${ADDITIONAL_ARGS}"
702+
"${CLUSTER_ID}" "${NETWORK_PLUGIN}" "${CONTAINER_RUNTIME}" \
703+
"${WAIT_FOR_CLUSTER}" "${NODE_COUNT}" "${ADDITIONAL_ARGS}"
685704
;;
686705
add-node)
687706
WAIT_FOR_CLUSTER=1
@@ -810,6 +829,7 @@ start accepts the following options:
810829
-n [net plugin] the name of the network plugin to deploy
811830
-N number of nodes in the cluster
812831
-b build origin before starting the cluster
832+
-c [runtime name] use the specified container runtime instead of dockershim (eg, "crio")
813833
-i build container images before starting the cluster
814834
-r remove an existing cluster
815835
-s skip waiting for nodes to become ready

images/dind/master/openshift-generate-master-config.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
# Should set OPENSHIFT_NETWORK_PLUGIN
8-
source /data/network-plugin
9-
source /data/additional-args
8+
source /data/dind-env
109

1110
function ensure-master-config() {
1211
local config_path="/data/openshift.local.config"

images/dind/master/ovn-kubernetes-master-setup.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
source /usr/local/bin/openshift-dind-lib.sh
8-
source /data/network-plugin
9-
source /data/ovn-kubernetes
8+
source /data/dind-env
109

1110
function is-api-running() {
1211
local config=$1

images/dind/master/ovn-kubernetes-master.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
source /usr/local/bin/openshift-dind-lib.sh
8-
source /data/network-plugin
9-
source /data/ovn-kubernetes
8+
source /data/dind-env
109

1110
function ovn-kubernetes-master() {
1211
local config_dir=$1

images/dind/node/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ RUN dnf -y update && dnf -y install\
2525
python-netaddr\
2626
python2-pyroute2\
2727
python2-requests\
28-
PyYAML
28+
PyYAML\
29+
cri-o
30+
31+
# Remove the CRI-O CNI network configs so openshift-sdn's will be used instead
32+
RUN rm -f /etc/cni/net.d/*
2933

3034
# Upgrade to a newer OVS and install OVN packages that are only available
3135
# with the newer release. (This can go away when the base image is upgraded to
@@ -90,3 +94,7 @@ RUN systemctl enable ovn-kubernetes-node-setup.service
9094
COPY ovn-kubernetes-node.service /etc/systemd/system/
9195
COPY ovn-kubernetes-node.sh /usr/local/bin/
9296
RUN systemctl enable ovn-kubernetes-node.service
97+
98+
COPY crio-node.sh /usr/local/bin/
99+
COPY crio-node.service /etc/systemd/system/
100+
RUN systemctl enable crio-node.service

images/dind/node/crio-node.service

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Setup for CRI-O node
3+
Before=openshift-node.service
4+
5+
[Service]
6+
Type=simple
7+
ExecStart=/usr/local/bin/crio-node.sh
8+
9+
[Install]
10+
WantedBy=openshift-node.service
11+

images/dind/node/crio-node.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
source /usr/local/bin/openshift-dind-lib.sh
8+
source /data/dind-env
9+
10+
if [[ "${OPENSHIFT_CONTAINER_RUNTIME}" = "crio" ]]; then
11+
systemctl enable crio
12+
systemctl start crio
13+
fi

images/dind/node/openshift-generate-node-config.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -o pipefail
66

77
source /usr/local/bin/openshift-dind-lib.sh
88
# Should set OPENSHIFT_NETWORK_PLUGIN
9-
source /data/network-plugin
9+
source /data/dind-env
1010

1111
function ensure-node-config() {
1212
local deployed_config_path="/var/lib/origin/openshift.local.config/node"
@@ -64,6 +64,15 @@ kubeletArguments:
6464
cgroups-per-qos: ["false"]
6565
enforce-node-allocatable: [""]
6666
EOF
67+
68+
if [[ "${OPENSHIFT_CONTAINER_RUNTIME}" != "dockershim" ]]; then
69+
cat >> "${node_config_file}" <<EOF
70+
container-runtime: ["remote"]
71+
container-runtime-endpoint: ["${OPENSHIFT_REMOTE_RUNTIME_ENDPOINT}"]
72+
image-service-endpoint: ["${OPENSHIFT_REMOTE_RUNTIME_ENDPOINT}"]
73+
EOF
74+
fi
75+
6776
fi
6877

6978
# Ensure the configuration is readable outside of the container

images/dind/node/ovn-kubernetes-node-setup.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
source /usr/local/bin/openshift-dind-lib.sh
8-
source /data/network-plugin
9-
source /data/ovn-kubernetes
8+
source /data/dind-env
109

1110
function is-api-running() {
1211
local config=$1

images/dind/node/ovn-kubernetes-node.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
source /usr/local/bin/openshift-dind-lib.sh
8-
source /data/network-plugin
9-
source /data/ovn-kubernetes
8+
source /data/dind-env
109

1110
function is-northd-running() {
1211
local northd_ip=$1

0 commit comments

Comments
 (0)