Categories
DevOps PaaS

Getting Started with Containers on OpenShift Origin

So you want to get started with OpenShift M5 but you don’t really have an idea about how to get started? Then this article is the right place for you. This is going to be a series of blog posts and videos which will get you started with OpenShift quickly.

The first article is starting with a plain RHEL 7 VM. Nothing installed, nothing prepared.  I will explain the steps necessary to start OpenShift on your VM.

First let us remove unnecessary repositories from the repository list and add the required repositories to install go.

[bash]
# subscription-manager repos –disable=rhel-sap* –disable=*-ha-* –disable=*-lb-* –disable=*-rs-* –disable=*-rt-beta-* –disable=*-htb-*
# subscription-manager repos –enable=rhel-7-server-extras-rpms –enable=rhel-7-server-optional-rpms
[/bash]

and install EPEL (we need EPEL because go in the standard distribution channels is in version 1.2.2 and we need 1.3.3 which is only available in EPEL.

[bash]
# rpm -ivh http://mirrors.cat.pdx.edu/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
[/bash]

Now with everything in place we can start to install the required toolset

[bash]
# yum -y install golang docker git
# systemctl enable docker
# systemctl start docker
[/bash]

Let us now go ahead and clone the OpenShift Repository

[bash]
# git clone https://github.com/openshift/origin.git
Cloning into ‘origin’…
remote: Counting objects: 13461, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 13461 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (13461/13461), 16.94 MiB | 1.25 MiB/s, done.
Resolving deltas: 100% (6589/6589), done.
[/bash]

These are the important bits, now we can begin to compile OpenShift Origin, add the executable to the path and start OpenShift

[bash]
# cd origin
# hack/build-go.sh
++ Building go targets for linux/amd64: cmd/openshift
++ Placing binaries
# export PATH=/root/origin/_output/local/bin/linux/amd64:$PATH
# openshift start –listen=http://0.0.0.0:8080
I1218 00:18:12.545702 37863 start.go:174] Starting an OpenShift all-in-one, reachable at http://192.168.168.152:8080 (etcd: http://192.168.168.152:4001)
I1218 00:18:12.545832 37863 start.go:184] Node: localhost
I1218 00:18:12.545869 37863 etcd.go:29] Started etcd at 192.168.168.152:4001
[etcd] Dec 18 00:18:12.559 INFO | Peer URLs in log: / openshift.local (http://127.0.0.1:7001)
[etcd] Dec 18 00:18:12.563 INFO | etcd server [name openshift.local, listen on 0.0.0.0:4001, advertised url http://192.168.168.152:4001]
[etcd] Dec 18 00:18:12.563 INFO | peer server [name openshift.local, listen on 0.0.0.0:7001, advertised url http://127.0.0.1:7001]
[etcd] Dec 18 00:18:12.563 INFO | openshift.local starting in peer mode
[etcd] Dec 18 00:18:12.563 INFO | openshift.local: state changed from ‘initialized’ to ‘follower’.
[etcd] Dec 18 00:18:12.864 INFO | openshift.local: state changed from ‘follower’ to ‘candidate’.
[etcd] Dec 18 00:18:12.864 INFO | openshift.local: state changed from ‘candidate’ to ‘leader’.
[etcd] Dec 18 00:18:12.864 INFO | openshift.local: leader changed from ” to ‘openshift.local’.
W1218 00:18:12.917454 37863 apiserver.go:107] error getting kind: expected pointer, but got invalid kind
2014/12/18 00:18:12 [restful/swagger] listing is available at /swaggerapi/
2014/12/18 00:18:12 [restful/swagger] Swagger(File)Path is empty ; no UI is served
I1218 00:18:12.928033 37863 master.go:210] container: &restful.Container{webServices:[]*restful.WebService{(*restful.WebService)(0xc208211a20), (*restful.WebService)(0xc2080c8840), (*restful.WebService)(0xc208211290), (*restful.WebService)(0xc2080af550), (*restful.WebService)(0xc2080c8000)}, ServeMux:(*http.ServeMux)(0xc208242510), isRegisteredOnRoot:true, containerFilters:[]restful.FilterFunction{}, doNotRecover:false, recoverHandleFunc:(restful.RecoverHandleFunction)(0x611c00), router:restful.RouterJSR311{}, contentEncodingEnabled:false}
I1218 00:18:12.928130 37863 master.go:109] Started Kubernetes Scheduler
I1218 00:18:12.928145 37863 master.go:92] Started Kubernetes Replication Manager
I1218 00:18:12.928152 37863 master.go:100] Started Kubernetes Endpoint Controller
I1218 00:18:12.928162 37863 master.go:123] Started Kubernetes Minion Controller
I1218 00:18:12.928319 37863 master.go:231] Started Kubernetes API at http://192.168.168.152:8080/api/v1beta1
I1218 00:18:12.928327 37863 master.go:231] Started Kubernetes API at http://192.168.168.152:8080/api/v1beta2
I1218 00:18:12.928330 37863 master.go:231] Started OAuth2 API at http://192.168.168.152:8080/oauth
I1218 00:18:12.928334 37863 master.go:231] Started login server at http://192.168.168.152:8080/login
I1218 00:18:12.928337 37863 master.go:231] Started OpenShift API at http://192.168.168.152:8080/osapi/v1beta1
I1218 00:18:12.928340 37863 master.go:231] Started Swagger Schema API at http://192.168.168.152:8080/swaggerapi/
I1218 00:18:12.928673 37863 master.go:316] Started OpenShift static asset server at http://192.168.168.152:8081
I1218 00:18:12.961998 37863 node.go:59] Connecting to Docker at unix:///var/run/docker.sock
I1218 00:18:12.962057 37863 proxier.go:311] Initializing iptables
I1218 00:18:13.021817 37863 node.go:150] Started Kubernetes Proxy on 0.0.0.0
I1218 00:18:13.021944 37863 plugins.go:56] Registering credential provider: .dockercfg
I1218 00:18:13.021969 37863 node.go:102] Started Kubelet for node localhost, server at 0.0.0.0:10250
I1218 00:18:43.032315 37863 proxier.go:501] Opened iptables portal for service "kubernetes-ro" on 172.30.17.145:80
I1218 00:18:43.040577 37863 proxier.go:501] Opened iptables portal for service "kubernetes" on 172.30.17.189:443
E1218 00:23:12.953311 37863 reflector.go:109] Failed to watch *api.Pod: Get http://192.168.168.152:8080/api/v1beta1/watch/pods?fields=DesiredState.Host%3D&resourceVersion=13: EOF
E1218 00:23:12.953432 37863 reflector.go:109] Failed to watch *api.Deployment: Get http://192.168.168.152:8080/osapi/v1beta1/watch/deployments?fields=&labels=&resourceVersion=0: http: can’t write HTTP request on broken connection
E1218 00:28:12.955781 37863 reflector.go:109] Failed to watch *api.Deployment: Get http://192.168.168.152:8080/osapi/v1beta1/watch/deployments?fields=&labels=&resourceVersion=0: http: can’t write HTTP request on broken connection
E1218 00:33:12.957258 37863 reflector.go:109] Failed to watch *api.Build: Get http://192.168.168.152:8080/osapi/v1beta1/watch/builds?fields=&labels=&resourceVersion=0: http: can’t write HTTP request on broken connection
[/bash]

This will start OpenShift listening on all interfaces, launch an etcd server to store persistent
data, and launch the Kubernetes system components. The server will run in the foreground until
you terminate the process.

You should now be able to query the system and access the OpenShift static asset servers’ web ui (In my example http://192.168.168.152:8081).

[bash]
# openshift cli get services
NAME LABELS SELECTOR IP PORT
kubernetes-ro <none> component=apiserver,provider=kubernetes 172.30.17.145 80
kubernetes <none> component=apiserver,provider=kubernetes 172.30.17.189 443
[/bash]

RHEL7_OpenShift_v3
OpenShift static asset server

That is it, you have a running OpenShift all-in-one server that is ready to process requests. You can learn more about how to deploy services and containers into this environment in my next post.

2 replies on “Getting Started with Containers on OpenShift Origin”

Hi Dmitry, Things are changing pretty fast. I will create another series of articles with the next release of OpenShift v3 Beta Drop. With the high flux in the technology I thought it would not make sense to write more articles that would be invalid within a 2 week timeframe. Thanks for your interest, And I will ping you once they are done.

Buddy