Senior Director Cloud Architecture, WSO2
@lakwarus
Deploying Applications in K8S and
Docker
Lakmal Warusawithana
Old Way
Install Application on
New Way
Deploy as a Container
Docker
Docker provides an easy-to-use
packaging model to bundle the
application
Reality
However in many cases, a single
container is not enough to run an
application
K8S
Kubernetes is an open source
container orchestration system that
helps to automate deployment,
scaling, and management of
containerized applications.
K8S Architecture (From Above 5000 ft)
K8S Core Primitive
Small group of containers and
volume
Tightly coupled
● The atom of replication
and placement
Logical host for containers
● Echo pod get an IP address
● Share data: localhost,
volume, IPC, etc.
K8S POD
Storage automatically
attached to a Pod
● Local storage
● Cloud block storage
○ AWS EBS, GCE persistent
● Cluster storage
○ NSF, Gluster
○ iSCSI, Cinder
● Special volumes
○ Git repo, secret
K8S Volume
Ensures N copies of Pod
● If too few, start new one
● If too many, kill some
Enables self-healing
Facilitates auto scaling
K8S Replication Controller
Group of pods thats work
together
DNS name
Load balanced: name map to
a stable virtual IP
Decoupled from Pods and
Replication controllers
K8S Service
Secrets: Tokens, credentials,
certs, etc.
Don’t put them in a container
image.
Inject them as virtual volume
into pods
● Not backed into images
nor pod config
● Kept in memory, never
touches disk
K8S Secret
Multi tenancy in K8S
is namespace has its own
● Resources (Pods, Services,
etc.)
● Policies (who can or
cannot perform an action
in their tenancy)
● Constrain (how much
quota, etc.)
K8S Namespace
12-factor says config comes
from the environment.
● Should not be baked into
Docker image
ConfigMap inject config as a
virtual volume into the Pods
● Late binding, live update
(atomic)
● Also available as env vars
K8S ConfigMap
Services are assumed L4
Ingress in L7
Ingress maps HTTP/HTTPS
incoming traffic to backend
services
● By host headers
● By URL paths
K8S Ingress
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
K8S Rolling Update
Rolling update too imperative
Deployment manage RC
changes for you
● Kubectl edit /apply is all
you need
Aggregate stats
Can have multiple updates
inflight
K8S Deployment
How to run pod in every
node? Or subset of nodes?
Daemonset
● Like ReplicationController
● Do one thing
● Don’t overload
Which node is a selector
K8S Daemonset
Give Pods time to clean up
Catch SIGTERM, clean-up exit
ASAP
Pods status Terminating
30 seconds by default
● Finish inflight operation
● Flush to disk
● Log state
K8S Graceful Termination
Automatically scale RCs to a
target utilization
● CPU utilization for now
Operate within user-defined
min/max bound
Set it and forget it
K8S Horizontal Pod Autoscaler
Demo: Hello World with kubectl
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● deploy code to k8s cluster (automates
build-push-deploy)
● deploy code in draft-pack supported
languages without writing dockerfile or
k8s manifests
● needs draft cli, helm cli, tiller on cluster,
local docker, docker registry
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● deploy code to k8s cluster (automates
build-push-deploy)
● git push to deploy, no dependencies on
your local machine
● needs dockerfile, k8s manifests in the
git repo, gitkube on cluster
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● deploy and manage charts (collection
of k8s objects defining an application)
on a k8s cluster
● ready made charts for many common
applications, like mysql, mediawiki etc.
● needs helm cli, tiller on cluster, chart
definition locally or from a repo
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● define k8s manifests in jsonnet, deploy
them to k8s cluster
● reusable components for common
patterns and stacks, like
deployment+service, redis
● needs jsonnet knowledge, ksonnet cli
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● deploy code to k8s cluster (automates
build-push-deploy)
● watches source code and triggers
build-push-deploy when change
happens, configurable pipeline
● needs skaffold cli, dockerfile, k8s
manifests, skaffold manifest in folder,
local docker, docker registry
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● deploy your code in metaparticle
supported languages to k8s
(automates build-push-deploy)
● define containerizing and deploying to
k8s in the language itself, in an
idiomatic way, without writing
dockerfile or k8s yaml
● needs metaparticle library for
language, local docker
● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
● Generate docker images, k8s artifacts
depending on annotation defined in
the code.
● Support many Kubernetes
functionalities like; all kind of
Kubernetes services, deployment,
ingress, secrets, persistent volumes,
config maps, liveness probe and
horizontal pod autoscaling.
Demo: Metaparticles with K8S
Demo: Ballerina with K8S
● https://kubernetes.io/docs/concepts
● https://www.youtube.com/watch?v=A4A7ybtQujA
● https://www.slideshare.net/DanielSmith272/whats-new-in-k
ubernetes
● https://blog.hasura.io/draft-vs-gitkube-vs-helm-vs-ksonnet
-vs-metaparticle-vs-skaffold-f5aa9561f948
References
THANK YOU
wso2.com

