This repository has been archived by the owner on Mar 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from e-minguez/post_install
Added post-install script to apply mcos
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
set -xe | ||
|
||
source logging.sh | ||
source common.sh | ||
|
||
KUBECONFIG=${KUBECONFIG:-ocp/auth/kubeconfig} | ||
IFCFG_INTERFACE="assets/post-install/ifcfg-interface.template" | ||
IFCFG_BRIDGE="assets/post-install/ifcfg-bridge.template" | ||
|
||
export bridge="${bridge:-brext}" | ||
|
||
create_bridge(){ | ||
echo "Deploying Bridge ${bridge}..." | ||
|
||
FIRST_MASTER=$(oc get node -o custom-columns=IP:.status.addresses[0].address --no-headers | head -1) | ||
export interface=$(ssh -q -o StrictHostKeyChecking=no core@$FIRST_MASTER "ip r | grep default | grep -Po '(?<=dev )(\S+)'") | ||
if [ "$interface" == "" ] ; then | ||
echo "Issue detecting interface to use! Leaving..." | ||
exit 1 | ||
if [ "$interface" != "$bridge" ] ; then | ||
echo "Using interface $interface" | ||
export interface_content=$(envsubst < ${IFCFG_INTERFACE} | base64) | ||
export bridge_content=$(envsubst < ${IFCFG_BRIDGE} | base64) | ||
envsubst < assets/post-install/99-brext-master.yaml.template > assets/post-install/99-brext-master.yaml | ||
echo "Done creating bridge definition" | ||
else | ||
echo "Bridge already there!" | ||
fi | ||
} | ||
|
||
apply_mc(){ | ||
for node_type in master node; do | ||
# Disable auto reboot hosts in order to apply several mcos at the same time | ||
oc patch --type=merge --patch='{"spec":{"paused":true}}' machineconfigpool/${node_type} | ||
|
||
# Apply machine configs | ||
echo "Applying machine configs..." | ||
oc create -f assets/post-install/*-${node_type}.yaml | ||
|
||
# Enable auto reboot | ||
oc patch --type=merge --patch='{"spec":{"paused":false}}' machineconfigpool/${node_type} | ||
|
||
echo "Rebooting nodes..." | ||
# This sleep is required because the machine-config changes are not immediate | ||
sleep 30 | ||
|
||
# The 'while' is required because in the process of rebooting the masters, the | ||
# oc wait connection is lost a few times, which is normal | ||
while ! oc wait mcp/${node_type} --for condition=updated --timeout 600s ; do sleep 1 ; done | ||
done | ||
} | ||
|
||
create_bridge | ||
apply_mc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: machineconfiguration.openshift.io/v1 | ||
kind: MachineConfig | ||
metadata: | ||
labels: | ||
machineconfiguration.openshift.io/role: master | ||
name: 99-brext-master | ||
spec: | ||
config: | ||
ignition: | ||
version: 2.2.0 | ||
storage: | ||
files: | ||
- contents: | ||
source: data:text/plain;charset=utf-8;base64,${interface_content} | ||
filesystem: root | ||
mode: 0644 | ||
path: /etc/sysconfig/network-scripts/ifcfg-${interface} | ||
- contents: | ||
source: data:text/plain;charset=utf-8;base64,${bridge_content} | ||
filesystem: root | ||
mode: 0644 | ||
path: /etc/sysconfig/network-scripts/ifcfg-${bridge} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This directory hosts machine-config objects that will be applied in an | ||
alphabetically sorted list after a successful installation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DEVICE=${bridge} | ||
NAME=${bridge} | ||
TYPE=Bridge | ||
ONBOOT=yes | ||
NM_CONTROLLED=yes | ||
BOOTPROTO=dhcp | ||
BRIDGING_OPTS=vlan_filtering=1 | ||
BRIDGE_VLANS="1 pvid untagged,20,300-400 untagged" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEVICE=${interface} | ||
BRIDGE=${bridge} | ||
ONBOOT=yes | ||
NM_CONTROLLED=yes | ||
BOOTPROTO=none |