start jenkins container

1) Install docker:

Fedora 21:

sudo yum -y install docker

Fedora 20

$ sudo yum -y remove docker
$ sudo yum -y install docker-io

2) Start docker

$ sudo systemctl start docker
$ sudo systemctl enable docker

3) Pull jenkins container

$ docker pull jenkins

4) Start jenkins container on port 8080

$ docker run -p 8080:8080 jenkins
Advertisements

Kuburnetes Configuration

Kuburnetes is  a system for container management. Open sourced by google.

Githttps://github.com/googlecloudplatform/kubernetes

Why Kuburnetes: lean, Portable, extensible, self-healing

Components:

1. Master: API Server, Scheduler, Registries, Controller-manager

2. Minion:  PODs, Kubelet, cAdvisor, Proxy

  3. Pod: Grouping of containers

4. Service and labels

5. Container

6. API Server

7. etcd

8. cAdvisor

9. kubectl: CLI which provides master access

CLI to manage is kubectl (kubecfg is deprecated) . All blogs talks configuration with kubecfg which may not work now.

Configuration

Current Kuburnetes is implemented on various ways.  This present setup use Fedora Manual setup.

My configuration has two nodes. ( one Master, One minor)

———–

Kuburnetes is  a system for container management. Open sourced by google.

Githttps://github.com/googlecloudplatform/kubernetes

Why Kuburnetes: lean, Portable, extensible, self-healing

Components:

1. Master: API Server, Scheduler, Registries, Controller-manager

2. Minion:  PODs, Kubelet, cAdvisor, Proxy

  3. Pod: Grouping of containers

4. Service and labels

5. Container

6. API Server

7. etcd

8. cAdvisor

9. kubectl: CLI which provides master access

CLI to manage is kubectl (kubecfg is deprecated) . All blogs talks configuration with kubecfg which may not work now.

Configuration

Current Kuburnetes is implemented on various ways.  This present setup use Fedora Manual setup.

My configuration has two nodes. ( one Master, One minon)

———–

1) System Information:

Both the machines has Fedora20

[root@fed-master ~]# cat /etc/issue
Fedora release 20 (Heisenbug)

[root@fed-minor ~]# cat /etc/issue
Fedora release 20 (Heisenbug)

fed-master = 9.121.59.12
fed-minion = 9.121.59.15

2) Install kuburnetes

yum install –enablerepo=updates-testing kubernetes

3) if DNS not configured in lab, add below on both nodes.

[root@fed-master ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 hadoop2
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
9.121.59.12 fed-master
9.121.59.15 fed-minion
[root@fed-master ~]#

4) Edit /etc/kubernetes/config on all hosts

# Comma seperated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS=”–etcd_servers=http://fed-master:4001″

# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR=”–logtostderr=true”

# journal message level, 0 is debug
KUBE_LOG_LEVEL=”–v=0″

# Should this cluster be allowed to run privleged docker containers
KUBE_ALLOW_PRIV=”–allow_privileged=false”

5) Disable the firewall on both the master and minon

6) Configure the kubernetes services on the master.

6.1 ) edit /etc/kubernetes/apiserver:

# The address on the local server to listen to.
KUBE_API_ADDRESS=”–address=0.0.0.0″

# The port on the local server to listen on.
KUBE_API_PORT=”–port=8080″

# How the replication controller and scheduler find the kube-apiserver
KUBE_MASTER=”–master=http://fed-master:8080″

# Port minions listen on
KUBELET_PORT=”–kubelet_port=10250″

# Address range to use for services
KUBE_SERVICE_ADDRESSES=”–portal_net=10.254.0.0/16″

# Add you own!
KUBE_API_ARGS=””

6.2) Edit /etc/kubernetes/controller-manager

# Add you own!
KUBE_CONTROLLER_MANAGER_ARGS=””

# Comma seperated list of minions
KUBELET_ADDRESSES=”–machines=fed-minion”

6.3 ) Start the appropriate services on master:

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

7) Configure the kubernetes services on the minon

7.1) Edit /etc/kubernetes/kubelet

# The address for the info server to serve on
KUBELET_ADDRESS=”–address=0.0.0.0″

