@@ -10,17 +10,21 @@ set -x
10
10
set -o errexit # TODO: replace with explicit error checking and error messages.
11
11
set -o pipefail
12
12
13
+ : ${INIT_KUBERNETES:= true}
13
14
HOSTNAME=${HOSTNAME:- $1 }
14
15
IPADDR=${IPADDR:- 127.0.0.1}
15
- BUNDLES=" cloud-native-basic containers-basic ${TEST_CLEAR_LINUX_BUNDLES} "
16
+ BUNDLES=" ${TEST_CLEAR_LINUX_BUNDLES} "
17
+ if ${INIT_KUBERNETES} ; then
18
+ BUNDLES=" ${BUNDLES} cloud-native-basic containers-basic"
19
+ fi
16
20
17
21
function error_handler(){
18
22
local line=" ${1} "
19
23
echo >&2 " ERROR: the command '${BASH_COMMAND} ' at $0 :${line} failed"
20
24
}
25
+ trap ' error_handler ${LINENO}' ERR
21
26
22
- function install_kubernetes(){
23
- trap ' error_handler ${LINENO}' ERR
27
+ function install_bundles(){
24
28
# Setup clearlinux environment
25
29
# Disable swupd autoupdate service
26
30
swupd autoupdate --disable
@@ -54,100 +58,102 @@ EOF
54
58
fi
55
59
swapoff -a
56
60
57
- # We put config changes in place for both runtimes, even though only one of them will
58
- # be used by Kubernetes, just in case that someone wants to use them manually.
61
+ if ${INIT_KUBERNETES} ; then
62
+ # We put config changes in place for both runtimes, even though only one of them will
63
+ # be used by Kubernetes, just in case that someone wants to use them manually.
59
64
60
- # Proxy settings for CRI-O.
61
- mkdir /etc/systemd/system/crio.service.d
62
- cat > /etc/systemd/system/crio.service.d/proxy.conf << EOF
65
+ # Proxy settings for CRI-O.
66
+ mkdir /etc/systemd/system/crio.service.d
67
+ cat > /etc/systemd/system/crio.service.d/proxy.conf << EOF
63
68
[Service]
64
69
Environment="HTTP_PROXY=${HTTP_PROXY} " "HTTPS_PROXY=${HTTPS_PROXY} " "NO_PROXY=${NO_PROXY} "
65
70
EOF
66
71
67
- # Testing may involve a Docker registry running on the build host (see
68
- # TEST_LOCAL_REGISTRY and TEST_PMEM_REGISTRY). We need to trust that
69
- # registry, otherwise CRI-O will fail to pull images from it.
72
+ # Testing may involve a Docker registry running on the build host (see
73
+ # TEST_LOCAL_REGISTRY and TEST_PMEM_REGISTRY). We need to trust that
74
+ # registry, otherwise CRI-O will fail to pull images from it.
70
75
71
- mkdir -p /etc/containers
72
- cat > /etc/containers/registries.conf << EOF
76
+ mkdir -p /etc/containers
77
+ cat > /etc/containers/registries.conf << EOF
73
78
[registries.insecure]
74
79
registries = [ $( echo $INSECURE_REGISTRIES | sed ' s|^|"|g;s| |", "|g;s|$|"|' ) ]
75
80
EOF
76
81
77
- # The same for Docker.
78
- mkdir -p /etc/docker
79
- cat > /etc/docker/daemon.json << EOF
82
+ # The same for Docker.
83
+ mkdir -p /etc/docker
84
+ cat > /etc/docker/daemon.json << EOF
80
85
{ "insecure-registries": [ $( echo $INSECURE_REGISTRIES | sed ' s|^|"|g;s| |", "|g;s|$|"|' ) ] }
81
86
EOF
82
87
83
- # Proxy settings for Docker.
84
- mkdir -p /etc/systemd/system/docker.service.d/
85
- cat > /etc/systemd/system/docker.service.d/proxy.conf << EOF
88
+ # Proxy settings for Docker.
89
+ mkdir -p /etc/systemd/system/docker.service.d/
90
+ cat > /etc/systemd/system/docker.service.d/proxy.conf << EOF
86
91
[Service]
87
92
Environment="HTTP_PROXY=$HTTP_PROXY " "HTTPS_PROXY=$HTTPS_PROXY " "NO_PROXY=$NO_PROXY "
88
93
EOF
89
94
90
- # Disable the use of Kata containers as default runtime in Docker.
91
- # The Kubernetes control plan (apiserver, etc.) fails to run otherwise
92
- # ("Host networking requested, not supported by runtime").
95
+ # Disable the use of Kata containers as default runtime in Docker.
96
+ # The Kubernetes control plan (apiserver, etc.) fails to run otherwise
97
+ # ("Host networking requested, not supported by runtime").
93
98
94
- cat > /etc/systemd/system/docker.service.d/51-runtime.conf << EOF
99
+ cat > /etc/systemd/system/docker.service.d/51-runtime.conf << EOF
95
100
[Service]
96
101
Environment="DOCKER_DEFAULT_RUNTIME=--default-runtime runc"
97
102
EOF
98
- mkdir -p /etc/systemd/system/kubelet.service.d/
99
- case $TEST_CRI in
100
- docker)
101
- cri_daemon=docker
102
- # Choose Docker by disabling the use of CRI-O in KUBELET_EXTRA_ARGS.
103
- cat > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf << EOF
103
+
104
+ mkdir -p /etc/systemd/system/kubelet.service.d/
105
+ case $TEST_CRI in
106
+ docker)
107
+ cri_daemon=docker
108
+ # Choose Docker by disabling the use of CRI-O in KUBELET_EXTRA_ARGS.
109
+ cat > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf << EOF
104
110
[Service]
105
111
Environment="KUBELET_EXTRA_ARGS="
106
112
EOF
107
- ;;
108
- crio)
109
- cri_daemon=cri-o
110
- ;;
111
- * )
112
- echo " ERROR: unsupported TEST_CRI=$TEST_CRI "
113
- exit 1
114
- ;;
115
- esac
116
-
117
- # kubelet must start after the container runtime that it depends on.
118
- # This is not currently configured in Clear Linux (https://github.com/clearlinux/distribution/issues/1004).
119
- cat > /etc/systemd/system/kubelet.service.d/10-cri.conf << EOF
113
+ ;;
114
+ crio)
115
+ cri_daemon=cri-o
116
+ ;;
117
+ * )
118
+ echo " ERROR: unsupported TEST_CRI=$TEST_CRI "
119
+ exit 1
120
+ ;;
121
+ esac
122
+
123
+ # kubelet must start after the container runtime that it depends on.
124
+ # This is not currently configured in Clear Linux (https://github.com/clearlinux/distribution/issues/1004).
125
+ cat > /etc/systemd/system/kubelet.service.d/10-cri.conf << EOF
120
126
[Unit]
121
127
After=$cri_daemon .service
122
128
EOF
123
-
124
- # flannel + CRI-O + Kata Containers needs a crio.conf change (https://clearlinux.org/documentation/clear-linux/tutorials/kubernetes) :
125
- # If you are using CRI-O and flannel and you want to use Kata Containers, edit the /etc/ crio/crio.conf file to add:
126
- # [crio.runtime]
127
- # manage_network_ns_lifecycle = true
128
- #
129
- # We don't use Kata Containers, so that particular change is not made to /etc/crio/crio.conf
130
- # at this time.
131
-
132
- # /opt/cni/bin is where runtimes like CRI-O expect CNI plugins. But cloud-native-basic installs into
133
- # /usr/libexec/cni. Instructions at https://clearlinux.org/documentation /clear-linux/tutorials/kubernetes#id2
134
- # are inconsistent at this time (https://github.com/clearlinux/clear-linux-documentation/issues/388).
135
- #
136
- # We solve this by creating the directory and symlinking all existing CNI plugins into it.
137
- mkdir -p /opt/ cni/bin
138
- for i in /usr/libexec/ cni/* ; do
139
- ln -s $i /opt/cni/bin/
140
- done
141
-
142
- # Reconfiguration done, start daemons. Starting kubelet must wait until kubeadm has created
143
- # the necessary config files.
144
- systemctl daemon-reload
145
- systemctl restart $cri_daemon || (
146
- systemctl status $cri_daemon || true
147
- journalctl -xe || true
148
- false
149
- )
150
- systemctl enable $cri_daemon kubelet
129
+ # flannel + CRI-O + Kata Containers needs a crio.conf change (https://clearlinux.org/documentation/clear-linux/tutorials/kubernetes):
130
+ # If you are using CRI-O and flannel and you want to use Kata Containers, edit the /etc/ crio/crio .conf file to add :
131
+ # [ crio.runtime]
132
+ # manage_network_ns_lifecycle = true
133
+ #
134
+ # We don't use Kata Containers, so that particular change is not made to /etc/crio/crio.conf
135
+ # at this time.
136
+
137
+ # /opt/cni/bin is where runtimes like CRI-O expect CNI plugins. But cloud-native-basic installs into
138
+ # /usr/libexec/cni. Instructions at https://clearlinux.org/documentation/clear-linux/tutorials/kubernetes#id2
139
+ # are inconsistent at this time ( https://github.com/clearlinux /clear-linux-documentation/issues/388).
140
+ #
141
+ # We solve this by creating the directory and symlinking all existing CNI plugins into it.
142
+ mkdir -p /opt/cni/bin
143
+ for i in /usr/libexec/ cni/* ; do
144
+ ln -s $i /opt/ cni/bin/
145
+ done
146
+
147
+ # Reconfiguration done, start daemons. Starting kubelet must wait until kubeadm has created
148
+ # the necessary config files.
149
+ systemctl daemon-reload
150
+ systemctl restart $cri_daemon || (
151
+ systemctl status $cri_daemon || true
152
+ journalctl -xe || true
153
+ false
154
+ )
155
+ systemctl enable $cri_daemon kubelet
156
+ fi
151
157
}
152
158
153
- install_kubernetes
159
+ install_bundles
0 commit comments