Within the last four years container technologies have become very popular. A lot of companies and developers are now using containers to ship their applications. Docker provides an easy-to-use packaging model to bundle the application. However in many cases, a single container is not enough to run an application. It requires multiple containers, scaled into multiple host machines to become a production grade deployment. Kubernetes is an open source system for automating deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery. This presentation discusses best practices of deploying application in Docker and Kubernetes while discussing Docker and Kubernetes concepts.
7. Best Practices in Container Based Deployment
● Single process in a single Container
● Read environment specific configurations
via environment variable
● Reduce Container image sizes
● Use Container native programming
languages
9. K8S
Kubernetes is an open source
container orchestration system that
helps to automate deployment,
scaling, and management of
containerized applications.
11. 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
12. 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
13. 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
14. 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
15. 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
16. 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
17. 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
18. Services are assumed L4
Ingress in L7
Ingress maps HTTP/HTTPS
incoming traffic to backend
services
● By host headers
● By URL paths
K8S Ingress
19. 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
20. 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
21. 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
23. ● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
Tools and framework for K8S
24. ● 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
25. ● 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
26. ● 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
27. ● 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
28. ● 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
29. ● 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
30. ● Draft
● Gitkube
● Helm
● Ksonnet
● Skaffold
● Metaparticle
● Ballerina
● 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.
Tools and framework for K8S