Kubernetes with Jenkins

..

Based on http://www.infoq.com/articles/scaling-docker-with-kubernetes

In a Ubuntu container :
mkdir -p /opt/kubernetes/bin
cd /opt/kubernetes
wget https://github.com/kubernetes/kubernetes/releases/download/v1.0.6/kubernetes.tar.gz
tar -C bin/ -xvf kubernetes.tar.gz
tar -C bin/ -xvf kubernetes-coreos.tar.gztar -C bin/ -xvf kubernetes-coreos.tar.gz
export KUBERNETES_PROVIDER=gce
export KUBERNETES_NUM_MINIONS=2

gcloud auth login

gcloud config list project

cd ./bin/kuberbetes
./cluster/kube-up.sh

K1

# ./cluster/kubectl.sh cluster-info
Kubernetes master is running at https://130.211.118.68
KubeDNS is running at https://130.211.118.68/api/v1/proxy/namespaces/kube-system/services/kube-dns
KubeUI is running at https://130.211.118.68/api/v1/proxy/namespaces/kube-system/services/kube-ui
Grafana is running at https://130.211.118.68/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana
Heapster is running at https://130.211.118.68/api/v1/proxy/namespaces/kube-system/services/monitoring-heapster
InfluxDB is running at https://130.211.118.68/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb

I can use the KubeUI URL to access the KUI, with the user and passwd availabe in /.kube/config

Same for Grafana

# gcloud config set compute/zone us-central1-b
# gcloud config set compute/region us-central1-b
# gcloud compute ssh kubernetes-master

root@kubernetes-master:~# kubectl get namespaces
NAME LABELS STATUS
default <none> Active
kube-system <none> Active

# kubectl create -f ./jenkins.json

# kubectl get pods
NAME READY STATUS RESTARTS AGE
jenkins 1/1 Running 0 12m

# gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
kubernetes-master us-central1-b n1-standard-1 10.240.0.2 130.211.118.68 RUNNING
kubernetes-minion-dmx6 us-central1-b n1-standard-1 10.240.0.5 104.154.41.63 RUNNING
kubernetes-minion-l1sh us-central1-b n1-standard-1 10.240.0.6 104.197.76.30 RUNNING
kubernetes-minion-nz79 us-central1-b n1-standard-1 10.240.0.3 104.154.70.12 RUNNING
kubernetes-minion-q489 us-central1-b n1-standard-1 10.240.0.4 23.236.53.59 RUNNING

Using https://github.com/GoogleCloudPlatform/kube-jenkins-imager

mkdir /opt/kubernetes
git clone https://github.com/GoogleCloudPlatform/kube-jenkins-imager.git
cd kube-jenkins-imager
cp ssl_secrets.template.yaml ssl_secrets.yaml
./cluster_up.sh
kubectl describe service/nginx-ssl-proxy 2>/dev/null | grep ‘LoadBalancer Ingress’ | cut -f2
kubectl describe service/nginx-ssl-proxy
git clone https://github.com/GoogleCloudPlatform/scalable-resilient-web-app.git
cd scalable-resilient-web-app

In the Google Developer Console, navigate to Source Code > Browse, click “Get started” then choose “Push code from a local Git repository to your Cloud Repository”, and follow all of the instructions to push the scalable-resilient-web-app to your Cloud Repository.
git config credential.helper gcloud.sh
git remote add google https://source.developers.google.com/p/natural-axiom-106513/
git push –all google

root@f5340f19193c:/kube-jenkins-imager/scalable-resilient-web-app# git remote -v show -n google | grep Fetch
Fetch URL: https://source.developers.google.com/p/natural-axiom-106513/

Advertisements
Posted in Uncategorized

Setting up a Docker Swarm Cluster on a W10 platform with Google and Amazon Clouds

In a GitBash window :

After I got docker-machine 0.4.0 from here

I already have a GCE account set up, and a project name so all I’m ready to create my swarm master on Google:

export GCE_PROJECT=”natural-axiom-106513″
export TOKEN=”4506ce594e7afc4d27276205f8710e25″

Capture

For nodes :

