Couchbase on OpenShift 3
OpenShift is Red Hat’s open source PaaS platform. OpenShift 3 provides a holistic experience of running your applications using Docker and Kubernetes. In a classic Red Hat way, all the work is done in the open source at OpenShift Origin. This also drives the next major release of OpenShift Online and OpenShift Enterprise.
OpenShift 3 using Docker and Kubernetes for container orchestration makes it really simple to bring any products that have a Docker image to run with minimal effort. This blog explains how to get started with Couchbase on OpenShift 3.
Getting Started with OpenShift 3 
- Download the latest Vagrant box (1.1 as of this writing) and Vagrantfile from: openshift.org/vm/. Copy them in the same directory.Vagrantfile is configured for 2GB memory and can be updated if you need to run more containers. OpenShift Master, Node, Docker Registry, and other components run inside the VM.This blog was written using Vagrant 1.7.4 and VirtualBox 5.0.10r104061.
- Add the Vagrant Box:12345
vagrant box add --name openshift3 openshift-bootstrap-1.1.box
==> box: Box
file
was not detected as metadata. Adding it directly...
==> box: Adding box
'openshift3'
(v0)
for
provider:
box: Unpacking necessary files from:
file
:
///Users/arungupta/tools/openshiftv3/1
.1
/openshift-bootstrap-1
.1.box
==> box: Successfully added box
'openshift3'
(v0)
for
'virtualbox'
!
- Start the Virtual Machine:01020304050607080910111213141516171819202122232425262728293031
vagrant up
Bringing machine
'default'
up with
'virtualbox'
provider...
==> default: Setting the name of the VM: openshift3
==> default: Clearing any previously
set
network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 1080 (adapter 1)
default: 443 => 1443 (adapter 1)
default: 5000 => 5000 (adapter 1)
default: 8080 => 8080 (adapter 1)
default: 8443 => 8443 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running
'pre-boot'
VM customizations...
==> default: Booting VM...
==> default: Waiting
for
machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking
for
guest additions
in
VM...
default: The guest additions on this VM
do
not match the installed version of
default: VirtualBox! In most cases this is fine, but
in
rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please
make
sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.3.20
default: VirtualBox Version: 5.0
Download and Configure OpenShift 3 Client
- Download Mac 64-bit client tools (
gem install rhc
is for v2 only) from openshift.org/vm/ and extract them a in directory. The listing looks like:0102030405060708091011tar
xzvf ~
/Downloads/openshift-origin-v1
.1-ac7a99a-darwin-amd64.
tar
.gz
x ./
x .
/oadm
x .
/kube-scheduler
x .
/kubelet
x .
/kube-apiserver
x .
/openshift
x .
/kube-controller-manager
x .
/kube-proxy
x .
/oc
x .
/kubectl
- Verify the client version:123
.
/oc
version
oc v1.1
kubernetes v1.1.0-origin-1107-g4c8e6f4
- Remove
~/.kube/config
or rename to something else. - Login to OpenShift:01020304050607080910111213141516171819
.
/oc
login
Server [https:
//localhost
:8443]:
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y
/n
): y
Authentication required
for
https:
//localhost
:8443 (openshift)
Username: admin
Password:
Login successful.
You have access to the following projects and can switch between them with
'oc project <projectname>'
:
* default (current)
* openshift
* turbo
Using project
"default"
.
Welcome! See
'oc help'
to get started.
Create Couchbase Application in OpenShift 3
- Create a new Couchbase instance:0102030405060708091011
.
/oc
new-app arungupta
/couchbase
--> Found Docker image 9131c5a (2 days old) from Docker Hub
for
"arungupta/couchbase"
* An image stream will be created as
"couchbase:latest"
that will track this image
* This image will be deployed
in
deployment config
"couchbase"
* Ports 11207
/tcp
, 11210
/tcp
, 11211
/tcp
, 18091
/tcp
, 18092
/tcp
, 8091
/tcp
, 8092
/tcp
, 8093
/tcp
will be load balanced by service
"couchbase"
--> Creating resources with label app=couchbase ...
ImageStream
"couchbase"
created
DeploymentConfig
"couchbase"
created
Service
"couchbase"
created
--> Success
Run
'oc status'
to view your app.
arungupta/couchbase
is used as it uses Couchbase REST API to preconfigure the Couchbase server with:- Memory and index quota
- Query, Data, and Index service
- Username and password credentials
- Install
travel-sample
bucket
This sample bucket will be used later for querying data.
- Check the status of deployment:010203040506070809101112131415161718192021222324
.
/oc
status
In project default on server https:
//localhost
:8443
svc
/couchbase
- 172.30.84.134 ports 8091, 8092, 8093, 11207, 11210, 11211, 18091, 18092
dc
/couchbase
deploys imagestreamtag
/couchbase
:latest
#1 deployed about a minute ago - 1 pod
svc
/docker-registry
- 172.30.236.154:5000
dc
/docker-registry
deploys docker.io
/openshift/origin-docker-registry
:v1.1
#1 deployed 4 weeks ago - 1 pod
svc
/kubernetes
- 172.30.0.1 ports 443, 53, 53
svc
/router
- 172.30.233.69:80
dc
/router
deploys docker.io
/openshift/origin-haproxy-router
:v1.1
#1 deployed 4 weeks ago - 1 pod
Warnings:
* container
"registry"
in
pod
/docker-registry-1-imxqp
has restarted 5
times
* container
"openshift-registry-proxy-1"
in
pod
/openshift-registry-proxy
has restarted 3
times
* container
"router"
in
pod
/router-1-5grim
has restarted 5
times
To see
more
, use
'oc describe <resource>/<name>'
.
You can use
'oc get all'
to see a list of other objects.
- Find the list of Pods:123456
client > .
/oc
get po
NAME READY STATUS RESTARTS AGE
couchbase-1-5zhju 1
/1
Running 0 1d
docker-registry-1-imxqp 1
/1
Running 5 32d
openshift-registry-proxy 1
/1
Running 3 32d
router-1-5grim 1
/1
Running 5 32d
- Get more details about the Couchbase pod:010203040506070809101112131415161718192021222324252627282930313233343536
.
/oc
describe po couchbase-1-5zhju
Name: couchbase-1-5zhju
Namespace: default
Image(s): arungupta
/couchbase
@sha256:9131c5a283d79e11b6556c94b0b0f8ceba7daf5ba5982bac850100099019959f
Node: localhost.localdomain
/10
.0.2.15
Start Time: Sat, 19 Dec 2015 08:19:31 -0800
Labels: app=couchbase,deployment=couchbase-1,deploymentconfig=couchbase
Status: Running
Reason:
Message:
IP: 172.17.0.7
Replication Controllers: couchbase-1 (1
/1
replicas created)
Containers:
couchbase:
Container ID: docker:
//bd51f655c2a54f92f4634b84f455ca91642a88b925be39126f07df43ce883a33
Image: arungupta
/couchbase
@sha256:9131c5a283d79e11b6556c94b0b0f8ceba7daf5ba5982bac850100099019959f
Image ID: docker:
//c9d204bb75427500ef94263f8f53e8b78f2e56efd37543e620aebb1bc1bd7de1
QoS Tier:
cpu: BestEffort
memory: BestEffort
State: Running
Started: Sat, 19 Dec 2015 08:20:21 -0800
Ready: True
Restart Count: 0
Environment Variables:
Conditions:
Type Status
Ready True
Volumes:
couchbase-volume-1:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
default-token-cycb6:
Type: Secret (a secret that should populate this volume)
SecretName: default-token-cycb6
No events.
Query Couchbase Sample Bucket
- Log into the Vagrant box:123
vagrant
ssh
Last login: Wed Nov 18 18:04:32 2015 from 10.0.2.2
[vagrant@localhost ~]$
- Find a list of all the running containers:01020304050607080910111213141516
[vagrant@localhost ~]$ docker
ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd51f655c2a5 arungupta
/couchbase
@sha256:9131c5a283d79e11b6556c94b0b0f8ceba7daf5ba5982bac850100099019959f
"/entrypoint.sh /opt/"
7 minutes ago Up 7 minutes k8s_couchbase.f96da262_couchbase-1-5zhju_default_48e953db-a66c-11e5-8a75-080027c5bfa9_31dbcfec
8e5ef3e54d4e openshift
/origin-pod
:v1.1
"/pod"
8 minutes ago Up 8 minutes k8s_POD.d7dfee57_couchbase-1-5zhju_default_48e953db-a66c-11e5-8a75-080027c5bfa9_b1bcd72d
0f7807f389d9 openshift
/mysql-55-centos7
:latest
"container-entrypoint"
15 minutes ago Up 15 minutes k8s_ruby-helloworld-database.448eeefe_database-1-w51ix_turbo_91adac2f-8d66-11e5-bf15-080027c5bfa9_74ecdc59
077a078e00a3 172.30.236.154:5000
/turbo/origin-ruby-sample
@sha256:c4ed12ec9817fca1fb41a5eb0c66f2edccf2e7375128fd6d64f7180207262193
"container-entrypoint"
16 minutes ago Up 16 minutes k8s_ruby-helloworld.88353f9f_frontend-2-1lm99_turbo_42a6dd40-8d67-11e5-bf15-080027c5bfa9_d5110e41
e2105f2f4ab6 openshift
/origin-haproxy-router
:v1.1
"/usr/bin/openshift-r"
16 minutes ago Up 16 minutes k8s_router.c3a638e8_router-1-5grim_default_cac8c2d2-8d63-11e5-b835-080027c5bfa9_9d49a633
b98052109d08 172.30.236.154:5000
/turbo/origin-ruby-sample
@sha256:c4ed12ec9817fca1fb41a5eb0c66f2edccf2e7375128fd6d64f7180207262193
"container-entrypoint"
16 minutes ago Up 16 minutes k8s_ruby-helloworld.88353f9f_frontend-2-hdz43_turbo_46657993-8d67-11e5-bf15-080027c5bfa9_f6394539
646dcce91f59 openshift
/origin-docker-registry
:v1.1
"/bin/sh -c 'REGISTRY"
16 minutes ago Up 16 minutes k8s_registry.35eb136e_docker-registry-1-imxqp_default_cb3dde6e-8d63-11e5-b835-080027c5bfa9_71586c07
d02c8c07f690 openshift
/origin-registry-proxy
"sh -cx '/bin/tcppm -"
16 minutes ago Up 16 minutes k8s_openshift-registry-proxy-1.a0457375_openshift-registry-proxy_default_767fcb12-8d64-11e5-bf15-080027c5bfa9_4c413a10
23267082944f openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes k8s_POD.d982fd5f_database-1-w51ix_turbo_91adac2f-8d66-11e5-bf15-080027c5bfa9_8fc2969f
bd7f82a88cb1 openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes k8s_POD.e127fd63_frontend-2-1lm99_turbo_42a6dd40-8d67-11e5-bf15-080027c5bfa9_3f73ddf8
d2ca01d75a0c openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes k8s_POD.4d0ddc3f_router-1-5grim_default_cac8c2d2-8d63-11e5-b835-080027c5bfa9_036343da
5e25f5ba5c4c openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes k8s_POD.e127fd63_frontend-2-hdz43_turbo_46657993-8d67-11e5-bf15-080027c5bfa9_122e502e
7c4b2b9e6c39 openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes k8s_POD.cc3ffd58_docker-registry-1-imxqp_default_cb3dde6e-8d63-11e5-b835-080027c5bfa9_0ae24ed7
85c4cf8d0808 openshift
/origin-pod
:v1.1
"/pod"
17 minutes ago Up 16 minutes 0.0.0.0:5000->5000
/tcp
k8s_POD.c686fded_openshift-registry-proxy_default_767fcb12-8d64-11e5-bf15-080027c5bfa9_04225f94
Search for Couchbase container:
12345[vagrant@localhost ~]$ docker
ps
|
grep
couchbase
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd51f655c2a5 arungupta
/couchbase
@sha256:9131c5a283d79e11b6556c94b0b0f8ceba7daf5ba5982bac850100099019959f
"/entrypoint.sh /opt/"
7 minutes ago Up 7 minutes k8s_couchbase.f96da262_couchbase-1-5zhju_default_48e953db-a66c-11e5-8a75-080027c5bfa9_31dbcfec
8e5ef3e54d4e openshift
/origin-pod
:v1.1
"/pod"
8 minutes ago Up 8 minutes k8s_POD.d7dfee57_couchbase-1-5zhju_default_48e953db-a66c-11e5-8a75-080027c5bfa9_b1bcd72d
0f7807f389d9 openshift
/mysql-55-centos7
:latest
"container-entrypoint"
15 minutes ago Up 15 minutes
Get the id for our container:
12docker
ps
|
grep
arungupta
/couchbase
|
awk
'{ print $1}'
bd51f655c2a5
- Get IP address of the Pod where Couchbase server is running:12
[vagrant@localhost ~]$ docker inspect --
format
'{{ index .Config.Env 6 }}'
`docker
ps
|
grep
arungupta
/couchbase
|
awk
'{ print $1}'
`
COUCHBASE_SERVICE_HOST=172.30.84.134
- Use the IP address shown above to start Couchbase Query CLI:01020304050607080910111213141516171819202122232425
[vagrant@localhost ~]$ docker run -it arungupta
/couchbase
/opt/couchbase/bin/cbq
-engine=http:
//172
.30.84.134:8093
Unable to
find
image
'arungupta/couchbase:latest'
locally
Trying to pull repository docker.io
/arungupta/couchbase
... latest: Pulling from arungupta
/couchbase
62baed0d0de5: Already exists
39387babd60f: Already exists
6a2bc8404be0: Already exists
bad926a6fb50: Already exists
1a86c4c907e0: Already exists
32132a7c82e9: Already exists
646c3d5ebb71: Already exists
864cbabd77ad: Already exists
8c327c6d4e43: Already exists
8592c697ab61: Already exists
7734f4a832d4: Already exists
35edb38ebc17: Already exists
99f3eb6fb46f: Already exists
91e5fad693c2: Already exists
0cb81f5cc79b: Already exists
ec58df60a109: Already exists
c9d204bb7542: Already exists
Digest: sha256:9131c5a283d79e11b6556c94b0b0f8ceba7daf5ba5982bac850100099019959f
Status: Downloaded newer image
for
docker.io
/arungupta/couchbase
:latest
Couchbase query shell connected to http:
//172
.30.84.134:8093/ . Type Ctrl-D to
exit
.
cbq>;
- Query the sample bucket:010203040506070809101112131415161718192021222324252627
cbq>
select
* from `travel-sample` limit 1;
{
"requestID"
:
"a7bd414a-c571-4b22-8c81-30512b87730d"
,
"signature"
: {
"*"
:
"*"
},
"results"
: [
{
"travel-sample"
: {
"callsign"
:
"MILE-AIR"
,
"country"
:
"United States"
,
"iata"
:
"Q5"
,
"icao"
:
"MLA"
,
"id"
: 10,
"name"
:
"40-Mile Air"
,
"type"
:
"airline"
}
}
],
"status"
:
"success"
,
"metrics"
: {
"elapsedTime"
:
"123.799956ms"
,
"executionTime"
:
"116.882044ms"
,
"resultCount"
: 1,
"resultSize"
: 300
}
}
Enjoy!
This blog shows the very basics of getting started with Couchbase on OpenShift 3. Future blogs will show:
- How to deploy an application to OpenShift and use this Couchbase
- How to make this application accessible outside OpenShift
- How to scale Couchbase in OpenShift
- Possibly some other interesting items that come along
Read more about Couchbase 4.1
- What’s New in Couchbase Server 4.1
- Download Couchbase Server 4.1
- Couchbase Server documentation
- Talk to us on Couchbase Forums
- Follow @couchbasedev or @couchbase
Reference: | Couchbase on OpenShift 3 from our JCG partner Arun Gupta at the Miles to go 2.0 … blog. |