Skip to content

OpenShift

Johnson Fu edited this page Sep 19, 2019 · 34 revisions

Quick Start

hostnamectl set-hostname master.monk.local

openshift_disable_check=disk_availability,docker_storage,memory_availability

yum -y install wget git net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
yum -y install centos-release-openshift-origin311 epel-release docker git pyOpenSSL
echo -e 'Defaults:origin !requiretty\norigin ALL = (root) NOPASSWD:ALL' | tee /etc/sudoers.d/openshift
chmod 440 /etc/sudoers.d/openshift
firewall-cmd --add-service=ssh --permanent
firewall-cmd --reload

systemctl start docker
systemctl enable docker

-- k8s => quick setup https://blog.tomy168.com/2019/08/centos-76-kubernetes.html

yum install wget net-tools nano -y

access remote kube cluster, scp the .kube from the master node to current user
allow access docker $sudo usermod -aG docker origin

How To Setup Local OpenShift Origin (OKD) Cluster on CentOS 7

https://computingforgeeks.com/setup-openshift-origin-local-cluster-on-centos/

OpenShift Origin (OKD) 3.11 : Install

https://www.server-world.info/en/note?os=CentOS_7&p=openshift311&f=1

Downgrade Ansible Engine

https://www.unixarena.com/2019/06/downgrading-ansible-engine-on-centos-7-rhel-7.html/

Setup IP Address for Two Network Card

https://blog.csdn.net/l1028386804/article/details/77487639

Foundations of OpenShift

https://www.katacoda.com/openshift/courses/introduction

Getting Started of using minishift

https://www.novatec-gmbh.de/en/blog/getting-started-minishift-openshift-origin-one-vm/

Run Spring boot Application in Openshift

https://dzone.com/articles/how-to-run-java-microservices-on-openshift-using-s

Node.js sample app on OpenShift!

https://github.com/quantificial/brain/wiki/OpenShift/_edit

docker hello wolrd sample image

https://github.com/crccheck/docker-hello-world

Console Command

oc login -u developer 
oc login -u system:admin
oc whoami

minishift.exe start --vm-driver virtualbox --memory 8GB

oc policy add-role-to-user edit system:serviceaccount:ci:jenkins -n mybank # assign edit role for jenkins to modify mybank

oc tag mybank-dev/mybank-demo-maven:latest mybank-sit/mybank-demo-maven:latest # tag image to another project

oc new-app -i mybank-demo-maven:latest # create project from image stream

ip addr # check ip
systemctl stop firewalld # stop firewall

Using Dashboard

  • create the project
  • add to the project
    • use sample image openshiftroadshow/parksmap-katacoda:1.0.0 to create the pod

further using console command to check the status

$ oc project myproject
Now using project "myproject" on server "https://172.17.0.71:8443".
$ oc status
In project myproject on server https://172.17.0.71:8443

svc/parksmap-katacoda - 172.30.215.210:8080
  dc/parksmap-katacoda deploys istag/parksmap-katacoda:1.0.0
    deployment #1 deployed 38 seconds ago - 1 pod

View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.

deploy application from source

this can be done through source-to-image S2I, it is a tools of openshift to produce docker image

  • add to project
  • select catalogs and choose the required runtime environment
  • input the github source url

select resource by label

$ oc get all --selector [label]=[value]

deploy application from source by using command line

$oc new-app python:latest~https://github.com/openshift-katacoda/blog-django-py --name blog

$oc new-app https://github.com/openshift-katacoda/blog-django-py --name blog2

build source from local and update the pod

$ oc start-build blog --from-dir=. --wait

usd odo to develop and build application

mvn package
odo create java backend --binary target/xxxxx.jar

summary

oc new-app <image:tag>~<source-code> --name <name>: Deploy an application from source code hosted on a Git repository using the specified S2I builder image.

oc start-build <name>: Trigger a new build and deployment of the application where source code is taken from the hosted Git repository specified to oc new-app when the build configuration was created.

oc start-build <name> --from-dir=.: Trigger a new build and deployment of the application where source code is taken from the current working directory of the local machine where the oc command is being run.

oc cancel-build <build>: Cancel a running build.

oc logs bc/<name> --follow: Monitor the log output from the current build for the application.

oc get builds: Display a list of all builds, completed, cancelled and running.

oc get builds --watch: Monitor the progress of any active builds.

oc get pods --watch: Monitor any activity related to pods in the project. This will include pods run to handle building and deployment of an application.

Resources

理解OpenShift(1):网络之 Router 和 Route

https://www.cnblogs.com/sammyliu/p/10013461.html

minishift

https://www.okd.io/minishift/

tutorial

https://www.katacoda.com/openshift/courses/introduction

DevOps with OpenShift

https://www.openshift.com/devops-with-openshift/

Getting Started: MiniShift - An OpenShift Origin All-in-One VM

https://www.novatec-gmbh.de/en/blog/getting-started-minishift-openshift-origin-one-vm/

  • freemarker
  • thymeleaf
  • JMX (jconsole)
  • ZeroMQ
  • microk8s
  • multipass
  • pwsh (powershell)

Clone this wiki locally