./docker-machine create -d google –google-project=${GCE_PROJECT} –google-machine-type=n1-standard-2 –google-disk-size=50 –swarm –swarm-discovery token://${TOKEN} slave01

./docker-machine create -d google –google-project=${GCE_PROJECT} –google-machine-type=n1-standard-2 –google-disk-size=50 –swarm –swarm-discovery token://${TOKEN} slave02

$ ./docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
crate-swarm google Running tcp://104.197.34.189:2376 crate-swarm (master)
slave01 google Running tcp://104.197.96.123:2376 crate-swarm
slave02 google Running tcp://104.197.48.142:2376 crate-swarm

I now have a 2 nodes cluster running on Gcloud

I can add a node on Amazon EC2 :

I need to create a key pair

Let’s create a few  AWS variables :

export AWS_DEFAULT_REGION=us-east-1
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx
export AWS_ACCESS_KEY_ID=xxxxxxxxxxx

Let’s check our credentials :

(Got the aws cli for windows here)

$ ./AWSCLI/aws ec2 describe-subnets |head
{
“Subnets”: [
{
“VpcId”: “vpc-dae01fbe”,
“CidrBlock”: “172.31.48.0/20”,
“MapPublicIpOnLaunch”: true,
“DefaultForAz”: true,
“State”: “available”,
“AvailabilityZone”: “us-east-1a”,
“SubnetId”: “subnet-5add9171”,

This gives you values you can use (VPCID, subnet name)

export AWS_VPC_ID=vpc-dae01fbe

$ ./docker-machine create –driver amazonec2 –amazonec2-access-key $AWS_ACCESS_KEY_ID –amazonec2-secret-key $AWS_SECRET_ACCESS_KEY –amazonec2-vpc-id $AWS_VPC_ID –amazonec2-subnet-id subnet-5add9171 –amazonec2-zone a –swarm –swarm-discovery token://${TOKEN} awsslave01
Launching instance…
To see how to connect Docker to this machine, run: C:\Users\Jean-Marie\docker-machine env awsslave01

And that’s it !

$ ./docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
awsslave01 * amazonec2 Running tcp://54.165.76.245:2376 crate-swarm
crate-swarm google Running tcp://104.197.34.189:2376 crate-swarm (master)
slave01 google Running tcp://104.197.96.123:2376 crate-swarm
slave02 google Running tcp://104.197.48.142:2376 crate-swarm

Next step is to play with that cluster !

Notes :

I found these pages quite helpful :
https://docs.docker.com/machine/drivers/aws/
http://networkstatic.net/docker-machine-provisioning-on-aws/
http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
https://aws.amazon.com/cli/?nc1=h_ls
https://github.com/docker/machine/issues/584

Tip : Everytime a creation attempt fails, it leaves traces and you have to clean up the house :

./AWSCLI/aws ec2 delete-key-pair –key-name awsslave01

./docker-machine rm -f awsslave01

Posted in Uncategorized

Installing a Windows Server 2016 VM with Docker on it

I use a Windows 10 laptop

First I download the iso :

https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-technical-preview

Then I tried to create a Windows 2016 VM using Virtual box but got no luck there (more exactly : no network connection on the server).

So then I tried Hyper V :

First you need to enable the Hyper-V feature in Windows (from that point, you cannot use VirtualBox anymore, so you need to disable Hyper-V to go back to VB)

I create a new VM in HyperV and declared the iso file as a boot device.

I create a brige (external) and connect the 2nd VM network interface to that bridge

I use a 60Gbs System disk.

Then I start the VM. The server installation takes time but causes no problem. Choose Custom Installation.

Tip : You need to use Right-CTRL for the mouse arrow to escape from the VM Window.

Tip : CTL-ALT-DEL has to be sent from the Action Menu of the VM Window

Then I add the Windows Container extension

Running the ps1 script without weird errors took me quite a while, not to mention a full reinstall of the VM with a non-GUI W2016.

eventually :

w16

In order to contact the docker daemon from the outside, I modified the settings so that the daemon listens to port 2375

Edit C:ProgramData\docker\runDockerDaemon.cmd (with notepad cause I have a minimal server config)

Replacing

docker daemon -D -b “Virtual Switch”

by

docker daemon -D -b “Virtual Switch” -H tcp://0.0.0.0:2375

restarting the docker service :

> restart-service docker

Guessing what the Windows Server IP adress is with “ipconfig /all”

Try to connect from a docker agent running on another host :

$ docker -H tcp://192.168.1.93:2375 info
Containers: 0
Images: 1
Storage Driver: windowsfilter
Windows:
Execution Driver: Windows 1854 1.9.0-dev 4376380
Kernel Version: 10.0 10514 (10514.0.amd64fre.th2_release.150808-1529)
Operating System: Windows Server 2016 Technical Preview 3
CPUs: 1

That works – Yippee !!

Tip : I had to unset the DOCKER_TLS_VERIFY variable first.

I can now add that Windows server to a Docker swarm server. But I won’t do it now cause my swarm server is currently on Gcloud.

Posted in Uncategorized

My life with Docker

I’ve been working quite a lot on Docker over the last few months. I sometimes feel sorry for not keeping track of everything I learned since day one, ideally.. a blog.

First because I’d be able to measure the progress made, see the decisive steps taken, and have an easy access to some old commands and tips. Second because that may be useful to other people.

But hey that’s never too late. So here we go, that post is the first.

I’ll probably use this first post as a placeholder for most of the resources I’ve used :

Books

Podcasts

Videos

And of course sites

Posted in Uncategorized

Docker / Devops : The books

Books, books, books.. I’ve started a few, but finished the wonderful “DevOps” book in August. Even bought a hard copy of it.

51peFvE8UGL._AA324_PIkin4,BottomRight,-52,22_AA346_SH20_OU08_

“What is DevOps ?” is free and really short

61txQiAv6iL._AA324_PIkin4,BottomRight,-38,22_AA300_SH20_OU08_

“The Docker Book” by James Trumbull from Docker is great to learn the basics. Free as well.

51VL0BxrnKL._SX381_BO1,204,203,200_

Also, this one is pretty good and can be used as a reference :

téléchargement (2)

“Building Microservices” is really interesting but I still have to devote time to finish it

téléchargement

 

That book on Kubernetes is really great and helpful :

K8

“Kubernetes: Up and Running” is not available yet but the 4 first chapters are available on Preview

téléchargement (1)

His author, Kelsey Hightower, is a great speaker. More about him later

Posted in Uncategorized

Docker / Devops Sites

Keeping track of interesting sites is hard, I’ll try to do that here

Docker info
https://docs.docker.com/articles/networking/
http://www.dedoimedo.com/computers/docker-networking.html
http://jpetazzo.github.io/assets/2015-03-03-not-so-deep-dive-into-docker-storage-drivers.html#4
http://sirile.github.io/2015/07/15/docker-swarm-and-experimental-multihost-networking-with-docker-machine-and-boot2docker.html
http://engineering.riotgames.com/news/thinking-inside-container
http://containerops.org/2014/12/19/docker-vs-rocket-gimme-a-break/

Kubernetes info
https://github.com/kelseyhightower/intro-to-kubernetes-workshop
https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/getting-started-guides/gce.md
http://www.dasblinkenlichten.com/kubernetes-101-networking/
http://kubernetes.io/v1.0/docs/user-guide/namespaces.html
https://github.com/kelseyhightower/intro-to-kubernetes-workshop/blob/master/labs/cluster-add-on-ui.md
https://coreos.com/blog/introducing-the-kubelet-in-coreos/

DevOps
https://twitter.com/devopscube

Gcloud
https://cloud.google.com/compute/docs/gcloud-compute/

NAT
http://www.linux-france.org/prj/edu/archinet/systeme/ch62s03.html
http://www.karlrupp.net/en/computer/nat_tutorial

LXC
https://www.slideshare.net/slideshow/embed_code/key/uYLzc1HLRpuaCs

CentOS
http://www.rayheffer.com/essential-linux-skills-with-centos-7-managing-services-with-systemd/

CoreOS
https://coreos.com/os/docs/latest/install-debugging-tools.html

Posted in Uncategorized

Docker / Devops : The Podcasts

The Cloud Cast

The Goat Farm

O’Radar

Posted in Uncategorized