[WSO2Con USA 2018] Deploying Applications in K8S and Docker

  • 1.
    Senior Director CloudArchitecture, WSO2 @lakwarus Deploying Applications in K8S and Docker Lakmal Warusawithana
  • 2.
  • 3.
    New Way Deploy asa Container
  • 4.
    Docker Docker provides aneasy-to-use packaging model to bundle the application
  • 5.
    Reality However in manycases, a single container is not enough to run an application
  • 7.
    K8S Kubernetes is anopen source container orchestration system that helps to automate deployment, scaling, and management of containerized applications.
  • 8.
    K8S Architecture (FromAbove 5000 ft)
  • 9.
  • 10.
    Small group ofcontainers and volume Tightly coupled ● The atom of replication and placement Logical host for containers ● Echo pod get an IP address ● Share data: localhost, volume, IPC, etc. K8S POD
  • 11.
    Storage automatically attached toa Pod ● Local storage ● Cloud block storage ○ AWS EBS, GCE persistent ● Cluster storage ○ NSF, Gluster ○ iSCSI, Cinder ● Special volumes ○ Git repo, secret K8S Volume
  • 12.
    Ensures N copiesof Pod ● If too few, start new one ● If too many, kill some Enables self-healing Facilitates auto scaling K8S Replication Controller
  • 13.
    Group of podsthats work together DNS name Load balanced: name map to a stable virtual IP Decoupled from Pods and Replication controllers K8S Service
  • 14.
    Secrets: Tokens, credentials, certs,etc. Don’t put them in a container image. Inject them as virtual volume into pods ● Not backed into images nor pod config ● Kept in memory, never touches disk K8S Secret
  • 15.
    Multi tenancy inK8S is namespace has its own ● Resources (Pods, Services, etc.) ● Policies (who can or cannot perform an action in their tenancy) ● Constrain (how much quota, etc.) K8S Namespace
  • 16.
    12-factor says configcomes from the environment. ● Should not be baked into Docker image ConfigMap inject config as a virtual volume into the Pods ● Late binding, live update (atomic) ● Also available as env vars K8S ConfigMap
  • 17.
    Services are assumedL4 Ingress in L7 Ingress maps HTTP/HTTPS incoming traffic to backend services ● By host headers ● By URL paths K8S Ingress
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
    Rolling update tooimperative Deployment manage RC changes for you ● Kubectl edit /apply is all you need Aggregate stats Can have multiple updates inflight K8S Deployment
  • 27.
    How to runpod in every node? Or subset of nodes? Daemonset ● Like ReplicationController ● Do one thing ● Don’t overload Which node is a selector K8S Daemonset
  • 28.
    Give Pods timeto clean up Catch SIGTERM, clean-up exit ASAP Pods status Terminating 30 seconds by default ● Finish inflight operation ● Flush to disk ● Log state K8S Graceful Termination
  • 29.
    Automatically scale RCsto a target utilization ● CPU utilization for now Operate within user-defined min/max bound Set it and forget it K8S Horizontal Pod Autoscaler
  • 30.
    Demo: Hello Worldwith kubectl
  • 31.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S
  • 32.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● deploy code to k8s cluster (automates build-push-deploy) ● deploy code in draft-pack supported languages without writing dockerfile or k8s manifests ● needs draft cli, helm cli, tiller on cluster, local docker, docker registry
  • 33.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● deploy code to k8s cluster (automates build-push-deploy) ● git push to deploy, no dependencies on your local machine ● needs dockerfile, k8s manifests in the git repo, gitkube on cluster
  • 34.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● deploy and manage charts (collection of k8s objects defining an application) on a k8s cluster ● ready made charts for many common applications, like mysql, mediawiki etc. ● needs helm cli, tiller on cluster, chart definition locally or from a repo
  • 35.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● define k8s manifests in jsonnet, deploy them to k8s cluster ● reusable components for common patterns and stacks, like deployment+service, redis ● needs jsonnet knowledge, ksonnet cli
  • 36.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● deploy code to k8s cluster (automates build-push-deploy) ● watches source code and triggers build-push-deploy when change happens, configurable pipeline ● needs skaffold cli, dockerfile, k8s manifests, skaffold manifest in folder, local docker, docker registry
  • 37.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● deploy your code in metaparticle supported languages to k8s (automates build-push-deploy) ● define containerizing and deploying to k8s in the language itself, in an idiomatic way, without writing dockerfile or k8s yaml ● needs metaparticle library for language, local docker
  • 38.
    ● Draft ● Gitkube ●Helm ● Ksonnet ● Skaffold ● Metaparticle ● Ballerina Tools and framework for K8S ● Generate docker images, k8s artifacts depending on annotation defined in the code. ● Support many Kubernetes functionalities like; all kind of Kubernetes services, deployment, ingress, secrets, persistent volumes, config maps, liveness probe and horizontal pod autoscaling.
  • 39.
  • 40.
  • 41.
    ● https://kubernetes.io/docs/concepts ● https://www.youtube.com/watch?v=A4A7ybtQujA ●https://www.slideshare.net/DanielSmith272/whats-new-in-k ubernetes ● https://blog.hasura.io/draft-vs-gitkube-vs-helm-vs-ksonnet -vs-metaparticle-vs-skaffold-f5aa9561f948 References
  • 42.