SlideShare a Scribd company logo
DOCKER, KUBERNETES, AND GCP
How do you use these complementary tools to deploy containers in the Cloud?
THE BASICS
CONTAINER TECH
Nothing new… Existed for years
Linux has LXC and Libcontainer, BSD has Jails, Solaris has
Zones
Docker (the company) just figured a clever way to packaging it
and adding a rich toolset around it.
DOCKER BASICS
•  Docker runs on Linux x64 (only)
•  Dependent on libcontainer, a Linux container platform
•  Container isolation (sandbox): filesystem, process, network
•  Layered filesystem
•  Benefits
•  Versioning
•  Portability
•  Lightweight
•  Faster to launch
DOCKER WORKFLOW
Dockerfile
Docker Client
docker build
Image
Docker Client
docker run
Container
Docker Client
docker pull
docker push
Docker Registry
Infrastructure
Client
swarm
kubernetes
meso
DOCKER ON MAC
•  Let’s focus on running Docker on the Mac
•  Remember Docker only runs on Linux x64
•  How do I run it on the Mac?
•  Need Virtual Machine to emulate a Linux host
•  Virtual machine (VM) running Linux x64
•  Docker engine running on VM
•  Mac client to communicate with Docker engine on Linux VM
DOCKER FOR MAC VS DOCKER TOOLBOX
Docker for Mac Docker Toolbox
# VMs 1 Multiple
Underlying VM
Hypervisor.framework
(xhyve)
VirtualBox
Base OS Alpine Boot2Docker
(VM) Management Tool Docker.app docker-machine
(VM) Management UI GUI CLI
MAC DOCKER ARCHITECTURE
Mac OS X
Virtual Machine (VirtualBox)Docker client
docker (CLI)
Kinematic (GUI)
Docker Machine
Linux (Boot2Docker)
Container
1
Container
2
Kernel
Docker Engine
Docker
Daemon
API
docker
(CLI)
KUBERNETES ARCHITECTURE
Master
API Server
Replication Scheduler
Config
(etcd)
Client
kubectl
Node
Kubelet
Kube-proxy
Pod 1
Container
Container
Container Engine
Pod 2
Container
KUBERNETES BASICS
•  Tool to orchestrate containers at scale and managing the application/service stack
•  Master
•  API Server and kubectl (client) – communicate and define the desired state
•  Scheduler – schedule workload on nodes
•  Replication – correct number of pod replicas
•  Config – distributed config store
•  Node (Slave)
•  Kubelet – communicate with master and start workloads
•  Kube-proxy – load balancer and direct traffic
•  Pod – group of 1..n containers tied together for admin and networking
•  Cluster = masters + nodes
DEMO
Tying together what we have learned so far and deploy Docker containers to Google
Cloud
HELLO WORLD ON GOOGLE CLOUD
(KUBERNETES)
http://kubernetes.io/docs/hellonode/
PRE-REQUISITES – SERVER SIDE
1.  Go to https://console.cloud.google.com/
2.  Create a GCP Project
3.  Copy the GCP Project ID
PRE-REQUISITES – CLIENT (MAC) SIDE
# Install node and nvm (node version manager)
$ brew update
$ brew install nvm
$ # Add the following to ~/.bash_profile
$ # export NVM_DIR=~/.nvm
$ # source $(brew --prefix nvm)/nvm.sh
$ nvm install 7.0.0
PRE-REQUISITES – CLIENT (MAC) SIDE II
$ # Install docker
$ brew install docker-compose # should also install docker and
docker-machine
$ # Install google cloud sdk
$ brew cask install google-cloud-sdk
$ gcloud components install kubectl
$ # You may want to add the following:
$ EXPORT PATH=$PATH:/opt/homebrew-cask/Caskroom/google-cloud-
sdk/latest/google-cloud-sdk/bin/
$ # Set up Google Cloud environment
$ export PROJECT_ID="my-google-cloud-project-id"
AUTHENTICATION
# Set up your account with google cloud sdk
$ gcloud auth login my-registered-email
$ gcloud config set project my-google-cloud-project-
id
$ gcloud auth list
# Optional: env var set for convenience
$ export PROJECT_ID="my-google-cloud-project-id"
$ # Note: your project-id != project name
NODE.JS CODE
// Filename: server.js
var http = require('http');
var handleRequest = function(request, response) {
console.log('Received request for URL: ' + request.url);
response.writeHead(200);
response.end('Hello World!');
};
var www = http.createServer(handleRequest);
www.listen(8080);
RUN DOCKER-MACHINE ON LOCAL VM
$ # Before running any docker commands, run docker-machine
to create a VirtualBox instance
$ docker-machine create --driver virtualbox default
$ docker-machine env
$ eval "$(docker-machine env default)"
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.12.0
DOCKERFILE
FROM node:7.0.0
ADD server.js .
EXPOSE 8080
CMD node server.js
DOCKER BUILD
$ # Build docker image
$ docker images
$ docker build -t gcr.io/$PROJECT_ID/helloworld:v1 .
$ # Please get your project id right.
$ # project name != project id. For example
$ # project name = helloworld-kubernetes
$ # project id = helloworld-kubernetes-148321
RUN LOCALLY
$ # Run docker locally
$ docker run -d -p 8080:8080 --name helloworld gcr.io/helloworld-kubernetes/
helloworld:v1
$ # Docker machine
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.12.3
$ # Docker containers running
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
3047947245fa gcr.io/helloworld-kubernetes/helloworld:v1 "/bin/sh -c 'node ser" 4 minutes ago Up 3
minutes 0.0.0.0:8080->8080/tcp helloworld
$ curl http://192.168.99.100:8080
Hello World!
# Or just do curl $(docker-machine ip default):8080
PRIVATE DOCKER REGISTRY (EMPTY)
PUSH IMAGE TO PRIVATE GOOGLE REGISTRY
$ docker images
$ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v1
$ # If gcloud docker -- push doesn’t work, you probably
didn’t set your project id properly.
$ # project name != project id. For example
$ # project name = helloworld-kubernetes
$ # project id = helloworld-kubernetes-148321
PRIVATE DOCKER REGISTRY
PUSH IMAGE TO PRIVATE GOOGLE REGISTRY
$ docker images
$ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v1
$ # If gcloud docker -- push doesn’t work, you probably
didn’t set your project id properly.
$ # project name != project id. For example
$ # project name = helloworld-kubernetes
$ # project id = helloworld-kubernetes-148321
CREATE A CONTAINER CLUSTER
CONFIGURE A CONTAINER CLUSTER
CREATED CONTAINER CLUSTER
GET CREDENTIALS FOR KUBECTL
•  API Manager > Create
Credentials > Service
Account Key
•  JSON Key type
•  Download the json file
AUTH FOR KUBECTL
$ # If you run kubectl, you see an error message
$ kubectl version
error: google: could not find default credentials. See https://
developers.google.com/accounts/docs/application-default-credentials
for more information.
$ You need to authenticate with the crentials
$ export GOOGLE_APPLICATION_CREDENTIALS=~/helloworld-
kubernetes-abcde00000.json
$ gcloud auth application-default login
$ kubectl version # Should work now
RUN KUBERNETES NODE
$ # Create and run a Kubernetes pod
$ kubectl run helloworld --image=gcr.io/$PROJECT_ID/helloworld:v1 --
port=8080
deployment "helloworld" created
$ # Print deployments
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
helloworld 1 1 1 1 1m
$ # Print pods
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-2696007752-golst 1/1 Running 0 5m
TEST WEBSITE
$ # Expose pod. By default a Kubernetes node is only
accessible by its internal IP address
$ kubectl expose deployment helloworld --
type="LoadBalancer"
$ kubectl get services helloworld
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloworld 10.3.247.187 104.198.6.146 8080/TCP 2m
$ curl 104.198.6.146:8080
Hello World!
SCALE WEBSITE
$ # Scale the pod to 4 replicas
$ kubectl scale deployment helloworld --replicas=4
$ # Get status
$ kubectl get deployment
$ kubectl get pods
CHANGE CODE AND UPDATE GCP
$ # Edit server.js
$ vi server.js
$ # Build and push changes
$ docker build -t gcr.io/$PROJECT_ID/helloworld:v2 .
$ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v2
$ # Deploy changes
$ kubectl set image deployment/helloworld helloworld=gcr.io/$PROJECT_ID/helloworld:v2
$ deployment "helloworld" image updated
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-2696007752-bergs 1/1 Terminating 0 15m
helloworld-2696007752-c87rs 1/1 Terminating 0 15m
helloworld-2696007752-golst 1/1 Terminating 0 14h
helloworld-2696007752-zwpi4 1/1 Terminating 0 15m
helloworld-2777403465-e802v 1/1 Running 0 11s
helloworld-2777403465-ksyxe 0/1 ContainerCreating 0 5s
helloworld-2777403465-rgq7f 1/1 Running 0 11s
helloworld-2777403465-six3e 1/1 Running 0 4s
$ kubectl get services helloworld
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloworld 10.3.247.187 104.198.6.146 8080/TCP 14h
$ curl 104.198.6.146:8080
Hello World 2!
CLEAN UP
$ # Delete pod
$ kubectl delete service,deployment helloworld
$ # Delete container cluster
$ gcloud container clusters delete helloworld
Q + A
Any questions?
You can find me at @cybersam

