-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add systemd services for configuration after start
this adds 4 small systemd services that: - creates crc specific configurations for dnsmasq - sets a new uuid as cluster id - creates the pod for routes-controller - tries to grow the disk and filesystem - checks if the cluster operators are ready
- Loading branch information
Showing
12 changed files
with
189 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
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
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,12 @@ | ||
[Unit] | ||
Description=CRC Unit checking if cluster is ready | ||
After=kubelet.service | ||
Requires=kubelet.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/bin/crc-cluster-status.sh | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,43 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
export KUBECONFIG=/opt/kubeconfig | ||
|
||
function check_cluster_unhealthy() { | ||
WAIT="authentication|console|etcd|ingress|openshift-apiserver" | ||
|
||
until `oc get co > /dev/null 2>&1` | ||
do | ||
sleep 2 | ||
done | ||
|
||
for i in $(oc get co | grep -P "$WAIT" | awk '{ print $3 }') | ||
do | ||
if [[ $i == "False" ]] | ||
then | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
# rm -rf /tmp/.crc-cluster-ready | ||
|
||
COUNTER=0 | ||
CLUSTER_HEALTH_SLEEP=8 | ||
CLUSTER_HEALTH_RETRIES=500 | ||
|
||
while $(check_cluster_unhealthy) | ||
do | ||
sleep $CLUSTER_HEALTH_SLEEP | ||
if [[ $COUNTER == $CLUSTER_HEALTH_RETRIES ]] | ||
then | ||
return 1 | ||
fi | ||
((COUNTER++)) | ||
done | ||
|
||
# need to set a marker to let `crc` know the cluster is ready | ||
# touch /tmp/.crc-cluster-ready | ||
|
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,14 @@ | ||
[Unit] | ||
Description=CRC Unit for configuring dnsmasq | ||
Requires=ovs-configuration.service | ||
After=ovs-configuration.service | ||
Before=dnsmasq.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecCondition=/usr/bin/bash -c "/usr/bin/ping -c1 gateway && echo 1 || echo 0" | ||
ExecStart=/usr/local/bin/crc-dnsmasq.sh | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,20 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
hostName=$(hostname) | ||
ip=$(ip -4 addr show br-ex | grep -oP '(?<=inet\s)192+(\.\d+){3}') | ||
iip=$(hostname -i) | ||
|
||
cat << EOF > /etc/dnsmasq.d/crc-dnsmasq.conf | ||
listen-address=$ip | ||
expand-hosts | ||
log-queries | ||
local=/crc.testing/ | ||
domain=crc.testing | ||
address=/apps-crc.testing/$ip | ||
address=/api.crc.testing/$ip | ||
address=/api-int.crc.testing/$ip | ||
address=/$hostName.crc.testing/$iip | ||
EOF | ||
|
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,13 @@ | ||
[Unit] | ||
Description=CRC Unit starting routes controller | ||
After=kubelet.service | ||
Requires=kubelet.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecCondition=/usr/bin/bash -c "/usr/bin/ping -c1 gateway && echo 1 || echo 0" | ||
ExecStart=/usr/local/bin/crc-routes-controller.sh | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
export KUBECONFIG=/opt/kubeconfig | ||
|
||
retry=0 | ||
max_retry=20 | ||
until `oc get pods > /dev/null 2>&1` | ||
do | ||
[ $retry == $max_retry ] && exit 1 | ||
sleep 5 | ||
((retry++)) | ||
done | ||
|
||
oc apply -f /opt/crc/routes-controller.yaml | ||
|
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,12 @@ | ||
[Unit] | ||
Description=CRC Unit setting random cluster ID | ||
After=kubelet.service | ||
Requires=kubelet.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/bin/ocp-clusterid.sh | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
export KUBECONFIG="/opt/kubeconfig" | ||
uuid=$(uuidgen) | ||
|
||
retry=0 | ||
max_retry=20 | ||
until `oc get clusterversion > /dev/null 2>&1` | ||
do | ||
[ $retry == $max_retry ] && exit 1 | ||
sleep 5 | ||
((retry++)) | ||
done | ||
|
||
oc patch clusterversion version -p "{\"spec\":{\"clusterID\":\"${uuid}\"}}" --type merge |
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,10 @@ | ||
[Unit] | ||
Description=CRC Unit to grow the root filesystem | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/bin/ocp-growfs.sh | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,11 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
root_partition=$(/usr/sbin/blkid -t TYPE=xfs -o device) | ||
/usr/bin/growpart "${root_partition#?}" "${root_partition#/dev/???}" | ||
|
||
rootFS="/sysroot" | ||
mount -o remount,rw "${rootFS}" | ||
xfs_growfs "${rootFS}" | ||
#mount -o remount,ro "${rootFS}" |