Baking AWS AMI with new Docker CE Using Packer

Programmatic Ponderings

AWS for Docker

Introduction

On March 2 (less than a week ago as of this post), Docker announced the release of Docker Enterprise Edition (EE), a new version of the Docker platform optimized for business-critical deployments. As part of the release, Docker also renamed the free Docker products to Docker Community Edition (CE). Both products are adopting a new time-based versioning scheme for both Docker EE and CE. The initial release of Docker CE and EE, the 17.03 release, is the first to use the new scheme.

Along with the release, Docker delivered excellent documentation on installing, configuring, and troubleshooting the new Docker EE and CE. In this post, I will demonstrate how to partially bake an existing Amazon Machine Image (Amazon AMI) with the new Docker CE, preparing it as a base for the creation of Amazon Elastic Compute Cloud (Amazon EC2) compute instances.

Adding Docker and similar…

View original post 791 more words

Advertisements

Quick How-to to set up Swarm cluster

1.Define a file hosts with the entries below, where : 192.168.1.3 is the IP address of the node manager, and 192.168.1.5 and 192.168.1.6 are simple nodes.

# Hosts
node1 ansible_host=192.168.1.3
node2 ansible_host=192.168.1.5
node3 ansible_host=192.168.1.6

[swarm]
node1
node2
node3

2.On node manager (192.168.1.103) run :

$ docker swarm init 3. Run the docker swarm join command on the rest of nodes, using ansible

$ ansible swarm:’!192.168.1.103′ -m shell -a ‘docker swarm join –token SWMTKN-1-32c9u5o0y7gbp3zg8wlvkacbcz0jcwnfgzyhitn5xk8v3gi7s5-2pyej0kduwv6kmx7ynjjvxnhl 192.168.1.103:2377′

The token WMTKN-1-32c9u5o0y7gbp3zg8wlvkacbcz0jcwnfgzyhitn5xk8v3gi7s5-2pyej0kduwv6kmx7ynjjvxnhl should depends on the return of the command : dockers swarm init.

4.Open 2377 TCP port on your firewall if you have one activated.

$ ufw allow 2377/tcp

5.Create the service :

$ docker service create –name hello-world –replicas 3 -p 80:80 dockercloud/hello-world

Configuring FCoE in Linux RHEL and HP FlexFabric

– First step is to identify Ethernet NIC’s and CNA that will pass FCoE traffic and thi is done by collecting information about MAC adresses.
– Installation of both of packages : fcoe-utils and lldpad
yum install fcoe-utils lldpad
– Load the driver bnx2fc
modprobe bnx2fc
– Renaming /etc/fcoe/cfg-ethx file to the name of the CNA, in our case it is eth2 :
cp /etc/fcoe/cfg-ethx /etc/fcoe/cfg-eth2
cat > /etc/fcoe/cfg-eth2 /etc/sysconfig/network-scripts/ifcfg-eth2<EOF
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
USERCTL=NO
MTU=9000
EOF
The MTU is set to 9000 because FC payload is 2,112 bytes jumbo frames must be turned on to
avoid unnecessary IP fragmentation
– Run ifup to bring FCoE interface up
ifup eth2
– Run fcoeadm -i to check all created FCoE interfaces and status.
– Run cat /proc/scsi/scsi to see the luns

Install bower on Ubuntu 14.04

I need to install bower to manage my js library for such use I need to install it using npm the nodejs package manager.
I you need nodejs on ubuntu 14.04 don’t install it using apt-get, the ubuntu packages are bad.
You may install the official package for ubuntu from nodejs website.

curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
sudo apt-get install --yes nodejs

bower is a shell tool, you have to install it globally so I run:
npm install -g bower

Quick setup : Free tier ec2 amazon instance

I create a free tier ec2 instance in amazon, I reserve an Elastic IP and assign it to my instance.
I install nginx and When I need to access nginx from internet, for that I went to my domain registrar godaddy I create a CNAME that point to this Elastic IP.
Finally I create a security group, I open stream to HTTP port, and my ec2 instance is became ready to use and to share http content.

Install and configure MongoDB in Ubuntu

We will install the most recent version of MongoDB from the 10gen repo. This requires us to first register the public key for the 10gen MongoDB apt repository, add the repository, and continue with the MongoDB installation.

Configure MongoDB
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
sudo apt-get -y update
sudo apt-get -y install mongodb-10gen vim curl

Create the database and database user
We need to create our database (proddb) and database user(admin).All commands denoted with ‘>’ are executed inside of MongoDB.

sudo mongo
>use proddb
>db.addUser({user: "admin",pwd: "bacon&eggs",roles: ["dbAdmin"],})
>exit

Modify MongoDB settings
We need to modify our MongoDB configuration to set the bind address to ‘0.0.0.0’ and port to ‘27017’. By default these values should be correct, but we want to ensure these settings are configured explicitly.

sudo vim /etc/mongodb.conf

Ensure the following is set correctly (note this is only a portion of the configuration file):

# mongodb.conf

# Where to store the data.

# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

port = 27017
bind_ip = 0.0.0.0

Restart the database
Now just restart the database for the changes to take effect.

sudo service mongodb restart

Fork from github and add change to your own repository

When playing with vagrant, I set up a haproxy keepalived apache stack on ubuntu precise.
For that I forked this repository vagrant-haproxy-demo from github (https://github.com/justintime/vagrant-haproxy-demo.git) that run a haproxy standalone instance and I append my change to it to support keepalived.

First of all, I create the repository vagrant-haproxy-keepalived.
and I set remote origin to the repository created.
I create a new branch named development, I modify code and I do a commit.

Finally I checkout to master and rebase the branch development.


git remote set-url origin https://github.com/mezgani/vagrant-haproxy-keepalived.git
git checkout -b development
git add .
git commit -a
git checkout master
git rebase development
git push origin master

My code is here https://github.com/mezgani/vagrant-haproxy-keepalived.git, you can browse code.