/single-node-openshift-azure-tutorial

How to setup a simple, single-node OpenShift demo on Azure, ready for other workloads.

Primary LanguageMakefile

**I have modified this from jameread/single-node-openshift-azure-tutorial to cover issues I encountered during deployment and also draw out examples of how to install other Openshift Versions. The original guide is based off RHEL 7.6 which at writing is currently out of date, and should be updated to cover RHEL 8.x. Additionally the original guide deploys version 3.11 of OpenShift. This guide will also explain how to change this version if desired.

single-node-openshift-azure-tutorial

1. What is this?

This simple tutorial/demo script will talk you through the creation of a single virtual machine (node) on Azure that is running OpenShift. It will use the "oc cluster up" mechanism to deploy OpenShift, which is great just for demos, labs, and that sort of thing.

This would not be the recommended way for a production deployment of OpenShift on Azure. If you want to learn more about that, then check out this repository instead; http://aka.ms/openshift

This is community documentation - not official Red Hat documentation or guidance.

1.1. What do I need before I get started?

  1. A working Azure account with at least $50 credit.

  2. Access to Red Hat OpenShift Container Platform subscriptions (NFRs, or lab repositories).

Note
This lab would also work with OKD (community OpenShift), but the instructions and repositories would be a little different. Unfortunately you are on your own if you want to try OKD!

1.2. What will I do in this tutorial?

  1. You’ll need a working Azure subscription and portal login to complete this.

  2. Create a Azure RHEL virtual machine and connect to it with SSH.

  3. Enable the OpenShift repositories.

  4. Configure Docker, and start a simple "all in one" OpenShift environment.

  5. Profit! …​ and then run more exciting OpenShift workloads on Azure ;-)

This lab should between 20-30 minutes to complete.

Note
Instructions may be deliberately brief, encouraging you to look into the answer a little yourself. Don’t be upset if some steps take you a little longer to find or fix, but do ask for help if you get stuck too long!

2. Provision a RHEL virtual machine from the marketplace

Naviate to the Azure Marketplace;

marketplaceRhel

Provision a new RHEL 7.x machine. Use the latest version of RHEL available (7.6 at the time of writing). Use common sense details for the VM hostname, etc.

  • Authentication Type: You should use a SSH key if you have one, otherwise, create a strong password!

  • Resource Group: Create new: openshift_occlusterup

  • Region: Use a region that is near to you!

provisioningDialog

2.1. Sizing

OpenShift in this environment will run quite happily on 2x CPUs and 8Gb/RAM, but 4x CPUs and 16GB RAM is a lot nicer. If you have the credits available, this lab recomments using a D4s_v3 sized virtual machine on Azure.

2.2. Disks

Use managed disks if prompted. OpenShift will work just find with a Standard HDD storage, but if you have the credits available, select a Premium SSD. A 16Gb Disk will be enough for this environment.

2.3. Start the provisioning, and wait for it to complete

waitForProvisioning

When complete, go and find the virtual machine;

provisioningComplete

2.4. Set a DNS name

When the virtual machine has been provisioned, set a DNS name in the virtual machine overview and take a note of the public IP address in your notes.

dnsName

2.5. Edit the Network Security Groups, and add a few basic rules;

Port 8443, 22, and 80 should be open. You should add these as inbound ports in the network security group.

nsg

2.6. SSH into your VM

Use your favorite SSH client (if you’re on Windows, download PuTTY) to connect to the OpenShift virtual machine. You need to use the username and ssh key/password specified during the provisioning process.

Get ready for some OpenShifting :-)

3. Prepare the machine for OpenShift

3.1. Become root

All instructions in the rest of the lab guide require root access, and to be in the root home directory.

sudo su
cd /root/

3.2. Disconnect from Red Hat Update Infrastructure;

RHEL machines provisioned from the marketplace come connected to Red Hat Update Infrastructure. However, Red Hat Update Infrastructure is for RHEL only, not OpenShift.

rpm -e rhui-azure-rhel7

3.3. Configure OpenShift repositories

In the next section, choose Option A or Option B. Don’t do both :-)

3.3.1. Option a) If you have a working Red Hat subscription;

subscription-manager register
Username: …
Password: …

Find a pool ID with OpenShift, and make a note of the pool ID.

subscription-manager list --available

Attach to this pool;

subscription-manager attach --pool=...

Disable all default repos, and then attach to the required repos.

subscription-manager repos --disable '*'
subscription-manager repos --enable 'rhel-7-server-rpms'
subscription-manager repos --enable 'rhel-7-server-extras-rpms'
subscription-manager repos --enable 'rhel-7-server-ose-3.11-rpms'

The rhel-7-server-ose-3.11-rpms covers the RPMs to install OpenShift 3.11, substitute this with the below if you want to deploy a different version.

If the above repos do not show up, enter the below commands: subscription-manager register subscription-manager refresh subscription-manager attach --auto

3.3.2. Option b) If you have a repository provided by your lab administrator;

cd /etc/yum.repos.d/
wget http://YOUR-ADDRESS-HERE.cloudapp.azure.com/repos/lab.repo

3.4. Install the oc client, Docker and Git

yum install atomic-openshift-clients docker git -y

3.5. Enable port 8443 in the Linux firewall;

Port 8443 is for the OpenShift Web Administration console. Port 80 is for your web application containers.

firewall-cmd --add-port 80/tcp --permanent
firewall-cmd --add-port 8443/tcp --permanent
firewall-cmd --reload

4. Setup Docker

4.1. Insecure registries

Add the insecure registry options in the docker configuration file /etc/docker/daemon.json;

{ "insecure-registries": ["172.30.0.0/16"] }
Note
Do not change the IP address of the insecure-registries, leave it as default - 172.30.0.0. This is the IP Network address of the docker0 interface on your virtual machine.

Make docker start on boot, and then start it manually;

systemctl enable docker
systemctl start docker

4.2. Login to the Red Hat Container Registry

In the next section, choose Option A or Option B. Don’t do both :-)

4.2.1. Option a) If you have a working Red Hat user and login

docker login https://registry.redhat.io
Username: ...
Password: ...

4.2.2. Option b) If you have a registry login file provided by your lab administrator

Instructions not yet written for this!

5. Start and Login to OpenShift

5.1. Start OpenShift

Make sure you are in the root home directory before continuing;

cd /root/

We’re going to run OpenShift, running inside a container. It will take about 10 minutes to come up and should be fully automatic.

oc cluster up --enable '*,automation-service-broker,service-catalog,template-service-broker' --public-hostname=<yourPublicIpAddress/publicFqdn> --routing-suffix=<FqdnExcludingFirstComponent>

Note: You must use a valid DNS name (or IP address with nip.io) or the cluster may hang trying to contact itself when starting.

5.2. Login to the web interface

Have a little look around ;-) You can login as developer with any password.

openshiftLogin

6. Optional Azure tasks;

These tasks are optional. You can skip over this section if you like.

6.1. Add .NET support from CentOS

On the virtual machine, enter this command;

oc cluster add centos-imagestreams

6.2. Service Broker for Azure

Installing the Open Service Broker for Azure is a 2-step process. The first step is getting a service principal, the second issue is then installing the service broker.

6.2.1. Create a service principal

A service broker is like a "username and password" to have admin access for Azure.

6.2.2. Install the service broker

Install the service broker using instructions from here;

7. What can I try now?

  1. Deploy php-ascii-pets; https://github.com/jamesread/php-ascii-pets.git

  2. If you know quite a lot about OpenShift already, but not Azure, start from challenge #7; https://github.com/palma21/openshiftlab#challenge—​7-monitoring-openshift-with-azure-oms

  3. If you know quite a lot about Azure already, but not OpenShift, start from challenge #2; https://github.com/palma21/openshiftlab#challenge—​2-create-and-manage-projects

  4. .NET and Azure focussed OpenShift demo; https://github.com/city-holidays-on-openshift-azure

  5. If you fancy a challenge; https://github.com/jbossdemocentral/coolstore-microservice

8. Troubleshooting?

If you made a mistake when running oc cluster up, you need to follow the below to correct it: 1. oc cluster down 2. Go to /root and remove openshift.local.clusterup - this is important and previous config will be mixed in with your re-deployment. 3. Re run oc cluster up with needed parameters.