More Related Content

What's hot

Dockers and kubernetes
Dockers and kubernetesDockers and kubernetes
Dockers and kubernetes
Dr Ganesh Iyer
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
Sathish VJ
 
Compare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudCompare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloud
Sreenivas Makam
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
NexThoughts Technologies
 
Docker 101 Checonf 2016
Docker 101 Checonf 2016Docker 101 Checonf 2016
Docker 101 Checonf 2016
Patrick Chanezon
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
Ajeet Singh Raina
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Mario Ishara Fernando
 
How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker
Jonathan Martin
 
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Carlos Sanchez
 
Developer workflow with docker
Developer workflow with dockerDeveloper workflow with docker
Developer workflow with docker
Lalatendu Mohanty
 
Introduction to Containers - SQL Server and Docker
Introduction to Containers - SQL Server and DockerIntroduction to Containers - SQL Server and Docker
Introduction to Containers - SQL Server and Docker
Chris Taylor
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
Giacomo Vacca
 
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Orchestrating Docker Containers with Google Kubernetes on OpenStackOrchestrating Docker Containers with Google Kubernetes on OpenStack
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Trevor Roberts Jr.
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux ContainerBalaji Rajan
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
Mathieu Buffenoir
 
Orchestrating Docker containers at scale
Orchestrating Docker containers at scaleOrchestrating Docker containers at scale
Orchestrating Docker containers at scale
Maciej Lasyk
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and tools
Ramit Surana
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
andersjanmyr
 
Docker 101 - High level introduction to docker
Docker 101 - High level introduction to dockerDocker 101 - High level introduction to docker
Docker 101 - High level introduction to docker
Dr Ganesh Iyer
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paas
rajdeep
 

What's hot (20)

Dockers and kubernetes
Dockers and kubernetesDockers and kubernetes
Dockers and kubernetes
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Compare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudCompare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloud
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Docker 101 Checonf 2016
Docker 101 Checonf 2016Docker 101 Checonf 2016
Docker 101 Checonf 2016
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
 
How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker
 
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
 
Developer workflow with docker
Developer workflow with dockerDeveloper workflow with docker
Developer workflow with docker
 
Introduction to Containers - SQL Server and Docker
Introduction to Containers - SQL Server and DockerIntroduction to Containers - SQL Server and Docker
Introduction to Containers - SQL Server and Docker
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Orchestrating Docker Containers with Google Kubernetes on OpenStackOrchestrating Docker Containers with Google Kubernetes on OpenStack
Orchestrating Docker Containers with Google Kubernetes on OpenStack
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
 
Orchestrating Docker containers at scale
Orchestrating Docker containers at scaleOrchestrating Docker containers at scale
Orchestrating Docker containers at scale
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and tools
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Docker 101 - High level introduction to docker
Docker 101 - High level introduction to dockerDocker 101 - High level introduction to docker
Docker 101 - High level introduction to docker
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paas
 

Viewers also liked

GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the CloudGCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
Samuel Chow
 
Getting started with docker
Getting started with dockerGetting started with docker
Getting started with docker
JEMLI Fathi
 
Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
Dmitry Lazarenko
 
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
DynamicInfraDays
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
Arun Gupta
 
Docker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - GoraeDocker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - Gorae
Rhio kim
 
Docker swarm
Docker swarmDocker swarm
Container Orchestration
Container OrchestrationContainer Orchestration
Container Orchestration
dfilppi
 
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
Neo4j
 
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
PLUMgrid
 
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea LuzzardiWhat's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Mike Goelzer
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Giovanni Toraldo
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introduction
Evan Lin
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
rajdeep
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
Carlos Sanchez
 
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
Ontico
 
Container Orchestration Wars
Container Orchestration WarsContainer Orchestration Wars
Container Orchestration Wars
Karl Isenberg
 
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
NAVER D2
 
Swarm migration
Swarm migrationSwarm migration
Swarm migration
Janakiram MSV
 
Docker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker SwarmDocker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker Swarm
Docker, Inc.
 

Viewers also liked (20)

GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the CloudGCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
 
Getting started with docker
Getting started with dockerGetting started with docker
Getting started with docker
 
Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
 
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
 
Docker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - GoraeDocker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - Gorae
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Container Orchestration
Container OrchestrationContainer Orchestration
Container Orchestration
 
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
An Introduction to Container Organization with Docker Swarm, Kubernetes, Meso...
 
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
Docker Networking in Swarm, Mesos and Kubernetes [Docker Meetup Santa Clara |...
 
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea LuzzardiWhat's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introduction
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
 
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
Evaluation of High Availability Performance of Kubernetes and Docker Swarm on...
 
Container Orchestration Wars
Container Orchestration WarsContainer Orchestration Wars
Container Orchestration Wars
 
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
[D2 COMMUNITY] Open Container Seoul Meetup - Running a container platform in ...
 
Swarm migration
Swarm migrationSwarm migration
Swarm migration
 
Docker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker SwarmDocker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker Swarm
 

Similar to Docker, Kubernetes, and Google Cloud

Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
Erica Windisch
 
Docker 進階實務班
Docker 進階實務班Docker 進階實務班
Docker 進階實務班
Philip Zheng
 
廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班
Paul Chao
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 
Running .NET on Docker
Running .NET on DockerRunning .NET on Docker
Running .NET on Docker
Ben Hall
 
Docker workshop
Docker workshopDocker workshop
Docker workshopEvans Ye
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
Runcy Oommen
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
Philip Zheng
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
Henryk Konsek
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
Alper Kanat
 
Docker
DockerDocker
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
Docker, Inc.
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
Philip Zheng
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
Paul Chao
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
Ben Hall
 
Docker^3
Docker^3Docker^3
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Philip Zheng
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PROIDEA
 

Similar to Docker, Kubernetes, and Google Cloud (20)

Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
 
Docker 進階實務班
Docker 進階實務班Docker 進階實務班
Docker 進階實務班
 
廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 
Running .NET on Docker
Running .NET on DockerRunning .NET on Docker
Running .NET on Docker
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Docker
DockerDocker
Docker
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Docker^3
Docker^3Docker^3
Docker^3
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 

More from Samuel Chow

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Terraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCPTerraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCP
Samuel Chow
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
Samuel Chow
 
UI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesUI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesSamuel Chow
 
Mobile Analytics
Mobile AnalyticsMobile Analytics
Mobile Analytics
Samuel Chow
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release Management
Samuel Chow
 
Frisbee Thrower Prototype
Frisbee Thrower PrototypeFrisbee Thrower Prototype
Frisbee Thrower Prototype
Samuel Chow
 
Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)
Samuel Chow
 

More from Samuel Chow (8)

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Terraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCPTerraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCP
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
UI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesUI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best Practices
 
Mobile Analytics
Mobile AnalyticsMobile Analytics
Mobile Analytics
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release Management
 
Frisbee Thrower Prototype
Frisbee Thrower PrototypeFrisbee Thrower Prototype
Frisbee Thrower Prototype
 
Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)
 

Recently uploaded

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 

Docker, Kubernetes, and Google Cloud

  • 1. DOCKER, KUBERNETES, AND GCP How do you use these complementary tools to deploy containers in the Cloud?
  • 3. CONTAINER TECH Nothing new… Existed for years Linux has LXC and Libcontainer, BSD has Jails, Solaris has Zones
  • 4. Docker (the company) just figured a clever way to packaging it and adding a rich toolset around it.
  • 5. DOCKER BASICS •  Docker runs on Linux x64 (only) •  Dependent on libcontainer, a Linux container platform •  Container isolation (sandbox): filesystem, process, network •  Layered filesystem •  Benefits •  Versioning •  Portability •  Lightweight •  Faster to launch
  • 6. DOCKER WORKFLOW Dockerfile Docker Client docker build Image Docker Client docker run Container Docker Client docker pull docker push Docker Registry Infrastructure Client swarm kubernetes meso
  • 7. DOCKER ON MAC •  Let’s focus on running Docker on the Mac •  Remember Docker only runs on Linux x64 •  How do I run it on the Mac? •  Need Virtual Machine to emulate a Linux host •  Virtual machine (VM) running Linux x64 •  Docker engine running on VM •  Mac client to communicate with Docker engine on Linux VM
  • 8. DOCKER FOR MAC VS DOCKER TOOLBOX Docker for Mac Docker Toolbox # VMs 1 Multiple Underlying VM Hypervisor.framework (xhyve) VirtualBox Base OS Alpine Boot2Docker (VM) Management Tool Docker.app docker-machine (VM) Management UI GUI CLI
  • 9. MAC DOCKER ARCHITECTURE Mac OS X Virtual Machine (VirtualBox)Docker client docker (CLI) Kinematic (GUI) Docker Machine Linux (Boot2Docker) Container 1 Container 2 Kernel Docker Engine Docker Daemon API docker (CLI)
  • 10. KUBERNETES ARCHITECTURE Master API Server Replication Scheduler Config (etcd) Client kubectl Node Kubelet Kube-proxy Pod 1 Container Container Container Engine Pod 2 Container
  • 11. KUBERNETES BASICS •  Tool to orchestrate containers at scale and managing the application/service stack •  Master •  API Server and kubectl (client) – communicate and define the desired state •  Scheduler – schedule workload on nodes •  Replication – correct number of pod replicas •  Config – distributed config store •  Node (Slave) •  Kubelet – communicate with master and start workloads •  Kube-proxy – load balancer and direct traffic •  Pod – group of 1..n containers tied together for admin and networking •  Cluster = masters + nodes
  • 12. DEMO Tying together what we have learned so far and deploy Docker containers to Google Cloud
  • 13. HELLO WORLD ON GOOGLE CLOUD (KUBERNETES) http://kubernetes.io/docs/hellonode/
  • 14. PRE-REQUISITES – SERVER SIDE 1.  Go to https://console.cloud.google.com/ 2.  Create a GCP Project 3.  Copy the GCP Project ID
  • 15. PRE-REQUISITES – CLIENT (MAC) SIDE # Install node and nvm (node version manager) $ brew update $ brew install nvm $ # Add the following to ~/.bash_profile $ # export NVM_DIR=~/.nvm $ # source $(brew --prefix nvm)/nvm.sh $ nvm install 7.0.0
  • 16. PRE-REQUISITES – CLIENT (MAC) SIDE II $ # Install docker $ brew install docker-compose # should also install docker and docker-machine $ # Install google cloud sdk $ brew cask install google-cloud-sdk $ gcloud components install kubectl $ # You may want to add the following: $ EXPORT PATH=$PATH:/opt/homebrew-cask/Caskroom/google-cloud- sdk/latest/google-cloud-sdk/bin/ $ # Set up Google Cloud environment $ export PROJECT_ID="my-google-cloud-project-id"
  • 17. AUTHENTICATION # Set up your account with google cloud sdk $ gcloud auth login my-registered-email $ gcloud config set project my-google-cloud-project- id $ gcloud auth list # Optional: env var set for convenience $ export PROJECT_ID="my-google-cloud-project-id" $ # Note: your project-id != project name
  • 18. NODE.JS CODE // Filename: server.js var http = require('http'); var handleRequest = function(request, response) { console.log('Received request for URL: ' + request.url); response.writeHead(200); response.end('Hello World!'); }; var www = http.createServer(handleRequest); www.listen(8080);
  • 19. RUN DOCKER-MACHINE ON LOCAL VM $ # Before running any docker commands, run docker-machine to create a VirtualBox instance $ docker-machine create --driver virtualbox default $ docker-machine env $ eval "$(docker-machine env default)" $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.100:2376 v1.12.0
  • 20. DOCKERFILE FROM node:7.0.0 ADD server.js . EXPOSE 8080 CMD node server.js
  • 21. DOCKER BUILD $ # Build docker image $ docker images $ docker build -t gcr.io/$PROJECT_ID/helloworld:v1 . $ # Please get your project id right. $ # project name != project id. For example $ # project name = helloworld-kubernetes $ # project id = helloworld-kubernetes-148321
  • 22. RUN LOCALLY $ # Run docker locally $ docker run -d -p 8080:8080 --name helloworld gcr.io/helloworld-kubernetes/ helloworld:v1 $ # Docker machine $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.100:2376 v1.12.3 $ # Docker containers running $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3047947245fa gcr.io/helloworld-kubernetes/helloworld:v1 "/bin/sh -c 'node ser" 4 minutes ago Up 3 minutes 0.0.0.0:8080->8080/tcp helloworld $ curl http://192.168.99.100:8080 Hello World! # Or just do curl $(docker-machine ip default):8080
  • 24. PUSH IMAGE TO PRIVATE GOOGLE REGISTRY $ docker images $ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v1 $ # If gcloud docker -- push doesn’t work, you probably didn’t set your project id properly. $ # project name != project id. For example $ # project name = helloworld-kubernetes $ # project id = helloworld-kubernetes-148321
  • 26. PUSH IMAGE TO PRIVATE GOOGLE REGISTRY $ docker images $ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v1 $ # If gcloud docker -- push doesn’t work, you probably didn’t set your project id properly. $ # project name != project id. For example $ # project name = helloworld-kubernetes $ # project id = helloworld-kubernetes-148321
  • 30. GET CREDENTIALS FOR KUBECTL •  API Manager > Create Credentials > Service Account Key •  JSON Key type •  Download the json file
  • 31. AUTH FOR KUBECTL $ # If you run kubectl, you see an error message $ kubectl version error: google: could not find default credentials. See https:// developers.google.com/accounts/docs/application-default-credentials for more information. $ You need to authenticate with the crentials $ export GOOGLE_APPLICATION_CREDENTIALS=~/helloworld- kubernetes-abcde00000.json $ gcloud auth application-default login $ kubectl version # Should work now
  • 32. RUN KUBERNETES NODE $ # Create and run a Kubernetes pod $ kubectl run helloworld --image=gcr.io/$PROJECT_ID/helloworld:v1 -- port=8080 deployment "helloworld" created $ # Print deployments $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE helloworld 1 1 1 1 1m $ # Print pods $ kubectl get pods NAME READY STATUS RESTARTS AGE helloworld-2696007752-golst 1/1 Running 0 5m
  • 33. TEST WEBSITE $ # Expose pod. By default a Kubernetes node is only accessible by its internal IP address $ kubectl expose deployment helloworld -- type="LoadBalancer" $ kubectl get services helloworld NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE helloworld 10.3.247.187 104.198.6.146 8080/TCP 2m $ curl 104.198.6.146:8080 Hello World!
  • 34. SCALE WEBSITE $ # Scale the pod to 4 replicas $ kubectl scale deployment helloworld --replicas=4 $ # Get status $ kubectl get deployment $ kubectl get pods
  • 35. CHANGE CODE AND UPDATE GCP $ # Edit server.js $ vi server.js $ # Build and push changes $ docker build -t gcr.io/$PROJECT_ID/helloworld:v2 . $ gcloud docker -- push gcr.io/$PROJECT_ID/helloworld:v2 $ # Deploy changes $ kubectl set image deployment/helloworld helloworld=gcr.io/$PROJECT_ID/helloworld:v2 $ deployment "helloworld" image updated $ kubectl get pods NAME READY STATUS RESTARTS AGE helloworld-2696007752-bergs 1/1 Terminating 0 15m helloworld-2696007752-c87rs 1/1 Terminating 0 15m helloworld-2696007752-golst 1/1 Terminating 0 14h helloworld-2696007752-zwpi4 1/1 Terminating 0 15m helloworld-2777403465-e802v 1/1 Running 0 11s helloworld-2777403465-ksyxe 0/1 ContainerCreating 0 5s helloworld-2777403465-rgq7f 1/1 Running 0 11s helloworld-2777403465-six3e 1/1 Running 0 4s $ kubectl get services helloworld NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE helloworld 10.3.247.187 104.198.6.146 8080/TCP 14h $ curl 104.198.6.146:8080 Hello World 2!
  • 36. CLEAN UP $ # Delete pod $ kubectl delete service,deployment helloworld $ # Delete container cluster $ gcloud container clusters delete helloworld
  • 37. Q + A Any questions? You can find me at @cybersam