Practice 12 - Introduction Openshift
In this Practice session you will work with OpenShift. Using OpenShift, you learn to create applications and manage them. Red Hat® OpenShift® is an enterprise-ready Kubernetes container platform with full-stack automated operations to manage hybrid cloud, multicloud, and edge deployments. Red Hat OpenShift is optimized to improve developer productivity and promote innovation https://www.redhat.com/en/technologies/cloud-computing/openshift.
References
- OpenShift https://docs.openshift.com/
- ManageIQ https://www.manageiq.org/
Exercise 12.1. Setting up OpenShift!
In this task we will learn how to use managed OpenShift servcie by RedHat Inc,. However, it can be installed using MiniShift- which is OpensShift dev environment for developers https://www.okd.io/minishift/
- Open the weblink https://www.openshift.com/try and Click on Developer Sandbox/Try it.
- Create an account by going through all the required steps and finally should see similar windows as below(!!Choose DevSandBox account).
- Get familiar with Administrator and Developer Tabs
- Administrator tab
- Developer tab, It contains several other subtabs as like below:
- Topology : Topology helps nicely to understand your applications progress and relationship between servcies.(Note!! As of now, you will not see any applications in your topology window)
- Developer tab, It contains several other subtabs as like below:
- Monitoring: It helps to display your current CPU and memory usage of your applications and also to query your metrics and alerts using PromoQL
Like wise, you can have look at all the other subtabs and get familiar.
Exercise 12.2. Creating your first application on OpenShift!
In this task we will create a sample application using OpenShift Dashboard. In this task, we will use in-built guided tour to create a application.
- Click on Add-->View all Quickstarts--> Click on Start tour on Get Started with Sample Application
- Here, we will follow the guided tour to create sample node-js application. It has following steps to complete:
- Create Sample application - Provide your name as an application name.
- View build status
- View the associated git repo
- View the pod status
- Run the sample application- You will see the Node-js welcome page
- Take the screenshot of Topology with your application running and your application name should be visible clearly.
Exercise 12.3. Deploying application on OpenShift using existing docker image!
In this task, you are going to deploy existing docker image in an OpenShift environment and run your application.
- Create a your own docker image with a flask application as you performed this experiment in Practical 2 and push to your docker hub(!!Note You can use existing flask docker image from Practical 2).
- Now, in OpenShift environment click on Add-->Container Image and fill the details accordingly as shown below:
- You need add routing port number, to do that click on Routing which is downside of the window. In that add Targetport-->5000 (This is required because, flask runs at default port number 5000 )
- You can view the deployment in topology view and click to view your application running as shown below:
Take the screenshot of application running web page.
- Optional tasks
- Adding health checks to your application
- Monitoring your applications
Exercise 12.4. Advanced application deployment on OpenShift!
In this task you will deploy two services namely influxdb and grafana. This use case is similar to the IoT use case done in pervious experiment. The custom IoT data is generated using curl and than its inserted in to influxdb and can be accessed in grafana.
- Now we will deploy influxdb
- Click on Add-->Container Image (Note!! if your facing issue in accessing docker hub account with error too may requests , it can solved by creating a image pull secret similarly as done in Lab 2)
- Provide Image name from external registry as
influxdb:1.8
- In General-->Application name, enter as
iot
or any custom name - In General-->name, enter
influxdb
- In Resources, click on Deployment
- In Advanced options, click on Deployment and create environment variables
- NAME= INFLUXDB_USER VALUE= myuser
- NAME=INFLUXDB_USER_PASSWORD VALUE= mypassword
- NAME=INFLUXDB_DB VALUE=mydatabase
- Click on create and wait for few seconds and it will be redirected to topology window
- Now we will deploy Grafana
- Click on Add-->Container Image
- Provide Image name from external registry as
grafana/grafana
- In General-->Application name, enter as
iot
or any custom name - In General-->name, enter
grafana
- In Resources, click on Deployment
- Click on create and wait for few seconds and it will be redirected to topology window
- Now log into grafana using dashboard and setup inflxudb
- In topology window, click on grafana service and open the application URL
- Login with Username as
admin
and Password asadmin
and skip for password update - Click on settings and click on add source,
- Enter Name--> influxdb and Query language --> InfluxQL
- In HTTP, URL--> http://INFLUXDB_URL:80 and leave AUTH as default
- In InfluxDb details , update Database, User and password fields and the whole configuration look like
- Login with Username as
- In topology window, click on grafana service and open the application URL
- Click on Save and Test
- Pushing the data to influxdb
- Run the following python script to generate random data Attach:test.py
- Make sure you update the script before running:
- Update the DB name from
mydatabase
, if you changed it in previous step - Update the request URL so that it contains your InfluxDB url, but keep the
/write
path at the end!
- Run the following python script to generate random data Attach:test.py
- Finally, create a dashboard in grafana and visualize the results
- Create dashboard with following queries to display battery data
- Create dashboard with following queries to display temp data
- Final dashboard looks like as shown below:
- Take the screenshot of grafana dashboard and Topology window.
Bonus Task
- Deploy a ManageIQ using docker container and configure a microk8s cluster in a openstack VM instance
- Integrate microk8s container provider in ManageIQ
- Deploy a sample application with your name(could be flask/Django or runtime of your choice)
- Capture the screen shot of ManageIQ showing overview of container platform.
- Capture the screenshot of application running.
Following web links can used: https://www.manageiq.org/docs/get-started/docker.html , https://www.section.io/engineering-education/installing-k8-ubuntu-server/
Deliverables:
- Screenshots from tasks 12.2, 12.3 and 12.4
- Web link of your application deployed in 12.3,12.4
- Answer the following questions:
- What is template in OpenShift ? and provide an example for existing templates.
- Which features of OpenShift you liked most and mention why you liked it?
- Write one difference between OpenShift and ManageIQ.
In case of issues, check these potential solutions to common issues:
- If your OpenShift pod does not launch and you see an error about too many requests and pull rate limit, you may need to define credentials for your dockerHub account.
- You can add it by going to:
Secrets -> Create -> Image pull secret
and filling information about your DockerHub account similarly to how we did it in Lab 2
- You can add it by going to:
- Deployes service no longer working later
- OpenShift Sandbox will undeploy your Service pods 8 hours after inactivity.
- You can change the number of deployed Pods back from 0 to 1 to restore the service state.