http://kubernetes.io/docs/hellonode/
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

  • Horizontal scaling
    Google Container Engine (a Google-hosted version of Kubernetes)

    Google Cloud Platform

TODO : Create an app with hapijs
https://github.com/robertschultz/docker-nodejs-hapi/blob/master/app.js

Create a Docker container image

docker build -t gcr.io/sport-kubernetes-codelab/hello-node:v1 .
docker run -d -p 8080:8080 --name hello_tutorial gcr.io/sport-kubernetes-codelab/hello-node:v1
gcloud docker -- push gcr.io/sport-kubernetes-codelab/hello-node:v1

Create a Kubernetes Cluster

A cluster consists of

  • a Master API server
  • a set of worker VMs called Nodes.

1 - First, choose a Google Cloud Project zone to run your service

gcloud config set compute/zone us-central1-a

2 - Create a Kubernetes cluster (Kubernetes cluster with three ?? nodes, ready to receive your container image!)

gcloud container clusters create hello-world

Now deploy your own containerized application to the Kubernetes cluster!

Create your pod

A Kubernetes pod is a group of containers, tied together for the purposes of administration and networking. It can contain a single container or multiple.

kubectl run hello-node --image=gcr.io/sport-kubernetes-codelab/hello-node:v1 --port=8080

kubectl run created a Deployment object (used to manage creation and scaling of pods) In this example, a new deployment manages a single pod replica running the hello-node:v1 image.

To view the Deployment :
kubectl get deployments

To view the Pod created by the deployment run :

kubectl get pods

To view the stdout / stderr from a Pod run :

kubectl logs <POD-NAME>

Allow external traffic
By default, the pod is only accessible by its internal IP within the Kubernetes cluster.
kubectl expose deployment hello-node –type=”LoadBalancer”
The flag used in this command specifies that we’ll be using the load-balancer provided by the underlying infrastructure (in this case the Compute Engine load balancer).

kubectl get services hello-node
kubectl logs <POD-NAME>

Scale up
Tell the deployment to manage a new number of replicas for your pod: kubectl scale deployment hello-node –replicas=4
kubectl get pods
Se connecter au cluster
Configurez l’accès à la ligne de commande kubectl en exécutant la commande suivante :

gcloud container clusters get-credentials hello-world –zone us-east1-c –project sport-kubernetes-codelab
$
Ensuite, démarrez un proxy pour vous connecter au plan de commande Kubernetes :

kubectl proxy
$
Ouvrez ensuite l’interface du tableau de bord en accédant à l’emplacement suivant dans votre navigateur :

http://localhost:8001/ui

kubectl run hello-node –image=gcr.io/sport-kubernetes-codelab/hello-node:v1 –port=8080
Fix on Windows
http://stackoverflow.com/questions/39277986/unable-to-push-to-google-container-registry-unable-to-access-the-repository?answertab=votes#tab-top
https://github.com/kubernetes/kubernetes/issues/34395

kubectl.sh run postgres –image=postgres –replicas=1

kubectlrun elasticsearch –image=elasticsearch:5.1.1 –replicas=1
kubectl expose deployment elasticsearch –port=9300 –type=ClusterIP

Cleaning it Up

https://developer.ibm.com/recipes/tutorials/kubernetes-how-to-run-a-node-js-application-which-accesses-mongo-database-where-both-are-running-in-containers-in-different-pods/
http://docs.spring.io/spring-cloud-dataflow-server-kubernetes/docs/1.0.1.RELEASE/reference/html/_deploying_streams_on_kubernetes.html

https://www.slalom.com/thinking/packaging-spring-boot-applications-for-deployment-on-kubernetes

http://kubernetes.io/docs/getting-started-guides/meanstack/

http://kubernetes.io/docs/tutorials/stateful-application/run-stateful-application/
http://kubernetes.io/docs/user-guide/pods/single-container/