Docker-in-docker can coexist with systemd when configured with the
native cgroup driver. This removes the primary difference between dind
and vagrant provisioning (different init system) and allows refactored
vagrant provisioning scripts to deploy to VMs or containers.
| ... | ... |
@@ -49,6 +49,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 49 | 49 |
"os" => "fedora", |
| 50 | 50 |
"dev_cluster" => false, |
| 51 | 51 |
"dind_dev_cluster" => ENV['OPENSHIFT_DIND_DEV_CLUSTER'] || false, |
| 52 |
+ "network_plugin" => ENV['OPENSHIFT_NETWORK_PLUGIN'] || ENV['OPENSHIFT_SDN'] || "", |
|
| 52 | 53 |
"insert_key" => true, |
| 53 | 54 |
"num_minions" => ENV['OPENSHIFT_NUM_MINIONS'] || 2, |
| 54 | 55 |
"rebuild_yum_cache" => false, |
| ... | ... |
@@ -136,13 +137,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 136 | 136 |
minion_ips = num_minion.times.collect { |n| minion_ip_base + "#{n+3}" }
|
| 137 | 137 |
minion_ips_str = minion_ips.join(",")
|
| 138 | 138 |
|
| 139 |
- fixup_net_udev = vagrant_openshift_config['fixup_net_udev'] |
|
| 139 |
+ fixup_net_udev = '' |
|
| 140 |
+ if vagrant_openshift_config['fixup_net_udev'] |
|
| 141 |
+ fixup_net_udev = '-f' |
|
| 142 |
+ end |
|
| 143 |
+ network_plugin = vagrant_openshift_config['network_plugin'] |
|
| 140 | 144 |
|
| 141 | 145 |
# OpenShift master |
| 142 | 146 |
config.vm.define "#{VM_NAME_PREFIX}master" do |config|
|
| 143 | 147 |
config.vm.box = kube_box[kube_os]["name"] |
| 144 | 148 |
config.vm.box_url = kube_box[kube_os]["box_url"] |
| 145 |
- config.vm.provision "shell", inline: "/vagrant/contrib/vagrant/provision-master.sh #{master_ip} #{num_minion} #{minion_ips_str} #{instance_prefix} #{fixup_net_udev} #{ENV['OPENSHIFT_SDN']}"
|
|
| 149 |
+ config.vm.provision "shell", inline: "/bin/bash -x /vagrant/contrib/vagrant/provision-master.sh #{master_ip} #{num_minion} #{minion_ips_str} #{instance_prefix} -n '#{network_plugin}' #{fixup_net_udev}"
|
|
| 146 | 150 |
config.vm.network "private_network", ip: "#{master_ip}"
|
| 147 | 151 |
config.vm.hostname = "openshift-master" |
| 148 | 152 |
config.vm.synced_folder ".", "/vagrant", type: vagrant_openshift_config['sync_folders_type'] |
| ... | ... |
@@ -155,7 +160,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 155 | 155 |
minion_ip = minion_ips[n] |
| 156 | 156 |
minion.vm.box = kube_box[kube_os]["name"] |
| 157 | 157 |
minion.vm.box_url = kube_box[kube_os]["box_url"] |
| 158 |
- minion.vm.provision "shell", inline: "/vagrant/contrib/vagrant/provision-minion.sh #{master_ip} #{num_minion} #{minion_ips_str} #{instance_prefix} #{minion_ip} #{minion_index} #{fixup_net_udev}"
|
|
| 158 |
+ minion.vm.provision "shell", inline: "/bin/bash -x /vagrant/contrib/vagrant/provision-node.sh #{master_ip} #{num_minion} #{minion_ips_str} #{instance_prefix} -n '#{network_plugin}' -i #{minion_index} #{fixup_net_udev}"
|
|
| 159 | 159 |
minion.vm.network "private_network", ip: "#{minion_ip}"
|
| 160 | 160 |
minion.vm.hostname = "openshift-minion-#{minion_index}"
|
| 161 | 161 |
config.vm.synced_folder ".", "/vagrant", type: vagrant_openshift_config['sync_folders_type'] |
| ... | ... |
@@ -1,47 +1,47 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
|
| 3 | 3 |
os::util::install-sdn() {
|
| 4 |
+ local default_target="/usr" |
|
| 5 |
+ |
|
| 4 | 6 |
local deployed_root=$1 |
| 5 |
- local target=$2 |
|
| 6 |
- target=${target:-/usr}
|
|
| 7 |
+ local target=${2:-${default_target}}
|
|
| 8 |
+ |
|
| 7 | 9 |
if [ ! -d ${target} ]; then
|
| 8 | 10 |
mkdir -p ${target}
|
| 9 | 11 |
fi |
| 10 |
- # Source scripts from an openshift-sdn repo if present to support |
|
| 11 |
- # openshift-sdn development. |
|
| 12 |
- local sdn_root="${deployed_root}/third-party/openshift-sdn"
|
|
| 13 |
- if [ -d "${sdn_root}" ]; then
|
|
| 14 |
- pushd "${sdn_root}" > /dev/null
|
|
| 15 |
- # TODO: Enable these commands once we have a separate binary for openshift-sdn |
|
| 16 |
- # make |
|
| 17 |
- # make "install-dev" |
|
| 18 |
- popd > /dev/null |
|
| 19 |
- else |
|
| 20 |
- local osdn_base_path="${deployed_root}/Godeps/_workspace/src/github.com/openshift/openshift-sdn"
|
|
| 21 |
- local osdn_controller_path="${osdn_base_path}/pkg/ovssubnet/controller"
|
|
| 22 |
- pushd "${osdn_controller_path}" > /dev/null
|
|
| 23 |
- # The subnet plugin is discovered via the kube network plugin path. |
|
| 24 |
- local kube_osdn_path="${target}/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet"
|
|
| 25 |
- mkdir -p "${kube_osdn_path}"
|
|
| 26 |
- mkdir -p "${target}/bin/"
|
|
| 27 |
- cp -f kube/bin/openshift-ovs-subnet "${kube_osdn_path}/"
|
|
| 28 |
- cp -f kube/bin/openshift-sdn-kube-subnet-setup.sh "${target}/bin/"
|
|
| 29 |
- |
|
| 30 |
- # The multitenant plugin only needs to be in PATH because the |
|
| 31 |
- # origin multitenant plugin knows how to discover it. |
|
| 32 |
- cp -f multitenant/bin/openshift-ovs-multitenant "${target}/bin/"
|
|
| 33 |
- cp -f multitenant/bin/openshift-sdn-multitenant-setup.sh "${target}/bin/"
|
|
| 34 |
- |
|
| 35 |
- # subnet and multitenant plugin setup writes docker network options |
|
| 36 |
- # to /run/openshift-sdn/docker-network, make this file to be exported |
|
| 37 |
- # as part of docker service start. |
|
| 38 |
- local system_docker_path="${target}/lib/systemd/system/docker.service.d/"
|
|
| 39 |
- mkdir -p "${system_docker_path}"
|
|
| 40 |
- cat <<EOF > "${system_docker_path}/docker-sdn-ovs.conf"
|
|
| 12 |
+ |
|
| 13 |
+ local osdn_base_path="${deployed_root}/Godeps/_workspace/src/github.com/openshift/openshift-sdn"
|
|
| 14 |
+ local osdn_controller_path="${osdn_base_path}/pkg/ovssubnet/controller"
|
|
| 15 |
+ local kube_osdn_path="${target}/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet"
|
|
| 16 |
+ mkdir -p "${kube_osdn_path}"
|
|
| 17 |
+ mkdir -p "${target}/bin/"
|
|
| 18 |
+ |
|
| 19 |
+ pushd "${osdn_controller_path}" > /dev/null
|
|
| 20 |
+ # The subnet plugin is discovered via the kube network plugin path. |
|
| 21 |
+ cp -f kube/bin/openshift-ovs-subnet "${kube_osdn_path}/"
|
|
| 22 |
+ cp -f kube/bin/openshift-sdn-kube-subnet-setup.sh "${target}/bin/"
|
|
| 23 |
+ |
|
| 24 |
+ # The multitenant plugin only needs to be in PATH because the |
|
| 25 |
+ # origin multitenant plugin knows how to discover it. |
|
| 26 |
+ cp -f multitenant/bin/openshift-ovs-multitenant "${target}/bin/"
|
|
| 27 |
+ cp -f multitenant/bin/openshift-sdn-multitenant-setup.sh "${target}/bin/"
|
|
| 28 |
+ popd > /dev/null |
|
| 29 |
+ |
|
| 30 |
+ # subnet and multitenant plugin setup writes docker network options |
|
| 31 |
+ # to /run/openshift-sdn/docker-network, make this file to be exported |
|
| 32 |
+ # as part of docker service start. |
|
| 33 |
+ local system_docker_path="${target}/lib/systemd/system/docker.service.d/"
|
|
| 34 |
+ mkdir -p "${system_docker_path}"
|
|
| 35 |
+ cat <<EOF > "${system_docker_path}/docker-sdn-ovs.conf"
|
|
| 41 | 36 |
[Service] |
| 42 | 37 |
EnvironmentFile=-/run/openshift-sdn/docker-network |
| 43 | 38 |
EOF |
| 44 |
- popd > /dev/null |
|
| 45 |
- fi |
|
| 46 | 39 |
|
| 40 |
+ # Assume a non-default target is an indication of deploying in an |
|
| 41 |
+ # environment where openvswitch is managed in a separate container |
|
| 42 |
+ # (e.g. atomic host). |
|
| 43 |
+ if [[ "${target}" = "${default_target}" ]]; then
|
|
| 44 |
+ systemctl enable openvswitch |
|
| 45 |
+ systemctl start openvswitch |
|
| 46 |
+ fi |
|
| 47 | 47 |
} |
| ... | ... |
@@ -12,11 +12,55 @@ ORIGIN_ROOT=$( |
| 12 | 12 |
) |
| 13 | 13 |
source ${ORIGIN_ROOT}/contrib/vagrant/provision-util.sh
|
| 14 | 14 |
|
| 15 |
-# Passed as arguments to provisioning from Vagrantfile |
|
| 15 |
+# Passed as arguments to provisioning script |
|
| 16 | 16 |
MASTER_IP=${1:-""}
|
| 17 |
-NUM_MINIONS=${2:-""}
|
|
| 18 |
-MINION_IPS=${3:-""}
|
|
| 17 |
+NODE_COUNT=${2:-2}
|
|
| 18 |
+NODE_IPS=${3:-""}
|
|
| 19 | 19 |
INSTANCE_PREFIX=${4:-${OS_INSTANCE_PREFIX:-openshift}}
|
| 20 | 20 |
|
| 21 |
+# Set defaults for optional arguments |
|
| 22 |
+FIXUP_NET_UDEV=false |
|
| 23 |
+NETWORK_PLUGIN=${OPENSHIFT_NETWORK_PLUGIN:-""}
|
|
| 24 |
+NODE_INDEX=0 |
|
| 25 |
+CONFIG_ROOT=${ORIGIN_ROOT}
|
|
| 26 |
+ |
|
| 27 |
+# Parse optional arguments |
|
| 28 |
+# Skip the positional arguments |
|
| 29 |
+OPTIND=5 |
|
| 30 |
+while getopts ":i:n:c:f" opt; do |
|
| 31 |
+ case $opt in |
|
| 32 |
+ f) |
|
| 33 |
+ FIXUP_NET_UDEV=true |
|
| 34 |
+ ;; |
|
| 35 |
+ i) |
|
| 36 |
+ NODE_INDEX=${OPTARG}
|
|
| 37 |
+ ;; |
|
| 38 |
+ n) |
|
| 39 |
+ NETWORK_PLUGIN=${OPTARG}
|
|
| 40 |
+ ;; |
|
| 41 |
+ c) |
|
| 42 |
+ CONFIG_ROOT=${OPTARG}
|
|
| 43 |
+ ;; |
|
| 44 |
+ \?) |
|
| 45 |
+ echo "Invalid option: -${OPTARG}" >&2
|
|
| 46 |
+ exit 1 |
|
| 47 |
+ ;; |
|
| 48 |
+ :) |
|
| 49 |
+ echo "Option -${OPTARG} requires an argument." >&2
|
|
| 50 |
+ exit 1 |
|
| 51 |
+ ;; |
|
| 52 |
+ esac |
|
| 53 |
+done |
|
| 54 |
+ |
|
| 55 |
+LOG_LEVEL=${OPENSHIFT_LOG_LEVEL:-5}
|
|
| 56 |
+ |
|
| 57 |
+NODE_IPS=(${NODE_IPS//,/ })
|
|
| 58 |
+if [ "${CONFIG_ROOT}" = "/" ]; then
|
|
| 59 |
+ CONFIG_ROOT="" |
|
| 60 |
+fi |
|
| 61 |
+NETWORK_PLUGIN=$(os::util::get-network-plugin "${NETWORK_PLUGIN}" \
|
|
| 62 |
+ "${DIND_MANAGEMENT_SCRIPT:-false}")
|
|
| 21 | 63 |
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
| 22 |
-MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
|
|
| 64 |
+NODE_PREFIX="${INSTANCE_PREFIX}-node-"
|
|
| 65 |
+NODE_NAMES=( $(eval echo ${NODE_PREFIX}{1..${NODE_COUNT}}) )
|
|
| 66 |
+SDN_NODE_NAME="${INSTANCE_PREFIX}-master-sdn"
|
| ... | ... |
@@ -1,72 +1,38 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
|
| 3 |
-set -ex |
|
| 4 | 3 |
source $(dirname $0)/provision-config.sh |
| 5 | 4 |
|
| 6 |
-FIXUP_NET_UDEV=$5 |
|
| 7 |
- |
|
| 8 |
-NETWORK_PLUGIN=$(os::util::get-network-plugin ${6:-""})
|
|
| 9 |
- |
|
| 10 |
-if [ "${FIXUP_NET_UDEV}" == "true" ]; then
|
|
| 11 |
- NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/ |
|
| 12 |
- rm -f ${NETWORK_CONF_PATH}ifcfg-enp*
|
|
| 13 |
- if [[ -f "${NETWORK_CONF_PATH}ifcfg-eth1" ]]; then
|
|
| 14 |
- sed -i 's/^NM_CONTROLLED=no/#NM_CONTROLLED=no/' ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 15 |
- if ! grep -q "NAME=" ${NETWORK_CONF_PATH}ifcfg-eth1; then
|
|
| 16 |
- echo "NAME=openshift" >> ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 17 |
- fi |
|
| 18 |
- nmcli con reload |
|
| 19 |
- nmcli dev disconnect eth1 |
|
| 20 |
- nmcli con up "openshift" |
|
| 21 |
- fi |
|
| 22 |
-fi |
|
| 23 |
- |
|
| 24 |
-# Setup hosts file to ensure name resolution to each member of the cluster |
|
| 25 |
-minion_ip_array=(${MINION_IPS//,/ })
|
|
| 26 |
-os::util::setup-hosts-file "${MASTER_NAME}" "${MASTER_IP}" MINION_NAMES \
|
|
| 27 |
- minion_ip_array |
|
| 28 |
- |
|
| 29 |
-# Install the required packages |
|
| 30 |
-yum install -y docker-io git golang e2fsprogs hg net-tools bridge-utils which |
|
| 31 |
- |
|
| 32 |
-# Build openshift |
|
| 33 |
-echo "Building openshift" |
|
| 34 |
-pushd "${ORIGIN_ROOT}"
|
|
| 35 |
- ./hack/build-go.sh |
|
| 36 |
- os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 37 |
- ./hack/install-etcd.sh |
|
| 38 |
-popd |
|
| 39 |
- |
|
| 40 |
-os::util::init-certs "${ORIGIN_ROOT}" "${NETWORK_PLUGIN}" "${MASTER_NAME}" \
|
|
| 41 |
- "${MASTER_IP}" MINION_NAMES minion_ip_array
|
|
| 42 |
- |
|
| 43 |
-# Start docker |
|
| 44 |
-systemctl enable docker.service |
|
| 45 |
-systemctl start docker.service |
|
| 46 |
- |
|
| 47 |
-# Create systemd service |
|
| 48 |
-node_list=$(os::util::join , ${MINION_NAMES[@]})
|
|
| 49 |
-cat <<EOF > /usr/lib/systemd/system/openshift-master.service |
|
| 50 |
-[Unit] |
|
| 51 |
-Description=OpenShift Master |
|
| 52 |
-Requires=docker.service network.service |
|
| 53 |
-After=network.service |
|
| 54 |
- |
|
| 55 |
-[Service] |
|
| 56 |
-ExecStart=/usr/bin/openshift start master --master=https://${MASTER_IP}:8443 --nodes=${node_list} --network-plugin=${NETWORK_PLUGIN}
|
|
| 57 |
-WorkingDirectory=${ORIGIN_ROOT}/
|
|
| 58 |
- |
|
| 59 |
-[Install] |
|
| 60 |
-WantedBy=multi-user.target |
|
| 61 |
-EOF |
|
| 62 |
- |
|
| 63 |
-# Start the service |
|
| 64 |
-systemctl daemon-reload |
|
| 65 |
-systemctl start openshift-master.service |
|
| 66 |
- |
|
| 67 |
-# setup SDN |
|
| 68 |
-$(dirname $0)/provision-sdn.sh |
|
| 69 |
- |
|
| 70 |
-# Set up the KUBECONFIG environment variable for use by oc |
|
| 71 |
-os::util::set-oc-env "${ORIGIN_ROOT}" "/root/.bash_profile"
|
|
| 72 |
-os::util::set-oc-env "${ORIGIN_ROOT}" "/home/vagrant/.bash_profile"
|
|
| 5 |
+os::util::base-provision |
|
| 6 |
+ |
|
| 7 |
+echo "Building and installing openshift" |
|
| 8 |
+${ORIGIN_ROOT}/hack/build-go.sh
|
|
| 9 |
+os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 10 |
+${ORIGIN_ROOT}/hack/install-etcd.sh
|
|
| 11 |
+os::util::install-sdn "${ORIGIN_ROOT}"
|
|
| 12 |
+ |
|
| 13 |
+# Running an openshift node on the master ensures connectivity between |
|
| 14 |
+# the openshift service and pods. This supports kube API calls that |
|
| 15 |
+# query a service and require that the endpoints of the service be |
|
| 16 |
+# reachable from the master. |
|
| 17 |
+# |
|
| 18 |
+# TODO(marun) This is required for connectivity with openshift-sdn, |
|
| 19 |
+# but may not make sense for other plugins. |
|
| 20 |
+NODE_NAMES+=(${SDN_NODE_NAME})
|
|
| 21 |
+NODE_IPS+=(127.0.0.1) |
|
| 22 |
+# Force the addition of a hosts entry for the sdn node. |
|
| 23 |
+os::util::add-to-hosts-file "${MASTER_IP}" "${SDN_NODE_NAME}" 1
|
|
| 24 |
+ |
|
| 25 |
+os::util::init-certs "${CONFIG_ROOT}" "${NETWORK_PLUGIN}" "${MASTER_NAME}" \
|
|
| 26 |
+ "${MASTER_IP}" NODE_NAMES NODE_IPS
|
|
| 27 |
+ |
|
| 28 |
+echo "Launching openshift daemons" |
|
| 29 |
+NODE_LIST=$(os::util::join , ${NODE_NAMES[@]})
|
|
| 30 |
+cmd="/usr/bin/openshift start master --loglevel=${LOG_LEVEL} \
|
|
| 31 |
+ --master=https://${MASTER_IP}:8443 --nodes=${NODE_LIST} \
|
|
| 32 |
+ --network-plugin=${NETWORK_PLUGIN}"
|
|
| 33 |
+os::util::start-os-service "openshift-master" "OpenShift Master" "${cmd}"
|
|
| 34 |
+os::util::start-node-service "${SDN_NODE_NAME}"
|
|
| 35 |
+ |
|
| 36 |
+# TODO(marun) Need to disable scheduling on sdn daemon |
|
| 37 |
+ |
|
| 38 |
+os::util::set-os-env "${ORIGIN_ROOT}" "${CONFIG_ROOT}"
|
| 73 | 39 |
deleted file mode 100755 |
| ... | ... |
@@ -1,76 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -ex |
|
| 3 |
-source $(dirname $0)/provision-config.sh |
|
| 4 |
- |
|
| 5 |
-MINION_IP=$5 |
|
| 6 |
-MINION_INDEX=$6 |
|
| 7 |
-FIXUP_NET_UDEV=$7 |
|
| 8 |
- |
|
| 9 |
-if [ "${FIXUP_NET_UDEV}" == "true" ]; then
|
|
| 10 |
- NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/ |
|
| 11 |
- rm -f ${NETWORK_CONF_PATH}ifcfg-enp*
|
|
| 12 |
- if [[ -f "${NETWORK_CONF_PATH}ifcfg-eth1" ]]; then
|
|
| 13 |
- sed -i 's/^NM_CONTROLLED=no/#NM_CONTROLLED=no/' ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 14 |
- if ! grep -q "NAME=" ${NETWORK_CONF_PATH}ifcfg-eth1; then
|
|
| 15 |
- echo "NAME=openshift" >> ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 16 |
- fi |
|
| 17 |
- nmcli con reload |
|
| 18 |
- nmcli dev disconnect eth1 |
|
| 19 |
- nmcli con up "openshift" |
|
| 20 |
- fi |
|
| 21 |
-fi |
|
| 22 |
- |
|
| 23 |
-# get the minion name, index is 1-based |
|
| 24 |
-minion_name=${MINION_NAMES[$MINION_INDEX-1]}
|
|
| 25 |
- |
|
| 26 |
-# Setup hosts file to ensure name resolution to each member of the cluster |
|
| 27 |
-minion_ip_array=(${MINION_IPS//,/ })
|
|
| 28 |
-os::util::setup-hosts-file "${MASTER_NAME}" "${MASTER_IP}" MINION_NAMES \
|
|
| 29 |
- minion_ip_array |
|
| 30 |
- |
|
| 31 |
-# Install the required packages |
|
| 32 |
-yum install -y docker-io git golang e2fsprogs hg openvswitch net-tools bridge-utils which ethtool |
|
| 33 |
- |
|
| 34 |
-# Build openshift |
|
| 35 |
-echo "Building openshift" |
|
| 36 |
-pushd "${ORIGIN_ROOT}"
|
|
| 37 |
- ./hack/build-go.sh |
|
| 38 |
- os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 39 |
-popd |
|
| 40 |
- |
|
| 41 |
-# Copy over the certificates directory |
|
| 42 |
-cp -r "${ORIGIN_ROOT}/openshift.local.config" /
|
|
| 43 |
-chown -R vagrant.vagrant /openshift.local.config |
|
| 44 |
- |
|
| 45 |
-mkdir -p /openshift.local.volumes |
|
| 46 |
- |
|
| 47 |
-# Setup SDN |
|
| 48 |
-$(dirname $0)/provision-sdn.sh |
|
| 49 |
- |
|
| 50 |
-# Create systemd service |
|
| 51 |
-cat <<EOF > /usr/lib/systemd/system/openshift-node.service |
|
| 52 |
-[Unit] |
|
| 53 |
-Description=OpenShift Node |
|
| 54 |
-Requires=network.service |
|
| 55 |
-After=docker.service network.service |
|
| 56 |
- |
|
| 57 |
-[Service] |
|
| 58 |
-ExecStart=/usr/bin/openshift start node --config=/openshift.local.config/node-${minion_name}/node-config.yaml
|
|
| 59 |
-Restart=on-failure |
|
| 60 |
-RestartSec=10s |
|
| 61 |
- |
|
| 62 |
-[Install] |
|
| 63 |
-WantedBy=multi-user.target |
|
| 64 |
-EOF |
|
| 65 |
- |
|
| 66 |
-# Start the service |
|
| 67 |
-systemctl daemon-reload |
|
| 68 |
-systemctl enable openshift-node.service |
|
| 69 |
-systemctl start openshift-node.service |
|
| 70 |
- |
|
| 71 |
-# Set up the KUBECONFIG environment variable for use by the client |
|
| 72 |
-os::util::set-oc-env / "/root/.bash_profile" |
|
| 73 |
-os::util::set-oc-env / "/home/vagrant/.bash_profile" |
|
| 74 |
- |
|
| 75 |
-# Register with the master |
|
| 76 |
-#curl -X POST -H 'Accept: application/json' -d "{\"kind\":\"Minion\", \"id\":"${MINION_IP}", \"apiVersion\":\"v1beta1\", \"hostIP\":"${MINION_IP}" }" http://${MASTER_IP}:8080/api/v1beta1/minions
|
| 77 | 1 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,17 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+source $(dirname $0)/provision-config.sh |
|
| 3 |
+ |
|
| 4 |
+os::util::base-provision |
|
| 5 |
+ |
|
| 6 |
+# openshift is assumed to have been built before node deployment |
|
| 7 |
+os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 8 |
+ |
|
| 9 |
+os::util::install-sdn "${ORIGIN_ROOT}"
|
|
| 10 |
+ |
|
| 11 |
+echo "Launching openshift daemon" |
|
| 12 |
+# Provided index is 1-based, array is 0 based |
|
| 13 |
+NODE_NAME=${NODE_NAMES[${NODE_INDEX}-1]}
|
|
| 14 |
+os::util::start-node-service "${NODE_NAME}"
|
|
| 15 |
+ |
|
| 16 |
+os::util::set-os-env "${ORIGIN_ROOT}" "${CONFIG_ROOT}"
|
| 0 | 17 |
deleted file mode 100755 |
| ... | ... |
@@ -1,13 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -ex |
|
| 3 |
-source $(dirname $0)/provision-config.sh |
|
| 4 |
- |
|
| 5 |
-os::util::install-sdn "${ORIGIN_ROOT}"
|
|
| 6 |
- |
|
| 7 |
-# Only start openvswitch if it has been installed (only minions). |
|
| 8 |
-if rpm -qa | grep -q openvswitch; then |
|
| 9 |
- systemctl enable openvswitch |
|
| 10 |
- systemctl start openvswitch |
|
| 11 |
-fi |
|
| 12 |
- |
|
| 13 |
-# no need to start openshift-sdn, as it is integrated with openshift binary |
| ... | ... |
@@ -85,24 +85,41 @@ os::util::init-certs() {
|
| 85 | 85 |
popd > /dev/null |
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 |
-# Set up the KUBECONFIG environment variable for use by oc |
|
| 89 |
-os::util::set-oc-env() {
|
|
| 90 |
- local config_root=$1 |
|
| 91 |
- local target=$2 |
|
| 88 |
+os::util::set-os-env() {
|
|
| 89 |
+ local origin_root=$1 |
|
| 90 |
+ local config_root=$2 |
|
| 91 |
+ |
|
| 92 |
+ # Set up the KUBECONFIG environment variable for use by oc. |
|
| 93 |
+ # |
|
| 94 |
+ # Target .bashrc since docker exec doesn't invoke .bash_profile and |
|
| 95 |
+ # .bash_profile loads .bashrc anyway. |
|
| 96 |
+ local file_target=".bashrc" |
|
| 92 | 97 |
|
| 93 |
- if [ "${config_root}" = "/" ]; then
|
|
| 94 |
- config_root="" |
|
| 98 |
+ local vagrant_target="/home/vagrant/${file_target}"
|
|
| 99 |
+ if [ -d $(dirname "${vagrant_target}") ]; then
|
|
| 100 |
+ os::util::set-bash-env "${origin_root}" "${config_root}" \
|
|
| 101 |
+"${vagrant_target}"
|
|
| 95 | 102 |
fi |
| 103 |
+ os::util::set-bash-env "${origin_root}" "${config_root}" \
|
|
| 104 |
+"/root/${file_target}"
|
|
| 105 |
+} |
|
| 106 |
+ |
|
| 107 |
+os::util::set-bash-env() {
|
|
| 108 |
+ local origin_root=$1 |
|
| 109 |
+ local config_root=$2 |
|
| 110 |
+ local target=$3 |
|
| 96 | 111 |
|
| 97 | 112 |
local path="${config_root}/openshift.local.config/master/admin.kubeconfig"
|
| 98 | 113 |
local config_line="export KUBECONFIG=${path}"
|
| 99 | 114 |
if ! grep -q "${config_line}" "${target}" &> /dev/null; then
|
| 100 | 115 |
echo "export KUBECONFIG=${path}" >> "${target}"
|
| 116 |
+ echo "cd ${origin_root}" >> "${target}"
|
|
| 101 | 117 |
fi |
| 102 | 118 |
} |
| 103 | 119 |
|
| 104 | 120 |
os::util::get-network-plugin() {
|
| 105 | 121 |
local plugin=$1 |
| 122 |
+ local dind_management_script=${2:-false}
|
|
| 106 | 123 |
|
| 107 | 124 |
local subnet_plugin="redhat/openshift-ovs-subnet" |
| 108 | 125 |
local multitenant_plugin="redhat/openshift-ovs-multitenant" |
| ... | ... |
@@ -110,15 +127,99 @@ os::util::get-network-plugin() {
|
| 110 | 110 |
|
| 111 | 111 |
if [ "${plugin}" != "${subnet_plugin}" ] && \
|
| 112 | 112 |
[ "${plugin}" != "${multitenant_plugin}" ]; then
|
| 113 |
- if [ "${plugin}" != "" ]; then
|
|
| 113 |
+ # Disable output when being called from the dind management script |
|
| 114 |
+ # since it may be doing something other than launching a cluster. |
|
| 115 |
+ if [ "${dind_management_script}" = "false" ]; then
|
|
| 116 |
+ if [ "${plugin}" != "" ]; then
|
|
| 114 | 117 |
>&2 echo "Invalid network plugin: ${plugin}"
|
| 118 |
+ fi |
|
| 119 |
+ >&2 echo "Using default network plugin: ${default_plugin}"
|
|
| 115 | 120 |
fi |
| 116 |
- >&2 echo "Using default network plugin: ${default_plugin}"
|
|
| 117 | 121 |
plugin="${default_plugin}"
|
| 118 | 122 |
fi |
| 119 | 123 |
echo "${plugin}"
|
| 120 | 124 |
} |
| 121 | 125 |
|
| 126 |
+os::util::base-provision() {
|
|
| 127 |
+ os::util::fixup-net-udev |
|
| 128 |
+ |
|
| 129 |
+ os::util::setup-hosts-file "${MASTER_NAME}" "${MASTER_IP}" NODE_NAMES NODE_IPS
|
|
| 130 |
+ |
|
| 131 |
+ os::util::install-pkgs |
|
| 132 |
+} |
|
| 133 |
+ |
|
| 134 |
+os::util::fixup-net-udev() {
|
|
| 135 |
+ if [ "${FIXUP_NET_UDEV}" == "true" ]; then
|
|
| 136 |
+ NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/ |
|
| 137 |
+ rm -f ${NETWORK_CONF_PATH}ifcfg-enp*
|
|
| 138 |
+ if [[ -f "${NETWORK_CONF_PATH}ifcfg-eth1" ]]; then
|
|
| 139 |
+ sed -i 's/^NM_CONTROLLED=no/#NM_CONTROLLED=no/' ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 140 |
+ if ! grep -q "NAME=" ${NETWORK_CONF_PATH}ifcfg-eth1; then
|
|
| 141 |
+ echo "NAME=openshift" >> ${NETWORK_CONF_PATH}ifcfg-eth1
|
|
| 142 |
+ fi |
|
| 143 |
+ nmcli con reload |
|
| 144 |
+ nmcli dev disconnect eth1 |
|
| 145 |
+ nmcli con up "openshift" |
|
| 146 |
+ fi |
|
| 147 |
+ fi |
|
| 148 |
+} |
|
| 149 |
+ |
|
| 150 |
+os::util::install-pkgs() {
|
|
| 151 |
+ # Only install packages if not deploying to a container. A |
|
| 152 |
+ # container is expected to have installed packages as part of image |
|
| 153 |
+ # creation. |
|
| 154 |
+ if [ ! -f /.dockerinit ]; then |
|
| 155 |
+ yum update -y |
|
| 156 |
+ yum install -y docker-io git golang e2fsprogs hg net-tools bridge-utils which ethtool |
|
| 157 |
+ |
|
| 158 |
+ systemctl enable docker |
|
| 159 |
+ systemctl start docker |
|
| 160 |
+ fi |
|
| 161 |
+} |
|
| 162 |
+ |
|
| 163 |
+os::util::start-os-service() {
|
|
| 164 |
+ local unit_name=$1 |
|
| 165 |
+ local description=$2 |
|
| 166 |
+ local exec_start=$3 |
|
| 167 |
+ local work_dir=${4:-${CONFIG_ROOT}/}
|
|
| 168 |
+ |
|
| 169 |
+ # TODO(marun) Should the daemons be sharing a working directory? |
|
| 170 |
+ |
|
| 171 |
+ cat <<EOF > "/usr/lib/systemd/system/${unit_name}.service"
|
|
| 172 |
+[Unit] |
|
| 173 |
+Description=${description}
|
|
| 174 |
+Requires=network.target |
|
| 175 |
+After=docker.target network.target |
|
| 176 |
+ |
|
| 177 |
+[Service] |
|
| 178 |
+ExecStart=${exec_start}
|
|
| 179 |
+WorkingDirectory=${work_dir}
|
|
| 180 |
+Restart=on-failure |
|
| 181 |
+RestartSec=10s |
|
| 182 |
+ |
|
| 183 |
+[Install] |
|
| 184 |
+WantedBy=multi-user.target |
|
| 185 |
+EOF |
|
| 186 |
+ |
|
| 187 |
+ systemctl daemon-reload |
|
| 188 |
+ systemctl enable "${unit_name}.service"
|
|
| 189 |
+ systemctl start "${unit_name}.service"
|
|
| 190 |
+} |
|
| 191 |
+ |
|
| 192 |
+os::util::start-node-service() {
|
|
| 193 |
+ local node_name=$1 |
|
| 194 |
+ |
|
| 195 |
+ # Copy over the certificates directory so that each node has a copy. |
|
| 196 |
+ cp -r "${CONFIG_ROOT}/openshift.local.config" /
|
|
| 197 |
+ if [ -d /home/vagrant ]; then |
|
| 198 |
+ chown -R vagrant.vagrant /openshift.local.config |
|
| 199 |
+ fi |
|
| 200 |
+ |
|
| 201 |
+ cmd="/usr/bin/openshift start node --loglevel=${LOG_LEVEL} \
|
|
| 202 |
+--config=/openshift.local.config/node-${node_name}/node-config.yaml"
|
|
| 203 |
+ os::util::start-os-service "openshift-node" "OpenShift Node" "${cmd}" /
|
|
| 204 |
+} |
|
| 205 |
+ |
|
| 122 | 206 |
os::util::wait-for-condition() {
|
| 123 | 207 |
local start_msg=$1 |
| 124 | 208 |
local error_msg=$2 |
| ... | ... |
@@ -148,3 +249,30 @@ os::util::wait-for-condition() {
|
| 148 | 148 |
echo -e '\nDone' |
| 149 | 149 |
fi |
| 150 | 150 |
} |
| 151 |
+ |
|
| 152 |
+os::util::is-sdn-node-registered() {
|
|
| 153 |
+ local master_cid=$1 |
|
| 154 |
+ local node_name=$2 |
|
| 155 |
+ |
|
| 156 |
+ ${DOCKER_CMD} exec -t "${master_cid}" bash -ci \
|
|
| 157 |
+ "oc get nodes ${node_name} &> /dev/null"
|
|
| 158 |
+} |
|
| 159 |
+ |
|
| 160 |
+os::util::disable-sdn-node() {
|
|
| 161 |
+ local master_cid=$1 |
|
| 162 |
+ local node_name=$2 |
|
| 163 |
+ |
|
| 164 |
+ local sdn_msg="for sdn node to register with the master" |
|
| 165 |
+ local start_msg="Waiting ${sdn_msg}"
|
|
| 166 |
+ local error_msg="[ERROR] Timeout waiting ${sdn_msg}"
|
|
| 167 |
+ local condition="os::util::is-sdn-node-registered ${master_cid} ${node_name}"
|
|
| 168 |
+ local timeout=30 |
|
| 169 |
+ os::util::wait-for-condition "${start_msg}" "${error_msg}" "${condition}" \
|
|
| 170 |
+ "${timeout}"
|
|
| 171 |
+ |
|
| 172 |
+ echo "Disabling scheduling for the sdn node" |
|
| 173 |
+ # Disable scheduling outside of the master provision script to give |
|
| 174 |
+ # the node time to register itself to the master. |
|
| 175 |
+ ${DOCKER_CMD} exec -t "${master_cid}" bash -ci \
|
|
| 176 |
+ "osadm manage-node ${node_name} --schedulable=false > /dev/null"
|
|
| 177 |
+} |
| ... | ... |
@@ -59,44 +59,26 @@ |
| 59 | 59 |
# |
| 60 | 60 |
# hack/dind-cluster.sh test-net-e2e |
| 61 | 61 |
# |
| 62 |
-# Bash Aliases |
|
| 63 |
-# ------------ |
|
| 64 |
-# |
|
| 65 |
-# The following bash aliases are available in the cluster containers: |
|
| 66 |
-# |
|
| 67 |
-# oc-create-hello - create the 'hello' example app |
|
| 68 |
-# oc-less-log - invoke 'less' on the openshift daemon log (will target |
|
| 69 |
-# the master or node log depending on the type of node) |
|
| 70 |
-# oc-tail-log - invoke tail on the openshift daemon log |
|
| 71 |
-# |
|
| 72 |
-# Process Management |
|
| 73 |
-# ------------------ |
|
| 74 |
-# |
|
| 75 |
-# Due to docker-in-docker conflicting with systemd when running in a |
|
| 76 |
-# container, supervisord is used instead. The 'supervisorctl' command |
|
| 77 |
-# is the equivalent of 'systemctl' and logs for managed processes can |
|
| 78 |
-# be found in /var/log/supervisor. |
|
| 79 |
-# |
|
| 80 |
-# Loopback Devices |
|
| 81 |
-# ---------------- |
|
| 82 |
-# |
|
| 83 |
-# Due to the way docker-in-docker daemons interact with loopback |
|
| 84 |
-# devices, it is important to invoke 'dind-cluster.sh stop' on a |
|
| 85 |
-# running cluster instead of manually stopping the containers. This |
|
| 86 |
-# ensures that the containerized docker daemons are gracefully |
|
| 87 |
-# shutdown and allowed to release their loopback devices before |
|
| 88 |
-# container shutdown. If the daemons are not stopped before container |
|
| 89 |
-# shutdown, the associated loopback devices will be effectively |
|
| 90 |
-# unusable ('leaked') until a subsequent host reboot. If enough
|
|
| 91 |
-# loopback devices are leaked, cluster boot may not be possible since |
|
| 92 |
-# each openshift node running in a container depends on a docker |
|
| 93 |
-# daemon requiring 2 loopback devices. |
|
| 94 | 62 |
|
| 95 | 63 |
set -o errexit |
| 96 | 64 |
set -o nounset |
| 97 | 65 |
set -o pipefail |
| 98 | 66 |
|
| 99 |
-source $(dirname "${BASH_SOURCE}")/dind/init.sh
|
|
| 67 |
+DIND_MANAGEMENT_SCRIPT=true |
|
| 68 |
+ |
|
| 69 |
+source $(dirname "${BASH_SOURCE}")/../contrib/vagrant/provision-config.sh
|
|
| 70 |
+ |
|
| 71 |
+DOCKER_CMD=${DOCKER_CMD:-"sudo docker"}
|
|
| 72 |
+ |
|
| 73 |
+# Override the default CONFIG_ROOT path with one that is |
|
| 74 |
+# cluster-specific. |
|
| 75 |
+CONFIG_ROOT=${OS_DIND_CONFIG_ROOT:-/tmp/openshift-dind-cluster/${INSTANCE_PREFIX}}
|
|
| 76 |
+ |
|
| 77 |
+DEPLOYED_CONFIG_ROOT="/config" |
|
| 78 |
+ |
|
| 79 |
+DEPLOYED_ROOT="/data" |
|
| 80 |
+ |
|
| 81 |
+SCRIPT_ROOT="${DEPLOYED_ROOT}/contrib/vagrant"
|
|
| 100 | 82 |
|
| 101 | 83 |
function check-selinux() {
|
| 102 | 84 |
if [ "$(getenforce)" = "Enforcing" ]; then |
| ... | ... |
@@ -141,45 +123,15 @@ function get-docker-ip() {
|
| 141 | 141 |
${DOCKER_CMD} inspect --format '{{ .NetworkSettings.IPAddress }}' "${cid}"
|
| 142 | 142 |
} |
| 143 | 143 |
|
| 144 |
-# Ensure sufficient available loopback devices to support the |
|
| 145 |
-# indicated number of dind nodes. Since it's not possible to create |
|
| 146 |
-# device nodes inside a container, this function needs to be called |
|
| 147 |
-# before launching a container that will run dind. |
|
| 148 |
-function ensure-loopback-for-dind() {
|
|
| 149 |
- local node_count=$1 |
|
| 150 |
- |
|
| 151 |
- # Ensure extra loopback devices to minimize the potential for |
|
| 152 |
- # contention. Sometimes docker restarts during deployment don't |
|
| 153 |
- # properly release the devices. |
|
| 154 |
- local extra_loopback=4 |
|
| 155 |
- local loopback_per_node=2 |
|
| 156 |
- local required_free_loopback=$(( ( ${node_count} * ${loopback_per_node} ) + \
|
|
| 157 |
- ${extra_loopback} ))
|
|
| 158 |
- |
|
| 159 |
- # Find the maximum index of existing loopback devices. |
|
| 160 |
- local max_index=$(losetup | grep '/dev/loop' | tail -n 1 | |
|
| 161 |
- sed -e 's|^/dev/loop\([0-9]\{1,\}\).*|\1|')
|
|
| 162 |
- if [ -z "${max_index}" ]; then
|
|
| 163 |
- max_index=0 |
|
| 164 |
- fi |
|
| 165 |
- |
|
| 166 |
- local requested_max_index=$(( ${max_index} + ${required_free_loopback} - 1))
|
|
| 167 |
- for i in $(eval echo "{${max_index}..${requested_max_index}}"); do
|
|
| 168 |
- if [ ! -e "/dev/loop${i}" ]; then
|
|
| 169 |
- sudo mknod "/dev/loop${i}" b 7 "${i}"
|
|
| 170 |
- fi |
|
| 171 |
- done |
|
| 172 |
-} |
|
| 173 |
- |
|
| 174 | 144 |
function start() {
|
| 175 | 145 |
# docker-in-docker's use of volumes is not compatible with SELinux |
| 176 | 146 |
check-selinux |
| 177 | 147 |
|
| 148 |
+ # TODO(marun) - perform these operations in a container for boot2docker compat |
|
| 178 | 149 |
echo "Ensuring compatible host configuration" |
| 179 | 150 |
sudo modprobe openvswitch |
| 180 | 151 |
sudo modprobe br_netfilter || true |
| 181 | 152 |
sudo sysctl -w net.bridge.bridge-nf-call-iptables=0 |
| 182 |
- ensure-loopback-for-dind "${NUM_NODES}"
|
|
| 183 | 153 |
mkdir -p "${CONFIG_ROOT}"
|
| 184 | 154 |
|
| 185 | 155 |
build-images |
| ... | ... |
@@ -205,10 +157,12 @@ function start() {
|
| 205 | 205 |
node_ips=$(os::util::join , ${node_ips[@]})
|
| 206 | 206 |
|
| 207 | 207 |
## Provision containers |
| 208 |
- local args="${master_ip} ${NUM_NODES} ${node_ips} ${INSTANCE_PREFIX}"
|
|
| 208 |
+ echo "Configured network plugin: ${NETWORK_PLUGIN}"
|
|
| 209 |
+ local args="${master_ip} ${NODE_COUNT} ${node_ips} ${INSTANCE_PREFIX} \
|
|
| 210 |
+-n '${NETWORK_PLUGIN}'"
|
|
| 209 | 211 |
echo "Provisioning ${MASTER_NAME}"
|
| 210 | 212 |
${DOCKER_CMD} exec -t "${master_cid}" bash -c \
|
| 211 |
- "${SCRIPT_ROOT}/provision-master.sh ${args} ${MASTER_NAME} ${NETWORK_PLUGIN}"
|
|
| 213 |
+ "${SCRIPT_ROOT}/provision-master.sh ${args} -c ${DEPLOYED_CONFIG_ROOT}"
|
|
| 212 | 214 |
|
| 213 | 215 |
# Ensure that all users (e.g. outside the container) have read-write |
| 214 | 216 |
# access to the openshift configuration. Security shouldn't be a |
| ... | ... |
@@ -218,18 +172,21 @@ function start() {
|
| 218 | 218 |
find "${openshift_config_path}" -type d -exec sudo chmod ga+x {} \;
|
| 219 | 219 |
|
| 220 | 220 |
for (( i=0; i < ${#node_cids[@]}; i++ )); do
|
| 221 |
+ local node_index=$((i + 1)) |
|
| 221 | 222 |
local cid="${node_cids[$i]}"
|
| 222 | 223 |
local name="${NODE_NAMES[$i]}"
|
| 223 | 224 |
echo "Provisioning ${name}"
|
| 224 | 225 |
${DOCKER_CMD} exec "${cid}" bash -c \
|
| 225 |
- "${SCRIPT_ROOT}/provision-node.sh ${args} ${name}"
|
|
| 226 |
+ "${SCRIPT_ROOT}/provision-node.sh ${args} -i ${node_index} -c \
|
|
| 227 |
+${DEPLOYED_CONFIG_ROOT}"
|
|
| 226 | 228 |
done |
| 227 | 229 |
|
| 228 |
- os::dind::disable-sdn-node "${master_cid}" "${SDN_NODE_NAME}"
|
|
| 230 |
+ os::util::disable-sdn-node "${master_cid}" "${SDN_NODE_NAME}"
|
|
| 229 | 231 |
} |
| 230 | 232 |
|
| 231 | 233 |
function stop() {
|
| 232 | 234 |
echo "Cleaning up docker-in-docker containers" |
| 235 |
+ |
|
| 233 | 236 |
local master_cid=$(${DOCKER_CMD} ps -qa --filter "name=${MASTER_NAME}")
|
| 234 | 237 |
if [[ "${master_cid}" ]]; then
|
| 235 | 238 |
${DOCKER_CMD} rm -f "${master_cid}"
|
| ... | ... |
@@ -239,21 +196,11 @@ function stop() {
|
| 239 | 239 |
if [[ "${node_cids}" ]]; then
|
| 240 | 240 |
node_cids=(${node_cids//\n/ })
|
| 241 | 241 |
for cid in "${node_cids[@]}"; do
|
| 242 |
- # Ensure that the nested docker daemon is stopped before attempting |
|
| 243 |
- # container removal so associated loopback devices are properly |
|
| 244 |
- # released. |
|
| 245 |
- # |
|
| 246 |
- # See: https://github.com/jpetazzo/dind/issues/19 |
|
| 247 |
- # |
|
| 248 |
- local is_running=$(${DOCKER_CMD} inspect -f {{.State.Running}} "${cid}")
|
|
| 249 |
- if [ "${is_running}" = "true" ]; then
|
|
| 250 |
- ${DOCKER_CMD} exec -t "${cid}" "${SCRIPT_ROOT}/kill-docker.sh"
|
|
| 251 |
- fi |
|
| 252 | 242 |
${DOCKER_CMD} rm -f "${cid}"
|
| 253 | 243 |
done |
| 254 | 244 |
fi |
| 255 | 245 |
|
| 256 |
- echo "Clearing configuration to avoid conflict with a future cluster" |
|
| 246 |
+ echo "Cleanup up configuration to avoid conflict with a future cluster" |
|
| 257 | 247 |
# The container will have created configuration as root |
| 258 | 248 |
sudo rm -rf ${CONFIG_ROOT}/openshift.local.*
|
| 259 | 249 |
|
| ... | ... |
@@ -314,8 +261,7 @@ case "${1:-""}" in
|
| 314 | 314 |
test-net-e2e |
| 315 | 315 |
;; |
| 316 | 316 |
config-host) |
| 317 |
- os::util::set-oc-env "${CONFIG_ROOT}" "/home/vagrant/.bashrc"
|
|
| 318 |
- os::util::set-oc-env "${CONFIG_ROOT}" "/root/.bashrc"
|
|
| 317 |
+ os::util::set-os-env "${ORIGIN_ROOT}" "${CONFIG_ROOT}"
|
|
| 319 | 318 |
;; |
| 320 | 319 |
*) |
| 321 | 320 |
echo "Usage: $0 {start|stop|restart|build-images|test-net-e2e|config-host}"
|
| 322 | 321 |
deleted file mode 100644 |
| ... | ... |
@@ -1,95 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-set -o errexit |
|
| 4 |
-set -o nounset |
|
| 5 |
-set -o pipefail |
|
| 6 |
- |
|
| 7 |
-source $(dirname "${BASH_SOURCE}")/../../contrib/vagrant/provision-config.sh
|
|
| 8 |
- |
|
| 9 |
-NUM_NODES=${NUM_MINIONS:-2}
|
|
| 10 |
-NODE_IPS=(${MINION_IPS//,/ })
|
|
| 11 |
-HOST_NAME=${5:-""}
|
|
| 12 |
-NETWORK_PLUGIN=${6:-${OPENSHIFT_SDN:-""}}
|
|
| 13 |
- |
|
| 14 |
-NODE_PREFIX="${INSTANCE_PREFIX}-node-"
|
|
| 15 |
-NODE_NAMES=( $(eval echo ${NODE_PREFIX}{1..${NUM_NODES}}) )
|
|
| 16 |
-SDN_NODE_NAME="${INSTANCE_PREFIX}-master-sdn"
|
|
| 17 |
- |
|
| 18 |
-DOCKER_CMD=${DOCKER_CMD:-"sudo docker"}
|
|
| 19 |
- |
|
| 20 |
-DEPLOYED_ROOT="/data" |
|
| 21 |
-SCRIPT_ROOT="${DEPLOYED_ROOT}/hack/dind"
|
|
| 22 |
-SUPERVISORD_CONF="/etc/supervisord.conf" |
|
| 23 |
- |
|
| 24 |
-CONFIG_ROOT=${OS_DIND_CONFIG_ROOT:-/tmp/openshift-dind-cluster/${INSTANCE_PREFIX}}
|
|
| 25 |
-DEPLOYED_CONFIG_ROOT="/config" |
|
| 26 |
- |
|
| 27 |
-os::dind::set-dind-env() {
|
|
| 28 |
- # Set up the KUBECONFIG environment variable for use by oc |
|
| 29 |
- local deployed_root=$1 |
|
| 30 |
- local config_root=$2 |
|
| 31 |
- |
|
| 32 |
- # Target .bashrc by default instead of .bash_profile because a |
|
| 33 |
- # 'docker exec' invocation will not run .bash_profile |
|
| 34 |
- local target=${3:-"/root/.bashrc"}
|
|
| 35 |
- |
|
| 36 |
- local log_target='/var/log/supervisor/openshift-*-stderr-*' |
|
| 37 |
- os::util::set-oc-env "${config_root}" "${target}"
|
|
| 38 |
- cat <<EOF >> "${target}"
|
|
| 39 |
-alias oc-less-log="less ${log_target}"
|
|
| 40 |
-alias oc-tail-log="tail -f ${log_target}"
|
|
| 41 |
-alias oc-create-hello="oc create -f ${deployed_root}/examples/hello-openshift/hello-pod.json"
|
|
| 42 |
-EOF |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-os::dind::reload-docker() {
|
|
| 46 |
- # Ensure that openshift-sdn has written configuration for docker |
|
| 47 |
- # before triggering a docker restart. |
|
| 48 |
- echo "Waiting for openshift-sdn to update supervisord.conf with docker config" |
|
| 49 |
- local counter=0 |
|
| 50 |
- local timeout=30 |
|
| 51 |
- while grep -q 'DOCKER_DAEMON_ARGS=\"\"' "${SUPERVISORD_CONF}"; do
|
|
| 52 |
- if [[ "${counter}" -lt "${timeout}" ]]; then
|
|
| 53 |
- counter=$((counter + 1)) |
|
| 54 |
- echo -n '.' |
|
| 55 |
- sleep 1 |
|
| 56 |
- else |
|
| 57 |
- echo -e "\n[ERROR] Timeout waiting for openshift-sdn to update supervisord.conf" |
|
| 58 |
- exit 1 |
|
| 59 |
- fi |
|
| 60 |
- done |
|
| 61 |
- echo -e '\nDone' |
|
| 62 |
- |
|
| 63 |
- # Stop docker gracefully |
|
| 64 |
- ${SCRIPT_ROOT}/kill-docker.sh
|
|
| 65 |
- |
|
| 66 |
- # Restart docker |
|
| 67 |
- supervisorctl update |
|
| 68 |
-} |
|
| 69 |
- |
|
| 70 |
-os::dind::is-sdn-node-registered() {
|
|
| 71 |
- local master_cid=$1 |
|
| 72 |
- local node_name=$2 |
|
| 73 |
- |
|
| 74 |
- ${DOCKER_CMD} exec -t "${master_cid}" bash -ci \
|
|
| 75 |
- "oc get nodes ${node_name} &> /dev/null"
|
|
| 76 |
-} |
|
| 77 |
- |
|
| 78 |
-os::dind::disable-sdn-node() {
|
|
| 79 |
- local master_cid=$1 |
|
| 80 |
- local node_name=$2 |
|
| 81 |
- |
|
| 82 |
- local sdn_msg="for sdn node to register with the master" |
|
| 83 |
- local start_msg="Waiting ${sdn_msg}"
|
|
| 84 |
- local error_msg="[ERROR] Timeout waiting ${sdn_msg}"
|
|
| 85 |
- local condition="os::dind::is-sdn-node-registered ${master_cid} ${node_name}"
|
|
| 86 |
- local timeout=30 |
|
| 87 |
- os::util::wait-for-condition "${start_msg}" "${error_msg}" "${condition}" \
|
|
| 88 |
- "${timeout}"
|
|
| 89 |
- |
|
| 90 |
- echo "Disabling scheduling for the sdn node" |
|
| 91 |
- # Disable scheduling outside of the master provision script to give |
|
| 92 |
- # the node time to register itself to the master. |
|
| 93 |
- ${DOCKER_CMD} exec -t "${master_cid}" bash -ci \
|
|
| 94 |
- "osadm manage-node ${node_name} --schedulable=false > /dev/null"
|
|
| 95 |
-} |
| 96 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,27 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-# Ensure that docker is gracefully killed. |
|
| 4 |
- |
|
| 5 |
-set -o errexit |
|
| 6 |
-set -o nounset |
|
| 7 |
-set -o pipefail |
|
| 8 |
- |
|
| 9 |
-pid_file=/var/run/docker.pid |
|
| 10 |
-if [ -f "${pid_file}" ]; then
|
|
| 11 |
- pid=$(cat "${pid_file}")
|
|
| 12 |
- kill "${pid}"
|
|
| 13 |
- echo "Waiting for docker daemon to exit" |
|
| 14 |
- COUNTER=0 |
|
| 15 |
- TIMEOUT=60 |
|
| 16 |
- while [ -d "/proc/${pid}" ]; do
|
|
| 17 |
- if [[ "${COUNTER}" -lt "${TIMEOUT}" ]]; then
|
|
| 18 |
- COUNTER=$((COUNTER + 1)) |
|
| 19 |
- echo -n '.' |
|
| 20 |
- sleep 1 |
|
| 21 |
- else |
|
| 22 |
- echo -e "\nError: Timeout waiting for the docker daemon to exit" |
|
| 23 |
- exit 1 |
|
| 24 |
- fi |
|
| 25 |
- done |
|
| 26 |
- echo -e '\nDone' |
|
| 27 |
-fi |
| 28 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,56 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-set -o errexit |
|
| 4 |
-set -o nounset |
|
| 5 |
-set -o pipefail |
|
| 6 |
- |
|
| 7 |
-source $(dirname "${BASH_SOURCE}")/init.sh
|
|
| 8 |
- |
|
| 9 |
-NETWORK_PLUGIN=$(os::util::get-network-plugin "${NETWORK_PLUGIN}")
|
|
| 10 |
- |
|
| 11 |
-# Running an openshift node on the master ensures connectivity between |
|
| 12 |
-# the openshift service and pods. This supports kube API calls that |
|
| 13 |
-# query a service and require that the endpoints of the service be |
|
| 14 |
-# reachable from the master. |
|
| 15 |
-NODE_NAMES+=(${SDN_NODE_NAME})
|
|
| 16 |
-NODE_IPS+=(127.0.0.1) |
|
| 17 |
- |
|
| 18 |
-# Force the addition of a hosts entry for the sdn node. |
|
| 19 |
-os::util::add-to-hosts-file "${MASTER_IP}" "${SDN_NODE_NAME}" 1
|
|
| 20 |
- |
|
| 21 |
-os::util::setup-hosts-file "${MASTER_NAME}" "${MASTER_IP}" NODE_NAMES NODE_IPS
|
|
| 22 |
- |
|
| 23 |
-echo "Building and installing openshift" |
|
| 24 |
-${ORIGIN_ROOT}/hack/build-go.sh
|
|
| 25 |
-os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 26 |
-${ORIGIN_ROOT}/hack/install-etcd.sh
|
|
| 27 |
-os::util::install-sdn "${ORIGIN_ROOT}"
|
|
| 28 |
- |
|
| 29 |
-os::util::init-certs "${DEPLOYED_CONFIG_ROOT}" "${NETWORK_PLUGIN}" \
|
|
| 30 |
- "${MASTER_NAME}" "${MASTER_IP}" NODE_NAMES NODE_IPS
|
|
| 31 |
- |
|
| 32 |
-NODE_NAME_LIST=$(os::util::join , ${NODE_NAMES[@]})
|
|
| 33 |
-cat <<EOF >> "${SUPERVISORD_CONF}"
|
|
| 34 |
- |
|
| 35 |
-[program:openshift-master] |
|
| 36 |
-command=/usr/bin/openshift start master --loglevel=5 --master=https://${MASTER_IP}:8443 --nodes=${NODE_NAME_LIST} --network-plugin=${NETWORK_PLUGIN}
|
|
| 37 |
-directory=${DEPLOYED_CONFIG_ROOT}
|
|
| 38 |
-priority=10 |
|
| 39 |
-startsecs=20 |
|
| 40 |
-stderr_events_enabled=true |
|
| 41 |
-stdout_events_enabled=true |
|
| 42 |
- |
|
| 43 |
-[program:openshift-master-sdn] |
|
| 44 |
-command=/usr/bin/openshift start node --loglevel=5 --config=${DEPLOYED_CONFIG_ROOT}/openshift.local.config/node-${SDN_NODE_NAME}/node-config.yaml
|
|
| 45 |
-priority=20 |
|
| 46 |
-startsecs=20 |
|
| 47 |
-stderr_events_enabled=true |
|
| 48 |
-stdout_events_enabled=true |
|
| 49 |
-EOF |
|
| 50 |
- |
|
| 51 |
-# Start openshift |
|
| 52 |
-supervisorctl update |
|
| 53 |
- |
|
| 54 |
-os::dind::reload-docker |
|
| 55 |
- |
|
| 56 |
-os::dind::set-dind-env "${ORIGIN_ROOT}" "${DEPLOYED_CONFIG_ROOT}"
|
| 57 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-set -o errexit |
|
| 4 |
-set -o nounset |
|
| 5 |
-set -o pipefail |
|
| 6 |
- |
|
| 7 |
-source $(dirname "${BASH_SOURCE}")/init.sh
|
|
| 8 |
- |
|
| 9 |
-os::util::setup-hosts-file ${MASTER_NAME} ${MASTER_IP} NODE_NAMES NODE_IPS
|
|
| 10 |
- |
|
| 11 |
-echo "Installing openshift" |
|
| 12 |
-os::util::install-cmds "${ORIGIN_ROOT}"
|
|
| 13 |
-os::util::install-sdn "${ORIGIN_ROOT}"
|
|
| 14 |
- |
|
| 15 |
-cat <<EOF >> "${SUPERVISORD_CONF}"
|
|
| 16 |
- |
|
| 17 |
-[program:openshift-node] |
|
| 18 |
-command=/usr/bin/openshift start node --loglevel=5 --config=${DEPLOYED_CONFIG_ROOT}/openshift.local.config/node-${HOST_NAME}/node-config.yaml
|
|
| 19 |
-priority=20 |
|
| 20 |
-startsecs=20 |
|
| 21 |
-stderr_events_enabled=true |
|
| 22 |
-stdout_events_enabled=true |
|
| 23 |
-EOF |
|
| 24 |
- |
|
| 25 |
-# Start openshift |
|
| 26 |
-supervisorctl update |
|
| 27 |
- |
|
| 28 |
-os::dind::reload-docker |
|
| 29 |
- |
|
| 30 |
-os::dind::set-dind-env "${ORIGIN_ROOT}" "${DEPLOYED_CONFIG_ROOT}"
|
| ... | ... |
@@ -6,23 +6,34 @@ |
| 6 | 6 |
|
| 7 | 7 |
FROM fedora:21 |
| 8 | 8 |
|
| 9 |
-RUN yum -y update && yum -y install supervisor git golang hg tar make \ |
|
| 9 |
+## Configure systemd to run in a container |
|
| 10 |
+ENV container=docker |
|
| 11 |
+ |
|
| 12 |
+RUN systemctl mask systemd-remount-fs.service dev-hugepages.mount \ |
|
| 13 |
+ sys-fs-fuse-connections.mount systemd-logind.service getty.target \ |
|
| 14 |
+ console-getty.service dnf-makecache.service |
|
| 15 |
+RUN cp /usr/lib/systemd/system/dbus.service /etc/systemd/system/; \ |
|
| 16 |
+ sed -i 's/OOMScoreAdjust=-900//' /etc/systemd/system/dbus.service |
|
| 17 |
+ |
|
| 18 |
+VOLUME ["/run", "/tmp"] |
|
| 19 |
+ |
|
| 20 |
+## Install packages |
|
| 21 |
+RUN yum -y update && yum -y install git golang hg tar make \ |
|
| 10 | 22 |
hostname bind-utils iproute iputils which procps-ng \ |
| 11 | 23 |
# Node-specific packages |
| 12 | 24 |
docker openvswitch bridge-utils ethtool \ |
| 13 | 25 |
&& yum clean all |
| 14 | 26 |
|
| 27 |
+## Configure dind |
|
| 15 | 28 |
ENV DIND_COMMIT 4e899d64e020a67ca05f913d354aa8d99a341a7b |
| 16 | 29 |
RUN curl -fL "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind" \
|
| 17 | 30 |
-o /usr/local/bin/dind && chmod +x /usr/local/bin/dind |
| 18 | 31 |
|
| 19 |
-# Use a bash script to work around supervisord's inability to allow |
|
| 20 |
-# arbitrary environment variables in command strings. |
|
| 21 |
-ADD wrapdind /usr/local/bin/wrapdind |
|
| 22 |
-RUN chmod +x /usr/local/bin/wrapdind |
|
| 32 |
+RUN mv /lib/systemd/system/docker.service /lib/systemd/system/docker.service.bak |
|
| 33 |
+COPY docker.service /lib/systemd/system/ |
|
| 23 | 34 |
|
| 24 |
-VOLUME /var/lib/docker |
|
| 35 |
+RUN systemctl enable docker.service |
|
| 25 | 36 |
|
| 26 |
-ADD supervisord.conf /etc/supervisord.conf |
|
| 37 |
+VOLUME /var/lib/docker |
|
| 27 | 38 |
|
| 28 |
-CMD [ "/usr/bin/supervisord" ] |
|
| 39 |
+CMD ["/usr/sbin/init"] |
| 29 | 40 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+[Unit] |
|
| 1 |
+Description=Docker-in-Docker (dind) |
|
| 2 |
+After=network.target |
|
| 3 |
+ |
|
| 4 |
+[Service] |
|
| 5 |
+Type=notify |
|
| 6 |
+EnvironmentFile=-/etc/sysconfig/docker-network |
|
| 7 |
+Environment=GOTRACEBACK=crash |
|
| 8 |
+ExecStart=/usr/local/bin/dind docker daemon --host=unix:///var/run/docker.sock \ |
|
| 9 |
+ --host=tcp://0.0.0.0:2375 --storage-driver=vfs \ |
|
| 10 |
+ --exec-opt native.cgroupdriver=cgroupfs \ |
|
| 11 |
+ $DOCKER_NETWORK_OPTIONS |
|
| 12 |
+ |
|
| 13 |
+[Install] |
|
| 14 |
+WantedBy=multi-user.target |
| 0 | 15 |
deleted file mode 100644 |
| ... | ... |
@@ -1,32 +0,0 @@ |
| 1 |
-[supervisord] |
|
| 2 |
-nodaemon=true |
|
| 3 |
-logfile = /var/log/supervisor/supervisord.log |
|
| 4 |
-logfile_maxbytes = 200KB |
|
| 5 |
-logfile_backups = 1 |
|
| 6 |
-pidfile = /var/run/supervisord.pid |
|
| 7 |
-childlogdir = /var/log/supervisor |
|
| 8 |
- |
|
| 9 |
-[unix_http_server] |
|
| 10 |
-file = /var/run/supervisor.sock |
|
| 11 |
- |
|
| 12 |
-[rpcinterface:supervisor] |
|
| 13 |
-supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface |
|
| 14 |
- |
|
| 15 |
-[supervisorctl] |
|
| 16 |
-serverurl = unix:///var/run/supervisor.sock |
|
| 17 |
- |
|
| 18 |
-[program:docker] |
|
| 19 |
-command=/usr/local/bin/wrapdind |
|
| 20 |
-priority=10 |
|
| 21 |
-startsecs=10 |
|
| 22 |
-stderr_events_enabled=true |
|
| 23 |
-stdout_events_enabled=true |
|
| 24 |
-environment=DOCKER_DAEMON_ARGS="" |
|
| 25 |
-autorestart=false |
|
| 26 |
- |
|
| 27 |
-[program:openvswitch] |
|
| 28 |
-command=/usr/share/openvswitch/scripts/ovs-ctl start --system-id=random |
|
| 29 |
-priority=10 |
|
| 30 |
-startsecs=0 |
|
| 31 |
-# The fedora control script exits after starting the ovs daemons. |
|
| 32 |
-autorestart=false |