Document For Openshift
Document For Openshift
Openshift SETUP :
Modes of Deployment:
1. All-in-one:
Master node & Worker node will be deployed in same system.
Used in Development environment.
2. Single Master:
In this, One single master will manage all the worker nodes.
3. Multiple Master:
Multiple master nodes will manage multiple worker nodes.
Used in Production environment.
Target Environments for Deployment:
On-Premise (Virtual Machine)
On cloud
Management Tools:
Openshift Webconsole – direct way to interact with openshift to manage our
applications. By default, it runs on 8443 port.
https://<openshift-ip>:8443/console
Openshift CLI – Using commands we interact with Openshift
Openshift Rest API – to interact with third-part applications.
Openshift Vs Kubernetes:
Although plain Kubernetes and OpenShift provide the same core orchestration features for
containers, there are several differences between plain Kubernetes and the Kubernetes
implementation that is built into OpenShift.
https://www.whizlabs.com/blog/openshift-vs-kubernetes/
Builds in Openshift:
A build in OpenShift is the process of transforming input parameters into a resulting
object. Most often, builds are used to transform source code into a runnable
container image.
A build configuration, or BuildConfig, is characterized by a build strategy and one or
more sources. The strategy determines the aforementioned process, while the
sources provide its input.
Build strategies:
Source-to-Image (S2I): Produces ready-to-run images by injecting application
source into a container image and assembling a new image.This is the most popular
build strategy used in Openshift.
Docker: Invokes the “docker build” command taking Dockerfile as input to produce
a runnable image.
Pipeline: Defines a Jenkins pipeline for execution
Custom: Define a specific builder image. Can use our own builder image to
customize our build process.
Openshift Online:
To use Openshift online plaform, take subscription to Redhat community and then
take subscription to Openshift online platform.
Note: Use compatible version of CLI tool with online openshift platform, to avoid
compatible issues. Used oc CLI version: 4.2
https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.2/
Using oc CLI,
NOTE: If developer is unable to add as admin, create a new user with any name and
add the same admin policies for that user.
Docker Build:
Deployed Python Application in Openshift Online platform using source code and
Dockerfile from github as:
https://github.com/AmruthaInnamuri/PythonAppConfigFiles
3. Then create service for that deploymentconfig and then create a route for that service
to access externally.
https://github.com/AmruthaInnamuri/DeploymentConfigWithImage
$ oc new-project SampleJava
NOTE: As openshift online platform provides limited resources, could not run java
application due memory insufficiency issue. Then shifted to Minishift.
Fabric8 -maven-plugin:
fabric8-maven-plugin helps in deploying Java applications on Openshift.
OpenShift resource descriptors can be created or generated from fabric8:resource.
$ mvn fabric8:resource
MINISHIFT:
Minishift is a tool that helps you run OpenShift locally by launching a single-node
OpenShift Origin cluster inside a virtual machine. You can run Minishift on Windows, Mac
OS, and GNU/Linux operating system.
Installation on Windows:
1. Install VirtualBox (Used version-- 6.1.4)
2. Install latest minishift (Used version—1.34.1)
3. Start Minishift using virtualbox
Goto cmd and change directory where minishift is downloaded and type:
Use the first line of output SET command, copy and paste it in cmd. Then you can
use oc commands.
6. Login as “developer” using oc CLI
$ oc login https://<minishift-ip>:8443 --token=<token-id>
NOTE: token-id will be user specific and is unique one.
7. Provide admin-privileges to “developer” inorder to avoid git connectivity and
authorization issues.
8. To get docker related info which is inbuilt in minishift
$ minishift docker-env
9. To use inbuilt docker of minishift
$ minishift ssh
Adding registry-route in Minishift:
1. In minishift cmd, check addons list
Here in pom.xml,
o Used docker host as https://<minishift-ip>:2376
o Used default certs prvided by minishift in certpath.
3. Create a new project through oc CLI
$ oc new-project sampleproject
4. Create a new imagestream
$ oc create new is sampleimg
5. Now tag docker image created with newly created imagestream in docker prompt as:
$ sudo docker tag <docker-image>:tag
<docker-registry-url>/<project-name>/<imagestream-name>:tag
6. Now push the imagestream into openshift docker registry, to create deployments and
pods in minishift.
$ sudo docker push <docker-registry-url>/<project-name>/<imagestream-name>:tag
NOTE:
While pushing imagestream, getting invalid certificates issue and authentication issue
for default-docker registry.Exact solution is not yet identified.