Skip to content

Instantly share code, notes, and snippets.

@sallyom
Last active August 22, 2016 14:25
Show Gist options
  • Save sallyom/13b8036b9818eb621bf4dcf21a998c1e to your computer and use it in GitHub Desktop.
Save sallyom/13b8036b9818eb621bf4dcf21a998c1e to your computer and use it in GitHub Desktop.

online-up

4 Steps to Start an OpenShift Online All-In-One Cluster:

(for testing and development) Until this 'devenvup' branch is merged with 'master', create a local cloned 'sallyom/devenvup' branch OR just copy Vagrantfile , hack/online-up.sh and the devenvup directory and contents to whatever local branch of 'online' you want. i.e. Those are the only differences between this branch and master.

First, to get set up for ssh with your ec2 instance, add libra.pem to the ssh-agent locally

  1. Add this repository to your remotes in your online repository and checkout the devenvup branch OR just copy Vagrantfile, hack/online-up.sh and devenvup directory to your local online repo.
  • Fill in all variables in online/devenvup/example_online_env and change to devenvup/online_env.
  • Run $ ./hack/online-up.sh
  • vagrant ssh and then /data/src/github.com/openshift/online/devenvup/cluster_up_and_beyond.sh
hack/online-up.sh usage:

Requires 2 arguments or 0 arguments:
1) ose|origin -> repository to build OpenShift from, enter no argument for default origin v1.3.0-alpha.3
2) subdomain to configure router -> enter 'default' or no argument to use '<PUBLIC_IP>.xip.io'.  Cluster
components will be reachable at 'http://<component>-<project-name>.subdomain'.  If using a subdomain 
other than 'default' you should have a local nameserver such as dnsmasq running.  

EXAMPLE 1) './hack/online-up.sh' -> this will build from locally checked out origin branch
(default if 'origin' not found locally or if local branch is 'master', and the default router subdomain 
will be configured.

EXAMPLE 2) './hack/online-up.sh ose default' -> this will build OpenShift from ose (whatever branch is 
checked out locally) and the default router subdomain will be configured.

EXAMPLE 3) './hack/online-up.sh origin someotherdomain.com' -> this will build from locally checked out 
origin branch or default origin branch, and the router will be configured with 'someothersubdomain.com.
 $ vagrant ssh from your online directory to access the VM.

 To access the console, go to aws console and check all security groups, and go to
 https://:8443/console
 If you want to edit the code or configs and re-run the scripts just:
 $ cd /data/src/github.com/openshift/online
 $ ./devenvup/cluster_up_and_beyond.sh
 
 The cluster up script tears down any existing cluster but if you want to run the teardown script:
 $ ./devenvup/teardown_cluster.sh
 
Note: '/devenvup/pull_install.sh' can also be re-run or edited to pull images from wherever you want;
as is, it pulls component images from registry.ops.openshift.com and builds the openshift commands.

Wait, You Don't Use Vagrant?? Follow these steps then and you'll still get your Online All-In-One!! [Non-Vagrant set-up] (https://docs.google.com/a/redhat.com/document/d/17TdGnUPcEx4-UK9HTyd1VhvB_KDn9H_OWXrvF3L3Uik/edit?usp=sharing)

That's it! Read below while you are waiting for the script to complete :)

The set-up takes ~15 mins, but when it completes you'll have a running 'OpenShift Online All-In-One Cluster' running in AWS that has:

  • Your local online repo/branch cloned
  • OpenShift 3.1 'origin' branch checkout out
  • Internal registry deployed
  • Online volume-provisioner deployed
  • Online user-analytics pod deployed
  • Online custom router launched
  • Various config changes in '/openshift.local.config/master/master-config.yaml'
  • Online-specific user-roles --NOT CURRENTLY IMPLEMENTED
  • Online accountant pod deployed
  • Online-specific ui-extensions
  • Online-specific project-request template --NOT CURRENTLY
  • Online-specific openshift-scripts, templates created
  • OpenShift logs located in /data/src/github.com/openshift/online/startup.log

Notes:

  • In your VM, your current local branch of online repo is located at /data/src/github.com/openshift/online.

  • In your VM, the master-config.yaml is located at /openshift.local.config/master/master-config.yaml

  • To clean up your All-In-One Online cluster and start a new All-In-One Online cluster, run /data/src/github.com/openshift/online/devenvup/teardown_cluster.sh.

  • If you re-run cluster_up_and_beyond.sh, it runs the teardown_cluster.sh for you. If you run any other openshift start command, you'll want to run ./teardown_cluster.sh first. Note the cleanup script deletes the config directory. You should keep a working copy of master-config.yaml in /data/src/github.com/openshift/online/devenvup/master-config.yaml because that is where cluster_up_and_beyond.sh looks for the config file.

  • In your VM, KUBECONFIG=/openshift.local.config/master/admin.kubeconfig. This is because it is set up with the vagrant-openshift plugin.

Notes on files:

hack/online-up.sh

  • Requires either 2 arguments or 0 arguments, see box below for usage.
  • Uses Vagrant to start an ec2-instance:
    • rhel7 base image (ami-68fb7d7f)
  • Tags Vagrant instance with $USER-online-dev
  • Sets up online, ose and origin repos.
  • Executes online/devenvup/clone-checkout.sh and online/devenvup/pull_install.sh.

devenvup/clone-checkout.sh

  • Clone your local working branch of the online repository and checkout the branch in VM.
  • Clone local 'ose' repository in VM, if it exists locally.
  • If building OpenShift from 'origin', checkout local origin tag in VM. If local branch is 'master', branch 'v1.3.0-alpha.3' will be checked out, because that is what OpenShift Online is currently using.
  • If you want to build from origin 'master', simply comment out Line #s 53-55 in this file.
  • Finally, this script builds OpenShift from 'ose' or 'origin' from either locally checked out branches or the default branches.

devenvup/pull_install.sh

  • Installs openshift-scripts-online rpm.
  • Pulls Online component images from ops registry.
  • Builds oc, oadm and openshift cmds.

devenvup/cluster_up_and_beyond.sh

  • Places Online-configured master-config.yaml maintained in this repo in /data/src/github.com/openshift/origin/_output/local/bin/linux/amd64/openshift.local.config/master.
  • Starts OpenShift server in a container with the Online-configured master-config.yaml.
  • Starts local registry for the cluster.
  • Starts a dnsmasq container for the cluster
  • Loads Online image streams and templates and ui-extensions
  • Deploys, launches, builds Online-specific components.

devenvup/teardown_cluster.sh

  • Stops/removes All-In-One cluster, dnsmasq container and all openshift containers and restores /etc/resolv.conf so you can re-run cluster_up_and_beyond.sh or openshift start.

Final Notes:

  • vagrant ssh from online directory to ssh into Vagrant aws instance.

  • After online-up.sh completes, $vagrant ssh and run $oc get pods in each project to see what's running.

  • You don't have permission to 'vagrant destroy' in AWS. So, to delete your AWS vagrant instance do the following:

    • rm -rf .vagrant
    • rm .vagrant-openshift.json
    • in AWS console, edit 'Name' ($USER-online-dev) to 'terminate' and stop the instance.
    • Now you are ready to run $.hack/online-up.sh again!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment