google cloud platform kubernetes workshop iyte

68
Google Cloud Platform Kubernetes Workshop www.zetaops.io Simplicity is the ultimate sophistication Leonardo da Vinci 8 Kasım 2017, Çarşamba İYTE İnovasyon Merkezi

Upload: gokhan-boranalp

Post on 22-Jan-2018

149 views

Category:

Technology


1 download

TRANSCRIPT

Google Cloud PlatformKubernetes Workshop

www.zetaops.io

Simplicity is the ultimate sophistication

Leonardo da Vinci“ “8 Kasım 2017, ÇarşambaİYTE İnovasyon Merkezi

Shoshin(初心) is a concept in Zen Buddhism meaning "beginner's mind". It refers to having an attitude of openness, eagerness, and lack of preconceptions when studying a subject, even when studying at an advanced level, just as a beginner in that subject would.

Program

● 09:45 - 10:15, Önder Güler, Google Cloud Country Manager, Google Cloud Vizyonu

● 10:15 - 11:30, Pınar Uğurlu Kirazcı, Cloud Customer Engineer, Google, Google Cloud Servislerine Teknik Bakış

● 11:30 - 12:30, Gökhan Boranalp, Zetaops, Sanallaştırma temelleri, Virtual machines, LX{C,D} Containers, Unikernels

● 13:30 - 14:15, Gökhan Boranalp, Zetaops, GCloud sdk tanıtımı● 14:30 - 15:45, Gökhan Boranalp, Zetaops, Kubernetes nedir?

Bileşenleri nelerdir?● 14:30 - 15:45, Pınar Uğurlu Kirazcı, Cloud Customer Engineer, Google,

Kubernetes Fast Track Demo● 15:30 - 16:30, Gökhan Boranalp, Zetaops, Kubernetes ile örnek bir

dağıtık web uygulaması● 16:45 - 17:15, Gökhan Boranalp, Zetaops, Soru cevap

Sanallaştırma Temelleri

Sanallaştırma Temelleri - Types

● Full virtualization: running an unmodified OS, Parallels, VirtualBox, XEN

● Paravirtualization: running a modified guest system (kernel), XEN, QEMU, KVM

● OS-level virtualization: enables running an isolated process (tree), OpenVZ, LXC, BSD-jails, Linux-VServer, Solaris Zones

● Virtualized Containers, LXC, LXD, Docker

Sanallaştırma Temelleri

Sanallaştırma Temelleri

● Sanal makinalar stateful● Büyük VM’ler: Depolama VM içinde,

tüm servisler aynı VM içinde, kocaman vCPU ve vRAM

● Uygulama SLA kuralları VM hayatta kalsın diye var.

● Dağıtıklık ve fail durumu için eldeki HA teknolojisine bağlı

● VM’ler kurulumdan sonra CPU ve RAM bakımından ölçeklenebilir.

● Uygulamalar VM’in crash olması durumuna göre geliştirilmemiştir.

● Örnek: Aynı VM üzerinde, database, web

server, frontend app birlikte çalışıyor.

● Uygulamalar dağıtık olmak üzere tasarlanmıştır. VM’ler stateless haldedir.

● VM’ler küçüktür. ● Uygulama SLA kuralları tüm

uygulama içindir. Bir VM için değil.

● Uygulama çok sayıda instance üzerinde çalışmaktadır.

● Uygulamanın ölçeklendirilmesi için anlık olarak VM eklenebilir.

● Uygulamalar VM’lerin fail olması durumuna göre geliştirilmiştir.

PETS CATTLE

Sanallaştırma Temelleri

Sanallaştırma Temelleri

Sanallaştırma Temelleri - Docker

● Docker Engine - Runs on “Linux” to create the operating environment for your distributed applications.

● Docker Machine - Automate Docker provisioning.

● Docker Swarm - Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host.

Sanallaştırma Temelleri - Docker

● Docker Compose - Compose is a tool for defining and running multi-container Docker applications.

● Docker Registry - The Registry is a stateless, highly scalable server side application that stores and lets you distribute Docker images.

