Skip to content

Instantly share code, notes, and snippets.

@awgreene
Last active June 20, 2019 20:48
Show Gist options
  • Save awgreene/f7b0f10124a11034bd7b19f5f08b360e to your computer and use it in GitHub Desktop.
Save awgreene/f7b0f10124a11034bd7b19f5f08b360e to your computer and use it in GitHub Desktop.
This script downloads and runs the OpenShift installer associated with the provided tag.
#!/bin/bash
# This script downloads and runs the OpenShift installer associated with the provided tag.
echo 'Select a tag from https://openshift-release.svc.ci.openshift.org to download and run...'
read -p 'Openshift Tag: ' TAG
oc adm release extract --command=openshift-install registry.svc.ci.openshift.org/ocp/release:$TAG
export DIR_NAME=cluster-0
export LOG_LEVEL=debug
echo 'Cleaning workspace...'
rm -rf $DIR_NAME
mkdir $DIR_NAME
cp install-config.yaml ./$DIR_NAME/install-config.yaml
echo 'Starting installer...'
./openshift-install create cluster --dir $DIR_NAME --log-level $LOG_LEVEL
@awgreene
Copy link
Author

awgreene commented Jun 3, 2019

Using the OpenShift Installer

Prereqs:

Docker:

You must have the docker daemon running on your machine. If you do not, download docker by executing the following steps:

$ sudo dnf install docker
$ sudo systemctl start docker
$ sudo systemctl enable docker
$ sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker && newgrp docker

Make sure that docker works with docker ps.

AWS Account

You must have valid AWS credentials.

Configuring your Installer

  1. Create and move to an installer directory:
$ mkdir -p ~/dev/openshift/installer
$ cd ~/dev/opneshift/installer
  1. Login to https://api.ci.openshift.org/ and upper right corner you'll see the ? dropdown to Command Line Tools that'll give you an oc login command to cp/paste in your terminal. Run that command.
  2. Login to registry.svc.ci.openshift.org by running the following command after replacing <YOUR_API_CI_NAME> with the first part of your redhat email. Example: agreene in agreene@redhat.com:
$ export YOUR_API_CI_NAME=<YOUR_API_CI_NAME>
$ docker login -u $YOUR_API_CI_NAME -p $(oc whoami -t) registry.svc.ci.openshift.org
  1. Download part of your pull secret with the following command:
$ oc registry login --to=reg-svc-ps.yaml
  1. Visit https://cloud.redhat.com/openshift/install/aws/upi and create an account. Then download your pull secret and name the file openshift-pull-secrets.yaml and place the file in ~/dev/openshift/installer. Add the auth from reg-svc-ps.yaml to openshift-pull-secret.yaml. Remove all whitespaces and then confirm that it is valid json at https://jsonlint.com.
  2. Download the installer by visiting https://openshift-release.svc.ci.openshift.org/ and copying a green name. Then run:
$ export TAG=<GREEN NAME>
$ oc adm release extract --command=openshift-install registry.svc.ci.openshift.org/ocp/release:$TAG
  1. Run ./openshift-install create install-config
  2. Copy and paste the script above into ~/dev/openshift/installer/automated-openshift-installer.sh.

With this, you can now run the script above to deploy any tagged version of openshift.

Running the script

Simply run the following command and specify the image from https://openshift-release.svc.ci.openshift.org/ :

$ ~/dev/openshift/installer/automated-openshift-installer.sh

After two days, a reaper will kill your OpenShift Cluster. Run the following command to ensure that all resource have been cleaned up:

$ export DIR_NAME=cluster-0;export LOG_LEVEL=debug;
$ ./openshift-install destroy cluster --dir $DIR_NAME --log-level $LOG_LEVEL

You can then rerun the install script above.

Troubleshooting

If you see the following error when running the installer:

ERROR Error: Error applying plan:
ERROR
ERROR 1 error occurred:
ERROR     * module.dns.aws_route53_record.api_external: 1 error occurred:
ERROR     * aws_route53_record.api_external: [ERR]: Error building changeset: InvalidChangeBatch: [Tried to create resource record set [name='api.vnarsing.devcluster.openshift.com.', type='A'] but it already exists]

Then complete the following steps:

  1. Login to https://console.aws.amazon.com/route53/
  2. Click the hosted-zones tab on the left.
  3. Click any checkbox and then click the Go To Record Sets button.
  4. Enter the name of your cluster in the search bar.
  5. Delete the record sets associated with your cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment