Monday, May 25, 2015

Setup Nova-Docker Driver with RDO Kilo on Fedora 21

    Set up RDO Kilo on Fedora 21 per https://www.rdoproject.org/Quickstart
Next step supposed to be is upgrade several python packages via Fedora
Rawhide, build Nova-Docker Driver based on stable/kilo branch and
switch openstack-nova-compute to run Nova-Docker Driver been built  via stable/kilo branch of http://github.com/stackforge/nova-docker.git

 # yum -y install git docker-io python-six  fedora-repos-rawhide
 # yum --enablerepo=rawhide install  python-pip python-pbr systemd
 # reboot
 **********************
 Next
 **********************
 # chmod 666 /var/run/docker.sock
 # yum - y install gcc python-devel
 # git clone http://github.com/stackforge/nova-docker.git
 # cd nova-docker
 # git checkout -b kilo origin/stable/kilo
 # git branch -v -a
 * kilo                           d556444 Do not enable swift/ceilometer/sahara
  master                         d556444 Do not enable swift/ceilometer/sahara
  remotes/origin/HEAD            -> origin/master
  remotes/origin/master          d556444 Do not enable swift/ceilometer/sahara
  remotes/origin/stable/icehouse 9045ca4 Fix lockpath for tests
  remotes/origin/stable/juno     b724e65 Fix tests on stable/juno
  remotes/origin/stable/kilo     d556444 Do not enable swift/ceilometer/sahara

 # python setup.py install
 # systemctl start docker
 # systemctl enable docker
 # chmod 666  /var/run/docker.sock
 # mkdir /etc/nova/rootwrap.d

******************************
Update nova.conf
******************************
vi /etc/nova/nova.conf
set "compute_driver = novadocker.virt.docker.DockerDriver"

************************************************
Next, create the docker.filters file:
************************************************
$ vi /etc/nova/rootwrap.d/docker.filters

Insert Lines

# nova-rootwrap command filters for setting up network in the docker driver
# This file should be owned by (and only-writeable by) the root user
[Filters]
# nova/virt/docker/driver.py: 'ln', '-sf', '/var/run/netns/.*'
ln: CommandFilter, /bin/ln, root

*****************************************
Add line /etc/glance/glance-api.conf
*****************************************
container_formats=ami,ari,aki,bare,ovf,ova,docker

Restart Services
************************
# systemctl restart openstack-nova-compute
# systemctl status openstack-nova-compute
# systemctl restart openstack-glance-api

***************************************************
 For docker pull && docker save
 Uploading docker image to glance
***************************************************
 # .  keystonerc_admin 
 #  docker pull rastasheep/ubuntu-sshd:14.04
 #  docker save rastasheep/ubuntu-sshd:14.04 | glance image-create --is-public=True   --container-format=docker --disk-format=raw --name rastasheep/ubuntu-sshd:14.04

  
****************************************************************
To enable security rules and launch NovaDocker Container :-
****************************************************************

#  . keystonerc_demo 

# neutron security-group-rule-create --protocol icmp \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default

# neutron security-group-rule-create --protocol tcp \
  --port-range-min 22 --port-range-max 22 \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default

# neutron security-group-rule-create --protocol tcp \
  --port-range-min 80 --port-range-max 80 \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default


# neutron security-group-rule-create --protocol tcp \
  --port-range-min 80 --port-range-max 4848 \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default


# neutron security-group-rule-create --protocol tcp \
  --port-range-min 80 --port-range-max 8080 \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default



# neutron security-group-rule-create --protocol tcp \
  --port-range-min 80 --port-range-max 8181  \
  --direction ingress --remote-ip-prefix 0.0.0.0/0 default


******************************************************************
Launch new instance via uploaded image :-
******************************************************************


#  . keystonerc_demo  

#   nova boot --image "rastasheep/ubuntu-sshd:14.04" --flavor m1.tiny
    --nic net-id=private-net-id UbuntuDocker


either via dashboard

*****************************************************
Update before reboot /etc/cr.d/rc.local as follows :-
*****************************************************
[root@fedora21wks ~(keystone_admin)]# cat  /etc/rc.d/rc.local
#!/bin/bash
chmod 666 /var/run/docker.sock ;
systemctl restart  openstack-nova-compute



[root@fedora21wks ~(keystone_admin)]# chmod a+x   /etc/rc.d/rc.local
 

   Starting NovaDocker TomCat container,  floating IP 192.168.1.158

  
Starting Nova-Docker GlassFish4.1 NovaDocker container,
floating IP 192.168.1.159


  
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/01_start-sshd.sh...
No SSH host key available. Generating one...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
invoke-rc.d: policy-rc.d denied execution of restart.
SSH KEYS regenerated by Boris just in case !
SSHD started !
*** Running /etc/my_init.d/database.sh...
Derby database started !
*** Running /etc/my_init.d/run.sh...
Bad Network Configuration.  DNS can not resolve the hostname: 
java.net.UnknownHostException: instance-00000009: instance-00000009: unknown error
Waiting for domain1 to start ..............
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
=> Modifying password of admin to random in Glassfish
spawn asadmin --user admin change-admin-password
Enter the admin password> 
Enter the new admin password> 
Enter the new admin password again> 
Command change-admin-password executed successfully.
=> Enabling secure admin login
spawn asadmin enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> 
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.
=> Done!
========================================================================
You can now connect to this Glassfish server using:

     admin:0f2HOP1vCiDd

Please remember to change the above password as soon as possible!
========================================================================
=> Restarting Glassfish server
Waiting for the domain to stop 
Command stop-domain executed successfully.
=> Starting and running Glassfish server
=> Debug mode is set to: false
Bad Network Configuration.  DNS can not resolve the hostname: 
java.net.UnknownHostException: instance-00000009: instance-00000009: unknown error 
 
 
[root@fedora21wks ~(keystone_admin)]# ssh root@192.168.1.159
root@192.168.1.159's password: 
Last login: Tue May 26 12:38:48 2015 from 192.168.1.75
root@instance-00000009:~# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 12:18 ?        00:00:00 /usr/bin/python3 -u /sbin/my_init
root        96     1  0 12:18 ?        00:00:00 /bin/bash /etc/my_init.d/run.sh
root       100     1  0 12:18 ?        00:00:00 /usr/sbin/sshd
root       162     1  0 12:18 ?        00:00:03 /opt/jdk1.8.0_25/bin/java -Djava.library.path=/op
root       426    96  0 12:18 ?        00:00:01 java -jar /opt/glassfish4/bin/../glassfish/lib/cl
root       443   426 12 12:18 ?        00:02:43 /opt/jdk1.8.0_25/bin/java -cp /opt/glassfish4/gla
root      1110   100  0 12:39 ?        00:00:00 sshd: root@pts/0 
root      1112  1110  0 12:39 pts/0    00:00:00 -bash
root      1123  1112  0 12:39 pts/0    00:00:00 ps -ef
root@instance-00000009:~# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8479 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8479 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1544705 (1.5 MB)  TX bytes:1544705 (1.5 MB)

ns292e45a2-ad Link encap:Ethernet  HWaddr fa:16:3e:b9:a8:4e  
          inet addr:50.0.0.19  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:feb9:a84e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17453 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9984 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:28521655 (28.5 MB)  TX bytes:5336887 (5.3 MB)

root@instance-00000009:~# 

**************************************************
Running NovaDocker's containers (instances) :- 
**************************************************
 
[root@fedora21wks ~(keystone_admin)]# docker ps
CONTAINER ID        IMAGE                                      COMMAND                CREATED             STATUS              PORTS               NAMES
c5c4594da13d        boris/docker-glassfish41:latest            "/sbin/my_init"        26 minutes ago      Up 26 minutes                           nova-d751e04c-8f9b-4171-988a-cd57fb37574c   
a58781eba98b        tutum/tomcat:latest                        "/run.sh"              4 hours ago         Up 4 hours                              nova-3024f190-8dbb-4faf-b2b0-e627d6faba97   
cd1418845931        eugeneware/docker-wordpress-nginx:latest   "/bin/bash /start.sh   5 hours ago         Up 5 hours                              nova-c0211200-eee9-431e-aa64-db5cdcadad66   
700fe66add76        rastasheep/ubuntu-sshd:14.04               "/usr/sbin/sshd -D"    7 hours ago         Up 7 hours                              nova-9d0ebc1d-5bfa-44d7-990d-957d7fec5ea2