Skip to content

Instantly share code, notes, and snippets.

@kairen
Created June 15, 2023 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kairen/f337c054dd9d27eadf26567eadd95810 to your computer and use it in GitHub Desktop.
Save kairen/f337c054dd9d27eadf26567eadd95810 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
FORCE_CLEAN_UP=${FORCE_CLEAN_UP:-"false"}
ONLY_CLEAN_UP=${ONLY_CLEAN_UP:-"false"}
RELEASE_PATH=${RELEASE_PATH:-"/var/www/html/ignition/hub"}
PULL_SECRET_PATH=${PULL_SECRET_PATH:-"./pull-secret.json"}
SSH_KEY_PATH=${SSH_KEY_PATH:-"${HOME}/.ssh/id_rsa.pub"}
export DOMAIN_NAME=${DOMAIN_NAME:-"ocplab.k2rb.com"}
export CLUSTER_NAME=${CLUSTER_NAME:-"hub"}
export CLUSTER_CIDR=${CLUSTER_CIDR:-"1.128.0.0/14"}
export SERVICE_CIDR=${SERVICE_CIDR:-"172.24.0.0/16"}
if [[ "${FORCE_CLEAN_UP}" == "true" ]]; then
echo "===> Clean up caches & release files."
rm -rf *.ign metadata.json .openshift_install* auth manifests openshift tmp
rm -rf ${RELEASE_PATH}/*.ign
echo "==> Done."
fi
if [ "${ONLY_CLEAN_UP}" != "true" ]; then
if [ ! -d "./auth" ] && [ ! -d "./.openshift_install*" ]; then
echo "===> Generate and move ignition files."
export PULL_SECRET=$(cat ${PULL_SECRET_PATH})
export SSH_KEY=$(cat ${SSH_KEY_PATH})
envsubst < install-config.yaml.bak > install-config.yaml
mkdir -p tmp
cp -rp install-config.yaml tmp/install-config.yaml
openshift-install create manifests
sed -i 's/mastersSchedulable: true/mastersSchedulable: false/g' manifests/cluster-scheduler-02-config.yml
butane ./butanes/99-master-timesync.bu -o manifests/99-master-timesync-configuration.yaml
butane ./butanes/99-worker-timesync.bu -o manifests/99-worker-timesync-configuration.yaml
ls -la manifests
openshift-install create ignition-configs
mv *.ign ${RELEASE_PATH}/
chmod 755 ${RELEASE_PATH}/*.ign
echo "==> Done."
echo "===> Check ignition files in release path."
ls -la ${RELEASE_PATH}
else
echo "Config has been generated! Set FORCE_CLEAN_UP as \"true\" for re-generating."
fi
fi
#!/bin/bash
set -eux
openshift-install wait-for bootstrap-complete --log-level=debug
openshift-install wait-for install-complete --log-level=debug
#!/bin/bash
set -eux
export KUBECONFIG=auth/kubeconfig
oc get csr -o go-template='{{range .items}}{{if not .status}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}' | xargs oc adm certificate approve
#!/bin/bash
set -eux
CLUSTER_NAME=$(cat metadata.json | jq -r .clusterName)
cat <<EOF > ${HOME}/${CLUSTER_NAME}.rc
export KUBECONFIG=${PWD}/auth/kubeconfig
echo "kubeadmin password: \$(cat ${PWD}/auth/kubeadmin-password)"
EOF
chmod u+x ${HOME}/${CLUSTER_NAME}.rc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment