Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Docker and GKE

Introduction to Docker and GKE

Etsuji Nakai

November 29, 2018
Tweet

More Decks by Etsuji Nakai

Other Decks in Technology

Transcript

  1. 1 2 3 5 6 7 8 9 10 11

    12 13 14 15 16 17 <Start Training> </Start Training> Etsuji Nakai Solutions Architect, Google Cloud Introduction to Docker and GKE
  2. 1 2 3 4 Google Container Engine From Borg to

    Kubernetes Docker Quick Tour Container Technology Agenda
  3. What you can do with Docker? Dockerfile ① Build a

    container image Application configuration files Application binaries / libraries Describe steps to build a container Container Image Containing minimum files Necessary to run the application ② Store and share container images ③ Deploy and execute images on host machines OS files Host Machine Image Registry
  4. What is Linux Container? Physical / Virtual Machine Application Application

    ・・・ Physical / Virtual Machine Linux Kernel Traditional Linux environment   Container environment Container Container ・・・ All applications see the same OS environment ▪ Linux container is a technology to "show" independent OS environments to different process groups. Linux Kernel Application Application Each container sees an independent environment • Local disk contents / Network (NIC, IP) / CPU , Memory resource / etc...
  5. Resource Separation with Namespaces ▪ There are different mechanisms inside

    Linux kernel to split various resources. • • • Filesystem Hostname Inter process communication Users (UID/GID) Process table Network configuration CPU / Memory resources * Mount namespace (kernel 2.4.19) * UTS namespace (kernel 2.6.19) * IPC namespece (kernel 2.6.19) * User namespace (kernel 2.6.23 〜kernel 3.8) • • • • * PID namespace (kernel 2.6.24) * Network Namepsace (kernel 2.6.24) * Control groups ※ Reference " Namespaces in operation, part 1: namespaces overview " http:/ lwn.net/Articles/531114/ ▪ Linux container is realized by combining these mechanisms. Strictly speaking, there's no single technology you can call "container."
  6. Container Image Management ▪ The container image is just a

    disk image (tar archive) associated with environment information like network configurations. ▪ The real uniqueness of Docker is its image management features. ▪ Dockerfile : Mechanism to automate image build process ▪ Image Registry : Mechanism to share and distribute container images Container Application Container Image Directory tree Attach as a root directory Mount locally on the host machine
  7. 1 2 3 4 Google Container Engine From Borg to

    Kubernetes Docker Quick Tour Container Technology Agenda
  8. Lifecycle of Container Snapshot image is created at container launch.

    commit Stopping container means stopping processes. Snapshot is kept remained. Snapshot is discarded when a container is removed You can clone the snapshot and store as a new image. Snapshot Processes Snapshot stop start rm Locally Stored Image run ✕ Locally Stored Image
  9. Network Communication with Container Container Host Linux vethXX eth0 docker0

    eth0 External network 172.17.42.1 # docker run -d -p 8000:80 ・・・ Connect to IP of the host Linux TCP 8000 TCP 80 Port Forwarding ▪ External communication is proxied (nat-ed) on the host Linux. • • IP Masquarade is applied to packets from container to the external network. Port forwarding is configured with container options for packets from the external network.
  10. Sample Operations of Docker ▪ Launching Apache HTTP Server. $

    docker search httpd NAME DESCRIPTION STARS OFFICIAL AUTOMATED httpd The Apache HTTP Server Project 780 [OK] centos/httpd 9 [OK] ... $ docker pull httpd $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE httpd latest 3076aa23a73c 9 days ago 193.3 MB $ docker run -d --name webserver -p 8080:80 httpd:latest a101d9d6fbf78a5c1b0fcf1339f1ee1a4f94eb7c9a74e51ea769d2050f84712c $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a101d9d6fbf7 httpd:latest "httpd-foreground" 2 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp webserver $ echo '<h1>Hello, World!</h1>' > /tmp/index.html $ docker cp /tmp/index.html webserver:/usr/local/apache2/htdocs/index.html
  11. Sample Operations of Docker ▪ Looking inside a container by

    launching a bash process. $ docker exec -it webserver bash root@a101d9d6fbf7:/usr/local/apache2# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 23:20 ? 00:00:00 httpd -DFOREGROUND daemon 8 1 0 23:20 ? 00:00:00 httpd -DFOREGROUND daemon 9 1 0 23:20 ? 00:00:00 httpd -DFOREGROUND daemon 10 1 0 23:20 ? 00:00:00 httpd -DFOREGROUND root 118 0 2 23:38 ? 00:00:00 bash root 124 118 0 23:38 ? 00:00:00 ps -ef root@a101d9d6fbf7:/usr/local/apache2# ip a ... 5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc noqueue state UP group default link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff inet 172.18.0.2/16 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::42:acff:fe12:2/64 scope link valid_lft forever preferred_lft forever root@a101d9d6fbf7:/usr/local/apache2# df Filesystem 1K-blocks Used Available Use% Mounted on none 10188088 5695284 3952236 60% / tmpfs 304344 0 304344 0% /dev tmpfs 304344 0 304344 0% /sys/fs/cgroup /dev/sda1 10188088 5695284 3952236 60% /etc/hosts shm 65536 0 65536 0% /dev/shm root@a101d9d6fbf7:/usr/local/apache2# exit
  12. 1 2 3 4 Google Container Engine From Borg to

    Kubernetes Docker Quick Tour Container Technology Agenda
  13. Containers at Google ▪ Large-scale cluster management at Google with

    Borg • http://research.google.com/pubs/pub43438.html ▪ Borg, Omega, and Kubernetes • http://research.google.com/pubs/pub44843.html
  14. Infrastructure for Planet-scale Services ▪ Globally Standardized Datacenters ▪ Focus

    on Application Management (OS layers should be invisible) ▪ Optimized Application Deployment with Resource Schedulers ▪ Abstraction and Autoscaling of Services ▪ Splitting Datastore and Application Runtime Built on Distributed Computing Technology Datacenter as a Computer Borg
  15. Kubernetes ▪ Open source project for container orchestration tool. ▪

    Based on the Google's experience in container management. ▪ Useful features to manage microservices: ◦ Autoscale of pods ◦ Blue Green Deployment ◦ Rolling update ◦ etc.
  16. Microservice Management with Deployment and Service ▪ Deployment :Launch and

    scale multiple Pods from the same image. ▪ Service :Create a virtual IP address for Pods with the sama image. ReplicaSet - - replicas: 3 selector: - - app: MyApp version: v1 Deployment - name: MyApp Virtual IP Service - name: MyService
  17. Blue Green Deployment ReplicaSet - - replicas: 3 selector: -

    - app: MyApp version: v1 ReplicaSet - - replicas: 3 selector: - - app: MyApp version: v2 ▪ Launching groups of Pods with different versions. ▪ Change the default version by reconfiguring the Service. Virtual IP
  18. Rolling Update ▪ Live update of services. ▪ Replacing Pods

    under the same deployment with a new version image. ReplicaSet - - replicas: 3 selector: - - app: MyApp version: v1 ReplicaSet - - replicas: 3 selector: - - app: MyApp version: v2 Add v2 Pods Remove v1 Pods
  19. 1 2 3 4 Google Kubernetes Engine From Borg to

    Kubernetes Docker Quick Tour Container Technology Agenda
  20. GKE : Google Kubernetes Engine ▪ Managed service environment on

    GCP for Kubernetes clusters. ▪ Autobuild Kubernetes clusters through GUI/CUI/API. ▪ Easy integration with external datastore services such as Cloud SQL and Cloud Datastore. ▪ Easy integration with external networking services such as Cloud Load Balancing.