● Docker Toolbox - The Docker Toolbox is an installer to install and setup a Docker environment on your computer.

Sanallaştırma Temelleri - Docker

● Dockerfile anatomy● Dockerfile example● Docker registry● Running Docker properly

Sanallaştırma Temelleri - Docker

Sanallaştırma Temelleri - Docker

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

GCloud SDK

● https://cloud.google.com/sdk/● https://cloud.google.com/sdk/gcloud/ref

erence/● Örnek komutlar

Kubernetes

12 factor

https://12factor.net/

12 factor

Mikro servisler

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Kubernetes

Hands on Kubernetes

Master: Kubernetes control panel or control plane. This is where decisions are made about the cluster, such as scheduling, and detecting/responding to cluster events. The components of the master can be run on any node in the cluster. Key components of the master:

API Server — This is the only component of the Kubernetes control panel with a user-accessible API and the sole master component that you’ll interact with. The API server exposes a restful Kubernetes API and consumes JSON manifest files.

Cluster State&Data Store — Kubernetes uses “etcd.” This is a strong consistent, and highly-available key value store that Kubernetes uses for persistent storage of all API objects. Think of it as the “source of truth” for the cluster.

Hands on Kubernetes

Hands on Kubernetes

Controller Manager — Known as the “kube-controller manager,” this runs all the controllers that handle routine tasks in the cluster. These include the Node Controller, Replication Controller, Endpoints Controller, and Service Account and Token Controllers. Each of these controllers works separately to maintain the desired state.

Hands on Kubernetes

Scheduler — The scheduler watches for newly-created pods (groups of one or more containers) and assigns them to nodes.

Dashboard (optional) — Kubernetes web UI that simplifies the Kubernetes cluster user’s interactions with the API server.

Kubernetes Worker Nodes

Master handles and manages the cluster, worker nodes run the containers and provide the Kubernetes runtime environment. Worker nodes comprise a kubelet. This is the primary node agent. It watches the API server for pods that have been assigned to its node. Kubelet carries out tasks and maintains a reporting backchannel of pod status to the master node.

Hands on Kubernetes

Hands on Kubernetes

Inside each pod there are containers, kubelet runs these via Docker (pulling images, starting and stopping containers, etc.). It also periodically executes any requested container liveness probes. In addition to Docker, RKT is also supported and the community is actively working to support OCI.

Another component of worker nodes is kube-proxy. This is the network brain of the node, maintaining network rules on the host and performing connection forwarding. It’s also responsible for load balancing across all pods in the service.

Kubernetes Pods

A pod is a group of one or more containers (such as Docker containers), with shared storage/network. Each pod contains specific information on how the containers should be run. Think of pods as a ring-fenced environment to run containers.

Pods are also a unit for scaling. If you need to scale an app component up or down, this can be achieved by adding or removing pods.

Hands on Kubernetes

Hands on Kubernetes

It’s possible to run more than one container in a pod (where each share the same IP address and mounted volumes), if they’re tightly coupled.

Pods are deployed on a single node and have a definite lifecycle. They can be pending, running, succeeding, or failing, but once gone, they are never brought back to life. If a pod dies, a replication controller or other controller must be used to create a new one.

Pods — A description of a set of containers that need to run together.

Services — An object that describes a set of pods that provide a useful service. Services are typically used to define clusters of uniform pods.

Persistent Volumes — A Kubernetes abstraction for persistent storage. Kubernetes supports many types of volumes, such as NFS, Ceph, GlusterFS, local directory, etc.

Hands on Kubernetes

Namespaces — This is a tool used to group, separate, and isolate groups of objects. Namespaces are used for access control, network access control, resource management, and quoting.

Ingress rules — These specify how incoming network traffic should be routed to services and pods.

Network policies — This defines the network access rules between pods inside the cluster.

Hands on Kubernetes

ConfigMaps and Secrets — Used to separate configuration information from application definition.

Controllers — These implement different policies for automatic pod management. There are three main types:

1. Deployment — Responsible for maintaining a set of running pods of the same type.

2. DaemonSet — Runs a specific type of pod on each node based on a condition.

3. StatefulSet — Used when several pods of the same type are needed to run in parallel, but each of the pods is required to have a specific identity.

Hands on Kubernetes

Hands on Kubernetes

● Kubernetes simultaneously runs and controls a set of nodes on virtual or physical machines.

● This is achieved by running agents on each node. ● The agent talks to the master via the same API used to

send the blueprint to Kubernetes. ● The agent registers itself in the master, providing

Kubernetes with information about the nodes.● Reading through the API, the agent determines which

containers are required to run on the corresponding node and how they are to be configured.

Hands on Kubernetes

● The master node runs several Kubernetes components. ● Together, these make all control decisions about which

container needs to be started on which node and how it should be configured.

● In addition, the master and agent may interact with a cloud provider and manage additional cloud resources such as load balancers, persistent volumes, persistent block storage, network configuration, and number of instances.

Hands on Kubernetes

● The master can be a single instance running Kubernetes components or a set of instances to ensure high availability.

● A master can also serve (in certain configurations) as a node to run containers, although this is not recommended for production.

★ Don’t run heavy duty databases in Kubernetes★ Choose wisely your load balancer.

● Running the Kubernetes cluster○ Examples

■ https://cloud.google.com/container-engine/docs/tutorials/hello-app

■ https://github.com/kubernetes/examples/blob/master/staging/spark/README.md

■ https://cloud.google.com/solutions/continuous-delivery-jenkins-container-engine

Hands on Kubernetes

Hands on Kubernetes

Q: If Pods are ephemeral how can I persist my container data across container restarts?

A: Kubernetes supports the concept of Volumes so you can use a Volume type that is persistent.

Q: Do I create Pods manually, what if I want to create a few copies of the same container do I have to create each one individually?

A: Replication Controller to rollout multiple copies using a Pod template

Q: If Pods are ephemeral and their IP address might change if they get restarted how can I reliability reference my backend container from a frontend container? A: Use a Service

Soru, cevap

http://goo.gl/slides/j6gx3q

Resources

● http://www.dummies.com/programming/networking/basics-of-network-virtualization/● https://12factor.net/● https://medium.com/jeroen-rosenberg/from-monolith-to-microservice-architecture-on-kubernetes-part-1-the-api-gateway-eb82f8c2d10c● https://daemonza.github.io/2017/02/20/using-helm-to-deploy-to-kubernetes/● https://dzone.com/articles/microservices-with-kubernetes-and-docker● https://medium.com/jeroen-rosenberg/from-monolith-to-microservice-architecture-on-kubernetes-part-1-the-api-gateway-eb82f8c2d10c● https://techbeacon.com/one-year-using-kubernetes-production-lessons-learned● https://github.com/wsargent/docker-cheat-sheet#dockerfile● http://blog.kubernetes.io/2015/06/the-distributed-system-toolkit-patterns.html ● http://blog.flux7.com/blogs/docker/docker-tutorial-series-part-3-automation-is-the-word-using-dockerfile● https://developers.google.com/apis-explorer/#search/compute/clouduseraccounts/alpha/● https://console.cloud.google.com/cloud-resource-manager● https://alpinelinux.org/downloads/● http://phusion.github.io/baseimage-docker/● https://www.slideshare.net/randybias/the-history-of-pets-vs-cattle-and-using-it-properly● http://cloudscaling.com/blog/cloud-computing/the-history-of-pets-vs-cattle/● https://www.discogs.com/Captain-Hook-And-His-Crew-Ship-Ahoy/release/5674030● http://thesecretlivesofdata.com/raft/● http://www.yamllint.com/● http://static.brandonpotter.com/kubernetes/DeploymentBuilder.html ● http://omerio.com/2015/12/18/learn-the-kubernetes-key-concepts-in-10-minutes/ ● https://youtu.be/9Wzw84Q-8yc ● https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/● https://cloud.google.com/solutions/automated-build-images-with-jenkins-kubernetes● https://cloud.google.com/container-builder/docs/quickstart-docker ● https://www.youtube.com/watch?v=xhwNywVYBk4