vagrant/provision-minion.sh
16aecd47
 #!/bin/bash
 set -ex
 source $(dirname $0)/provision-config.sh
 
 MINION_IP=$4
168f6beb
 OPENSHIFT_SDN=$6
72bcaea7
 MINION_INDEX=$5
16aecd47
 
777433ec
 NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/
 sed -i 's/^NM_CONTROLLED=no/#NM_CONTROLLED=no/' ${NETWORK_CONF_PATH}ifcfg-eth1
 
 systemctl restart network
 
 # get the minion name, index is 1-based
 minion_name=${MINION_NAMES[$MINION_INDEX-1]}
 
16aecd47
 # Setup hosts file to support ping by hostname to master
 if [ ! "$(cat /etc/hosts | grep $MASTER_NAME)" ]; then
   echo "Adding $MASTER_NAME to hosts file"
   echo "$MASTER_IP $MASTER_NAME" >> /etc/hosts
 fi
 
 # Setup hosts file to support ping by hostname to each minion in the cluster
 minion_ip_array=(${MINION_IPS//,/ })
 for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
   minion=${MINION_NAMES[$i]}
   ip=${minion_ip_array[$i]}  
   if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
     echo "Adding $minion to hosts file"
     echo "$ip $minion" >> /etc/hosts
975a7209
   fi
16aecd47
 done
777433ec
 if ! grep ${MINION_IP} /etc/hosts; then
   echo "${MINION_IP} ${minion_name}" >> /etc/hosts
 fi
16aecd47
 
 # Install the required packages
69ecca8e
 yum install -y docker-io git golang e2fsprogs hg openvswitch net-tools bridge-utils which ethtool
16aecd47
 
 # Build openshift
 echo "Building openshift"
 pushd /vagrant
   ./hack/build-go.sh
e3bb13a1
   cp _output/local/go/bin/openshift /usr/bin
16aecd47
 popd
 
cb1a5e1b
 # Copy over the certificates directory
40be29be
 cp -r /vagrant/openshift.local.config /
 chown -R vagrant.vagrant /openshift.local.config
cb1a5e1b
 
0241c213
 if [ "${OPENSHIFT_SDN}" != "ovs-gre" ]; then
40be29be
   export ETCD_CAFILE=/openshift.local.config/master/ca.crt
   export ETCD_CERTFILE=/openshift.local.config/master/master.etcd-client.crt
   export ETCD_KEYFILE=/openshift.local.config/master/master.etcd-client.key
168f6beb
   $(dirname $0)/provision-node-sdn.sh $@
 else
   # Setup default networking between the nodes
   $(dirname $0)/provision-gre-network.sh $@
 fi
16aecd47
 
 # Create systemd service
 cat <<EOF > /usr/lib/systemd/system/openshift-node.service
 [Unit]
52683658
 Description=OpenShift Node
69ecca8e
 Requires=network.service
 After=docker.service network.service
16aecd47
 
 [Service]
40be29be
 ExecStart=/usr/bin/openshift start node --config=/openshift.local.config/node-${minion_name}/node-config.yaml
232a2d11
 Restart=on-failure
 RestartSec=10s
16aecd47
 
 [Install]
 WantedBy=multi-user.target
 EOF
 
 # Start the service
 systemctl daemon-reload
 systemctl enable openshift-node.service
 systemctl start openshift-node.service
 
d46b3af9
 # Set up the KUBECONFIG environment variable for use by the client
 echo 'export KUBECONFIG=/openshift.local.config/master/admin.kubeconfig' >> /root/.bash_profile
 echo 'export KUBECONFIG=/openshift.local.config/master/admin.kubeconfig' >> /home/vagrant/.bash_profile
e82970e0
 
16aecd47
 # Register with the master
 #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