# The port for the info server to serve on
KUBELET_PORT=”–port=10250″

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME=”–hostname_override=fed-minion”

# Add your own!
KUBELET_ARGS=””

7.2) start Servcies:

for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

8)  Check the setup on Master

[root@fed-master ~]# kubectl get minions
NAME LABELS
fed-minion <none>

All set. Ready to go.

9)  create  a yaml file on master

[root@fed-master ~]# cat kubeintro.yaml
apiVersion: v1beta1
kind: Pod
id: www
desiredState:
manifest:
version: v1beta1
id: www
containers:
– name: nginx
image: dockerfile/nginx
[root@fed-master ~]#

10) create pod:

[root@fed-master ~]# kubectl create -f kubeintro.yaml
www

11) Get pod status

[root@fed-master ~]# kubectl get pods
NAME                IMAGE(S)            HOST                LABELS              STATUS
redis-master        dockerfile/redis    fed-minion/         name=redis-master   Running
www                 dockerfile/nginx    fed-minion/                       Running
php                 dockerfile/nginx    fed-minion/         name=foo            Running

12) go to Master web browser on run :

fed-master:8080

Welcome to Kubernetes

You can keep adding more minons and run pods on minon.

For now only one master can manage. Multiple masters for redudancy code is available. But not well tested.

Thanks to Kubernetes github.

Docker on RHEL

Steps to start Dockerised application on x86.

1. Install Docker

yum install docker

2. Start & Enable service

systemctl start docker.service

systemctl enable docker.service

systemctl status docker.service

[root@xkvm ~]# systemctl status docker.service
docker.service – Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
Active: active (running) since Fri 2014-11-21 07:20:23 EST; 1 weeks 4 days ago
Docs: http://docs.docker.io
Main PID: 26839 (docker)
CGroup: /system.slice/docker.service
└─26839 /usr/bin/docker -d –selinux-enabled -H fd://

3. Docker CLi commands.

[root@xkvm ~]# docker

4. For ex:

Steps to start Dockerised application on x86.

1. Install Docker

yum install docker

2. Start & Enable service

systemctl start docker.service

systemctl enable docker.service

systemctl status docker.service

[root@xkvm ~]# systemctl status docker.service
docker.service – Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
Active: active (running) since Fri 2014-11-21 07:20:23 EST; 1 weeks 4 days ago
Docs: http://docs.docker.io
Main PID: 26839 (docker)
CGroup: /system.slice/docker.service
└─26839 /usr/bin/docker -d –selinux-enabled -H fd://

3. Docker CLi commands.

[root@xkvm ~]# docker

4. For ex: version

[root@xkvm ~]# docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): 2a2f26c/1.2.0
OS/Arch (client): linux/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): 2a2f26c/1.2.0
[root@xkvm ~]#

5. Work with Docker images

[root@xkvm ~]# docker search –stars=1 –trusted fedora
Warning: ‘–trusted’ is deprecated, it will be removed soon. See usage.
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
fedora/apache 28 [OK]
fedora/couchdb 23 [OK]
fedora/mariadb 22 [OK]
fedora/redis 19 [OK]
fedora/memcached 19 [OK]
fedora/qpid 18 [OK]
fedora/python 18 [OK]
fedora/registry 18 [OK]
fedora/systemd-systemd 18 [OK]
fedora/rabbitmq 18 [OK]
fedora/nginx 18 [OK]
fedora/earthquake 17 [OK]
fedora/firefox 16 [OK]
fedora/ssh 16 [OK]
fedora/nodejs 14 [OK]
fedora/systemd-apache 5 [OK]
tutum/fedora Fedora image with SSH access. For the root… 4 [OK]
vbatts/fedora-varnish https://github.com/vbatts/laughing-octo/tr&#8230; 2 [OK]
tutum/fedora-20 DEPRECATED. Use tutum/fedora:20 or tutum/f… 2 [OK]
neroinc/fedora-apache-php-phalcon1.2 Apache, PHP and the Phalcon PHP Framework … 1 [OK]
neroinc/fedora-apache Plain and simple image with Apache httpd b… 1 [OK]
kumarpraveen/fedora-sshd Fedora docker file for ssh service which m… 1 [OK]
openshift/fedora-redis 1 [OK]
fedora/owncloud 1 [OK]
neroinc/fedora-apache-php-phalcon Apache, PHP and the Phalcon PHP Framework … 1 [OK]
jervine/docker-squid Fedora based Squid Proxy 1 [OK]
adelton/freeipa-client Fedora/CentOS container to be used for IPA… 1 [OK]
jervine/docker-sickbeard Fedora 20 based SickBeard 1 [OK]
jervine/docker-sabnzbd Fedora 20 based SABnzbd 1 [OK]
jervine/docker-couchpotato Fedora 20 based CouchPotato 1 [OK]
startx/fedora 1 [OK]
neroinc/fedora-memcached Installation of memcached based on fedora:20 1 [OK]
neroinc/fedora-apache-php Apache and PHP based on fedora:20 1 [OK]
neroinc/fedora-golang 1 [OK]
knighcl/freeipa-devel-rpms FreeIPA project build rpms from any git br… 1 [OK]
juhp/fedora-haskell-ghc Fedora Haskell image 1 [OK]
michilu/fedora-zero 120MB minimum rawhide not install anything 1 [OK]
neroinc/fedora-node Node.js image based on fedora:20 1 [OK]
[root@xkvm ~]#

6. search for images

docker search name

7. Pull images from repo

pulling redis image from fedora repo.

[root@xkvm ~]# docker pull fedora/redis
Pulling repository fedora/redis
178a540d524c: Download complete
511136ea3c5a: Download complete
ff75b0852d47: Download complete
0dae8c30a0b2: Download complete
473b7396e1fb: Download complete
6f809bf47415: Download complete
1a42431fcb9e: Download complete
dfd2e7366898: Download complete
[root@rhevb ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
fedora/redis latest 178a540d524c 9 weeks ago 552.2 MB
[root@xkvm ~]#

8. List Images

[root@xkvm ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
fedora/redis latest 178a540d524c 9 weeks ago 552.2 MB
[root@xkvm ~]#

9. sharing images

docker push <repo/name>

10. Play with containers

[root@xkvm ~]# docker run –name=redis1 redis
Unable to find image ‘redis’ locally
Pulling repository redis
dad71287aacb: Download complete
511136ea3c5a: Download complete
f10807909bc5: Download complete
f6fab3b798be: Download complete
1e6ac0ffed3b: Download complete
62ff5003ac9a: Download complete
e49d349e8a75: Download complete
61213f5a1710: Download complete
1224a21102d6: Download complete
c6e112c19412: Download complete
7d2c1e0aecf8: Download complete
ff39eeaeb65a: Download complete
2854f8d9f233: Download complete
a7f162e686d8: Download complete
1a4e6a91ed17: Download complete
c1f74633a2f9: Download complete
41b458fa48f0: Download complete
15c3639f2b59: Download complete
[1] 02 Dec 17:35:04.183 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-“__ ”-._
_.-“    `.  `_.  ”-._           Redis 2.8.17 (00000000/0) 64 bit
.-“ .-“`.  “`\/    _.,_ ”-._
(    ‘      ,       .-`  | `,    )     Running in stand alone mode
|`-._`-…-` __…-.“-._|’` _.-‘|     Port: 6379
|    `-._   `._    /     _.-‘    |     PID: 1
`-._    `-._  `-./  _.-‘    _.-‘
|`-._`-._    `-.__.-‘    _.-‘_.-‘|
|    `-._`-._        _.-‘_.-‘    |           http://redis.io
`-._    `-._`-.__.-‘_.-‘    _.-‘
|`-._`-._    `-.__.-‘    _.-‘_.-‘|
|    `-._`-._        _.-‘_.-‘    |
`-._    `-._`-.__.-‘_.-‘    _.-‘
`-._    `-.__.-‘    _.-‘
`-._        _.-‘
`-.__.-‘

[1] 02 Dec 17:35:04.185 # Server started, Redis version 2.8.17
[1] 02 Dec 17:35:04.185 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.
[1] 02 Dec 17:35:04.185 * The server is now ready to accept connections on port 6379