Kubernetes - training
micro-dragons without getting
burnt
Amir Moghimi
Senior Consultant in managed services
Sixtree, Australia
Traditional approach
Micro-services approach
Train microservices
Microservices architecture magnifies the need for:
● Fairly homogenous build artifacts
● Standard running platform
● Configuration and secret management
● Service Discovery
Polyglot programming
● Pick right tool for the job
● Multiple teams with different expertise/perspectives
● Keep developers busy learning new language(s)
Homogenous build artifacts
Build artifacts:
● Java Jar and War files
● Ruby Gems and Rails apps
● Node packages and apps
● Go binaries
Containerise everything (Docker):
● Universally deployable artifact
Dockerfile
FROM debian:jessie
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre
RUN apt-get update 
&& apt-get install -y 
openjdk-8-jre-headless
COPY my-app.jar /my-app.jar
ENV MY_APP_CONF_VAR super-cool-default-value
CMD [“java”, “-jar”, “/my-app.jar”]
docker build -t registry/image_name .
docker push registry/image_name
Configure and run
docker run -d 
-e REDIS_NAMESPACE='staging' 
-e POSTGRES_ENV_POSTGRES_PASSWORD='foo' 
-e POSTGRES_ENV_POSTGRES_USER='bar' 
-e POSTGRES_ENV_DB_NAME='mysite_staging' 
-e POSTGRES_ADDR='docker-db-1.us-east-1.rds.amazonaws.com' 
-e SITE_URL='staging.mysite.com' 
-p 80:80 
--restart=on-failure:10 
--name container_name 
registry/image_name 
image_command cmd_arg1 cmd_arg2
Configuration hell
● Application config
○ Env vars, config files, cmd line args
● Runtime environment config
○ Web server, JVM
● Runtime dependencies config
○ Volumes, logging, monitoring, stats
Configuration management
● Train your app:
○ 12-factor app
● Configuration in a containerised world:
○ Log to stdout
○ Port mappings (from host to container)
○ SaaS blob storage (mount volumes only if providing a storage service)
○ Service discovery (Consul, Eureka, DNS)
○ Secrets (ideally only in memory but how?)
○ Environment Variables for everything else
Configuration management tools
● Docker compose
○ State management? Templating? Secrets? Service discovery? Cluster-
level volumes?
● Ansible Role (classic host-based approach + docker module)
● Kubernetes (container PaaS)
Kubernetes key resources
● Namespace
● Pod (container)
● Replica Set
● ConfigMap
● Secret
● Service
● Deployment
Kubernetes Master
API Server Replica Set
kubelet
Node
Pod
Container
Pod
Container
kubelet
Node
Pod
Container
Kubernetes Cluster
= Label
= Resource
= Process
Replica Set (Replication Controller)
apiVersion: v1
kind: ReplicationController
metadata:
name: my-nginx-replica-set
spec:
replicas: 3
selector:
app: dragon-web
template:
metadata:
name: nginx-pod
labels:
app: dragon-web
spec:
containers:
- name: nginx-container
image: nginx
env:
- name: LOG_LEVEL
value: INFO
ports:
- containerPort: 80
apiVersion: v1
kind: Pod
kubectl create -f my-nginx-replica-set.yml
ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: dragon-config
labels:
environment: non-prod
data:
dragon.how.much: very
dragon.type: fast
apiVersion: v1
kind: Pod
metadata:
name: dragon-pod
spec:
containers:
- name: dragon-container
image: dragon-image
env:
- name: DRAGON_LEVEL
valueFrom:
configMapKeyRef:
name: dragon-config
key: dragon.how.much
- name: DRAGON_TYPE
valueFrom:
configMapKeyRef:
name: dragon-config
key: dragon.type
Secret
apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
data:
password: MWYyZDFlMmU2N2RmCg==
username: my_admin
apiVersion: v1
kind: Pod
metadata:
name: secret-user-pod
Spec:
volumes:
name: secret-vol
secret:
secretName: my-secret
containers:
- name: nginx-container
image: nginx
volumeMounts:
name: secret-vol
mountPath: /etc/my-access-keys
readOnly: true
Service
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "my-service"
},
"spec": {
"selector": {
"app": "dragon-web"
},
"ports": [{
"protocol": "TCP",
"port": 80,
"targetPort": 80
}]
}
}
Service discovery
● DNS
○ Take extra care when playing with fire
○ No control over client
○ Time sensitive protocol
○ Use only if you have a reliable DNS service, i.e. AWS Route53
● Provided environment variables
○ MY_DROGON_SERVICE_HOST=10.0.0.11
MY_DROGON_SERVICE_PORT=8080
○ Create services before using them in pods
○ Only works per namespace
● Kubernetes REST API
○ GET /api/v1/namespaces/{namespace}/services/{service_name}
DNS
HAZARD
Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Declarative
Server-side
Revision tracking
Easy rollback
Project structure
my-dragon-microservice/
src/
kube-resources/
default-configmap.yml
default-secret.yml
service.yml
deployment.yml
pipeline-resources/
build.sh
test.sh
deploy.sh # kubectl apply -f ../kube-resources
pipeline.yml
Dockerfile
Environments config
dev-1/
namespace.yml
configmap.yml
secret.yml
dev-2/… dev-N/
qa-1/
namespace.yml
configmap.yml
secret.yml
qa-2/… qa-N/
prod-1/
namespace.yml
configmap.yml
secret.yml
prod-2/… prod-N/
Demo

More Related Content

PPTX
Going Serverless with Azure Functions
PDF
Rob Gruhl and Erik Erikson - What We Learned in 18 Serverless Months at Nords...
PPTX
Aws serverless architecture
PPTX
API Gateway: Nginx way
PPTX
Everybody loves Swagger
PPTX
Serverless Summit India 2017: Fission
PDF
Putting The 'M' In MBaaS—Red Hat Mobile Client Development Platform (Jay Balu...
PDF
Microservices
Going Serverless with Azure Functions
Rob Gruhl and Erik Erikson - What We Learned in 18 Serverless Months at Nords...
Aws serverless architecture
API Gateway: Nginx way
Everybody loves Swagger
Serverless Summit India 2017: Fission
Putting The 'M' In MBaaS—Red Hat Mobile Client Development Platform (Jay Balu...
Microservices

What's hot (20)

PDF
Beautifying the Beautiful: Theming WSO2 API Manager
PPTX
Microservices from operations aspect
PPTX
Microservices environment in production
PDF
AWS Api Gateway by Łukasz Marchewka Scalacc
PDF
Azure Service Fabric - Hamida Rebai - CCDays
PDF
Lean Microservices with OSGi - Christian Schneider
PPTX
BUILD, TEST & DEPLOY .NET CORE APPS IN AZURE DEVOPS
PDF
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
PPTX
Using an API Gateway for Microservices
PPTX
Developing Cross-Platform Web Apps with ASP.NET Core1.0
PPTX
Serverless in Azure with Functions
PPTX
Indore mule soft meetup 3
PDF
Forced Evolution: Shopify's Journey to Kubernetes
PPSX
Power of Microsoft Graph API by Nilesh Shah SharePoint Saturday Toronto 2017
PPTX
12 Clouds of Christmas 2012- Stormpath
PPTX
Azure Update, July 2016
PDF
Spring one pivotal
PDF
WSO2Con USA 2017: Building an Effective API Architecture
PPTX
Microservices: A developer's approach
PPTX
SDLC, Agile methodologies and Career in Product management
Beautifying the Beautiful: Theming WSO2 API Manager
Microservices from operations aspect
Microservices environment in production
AWS Api Gateway by Łukasz Marchewka Scalacc
Azure Service Fabric - Hamida Rebai - CCDays
Lean Microservices with OSGi - Christian Schneider
BUILD, TEST & DEPLOY .NET CORE APPS IN AZURE DEVOPS
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Using an API Gateway for Microservices
Developing Cross-Platform Web Apps with ASP.NET Core1.0
Serverless in Azure with Functions
Indore mule soft meetup 3
Forced Evolution: Shopify's Journey to Kubernetes
Power of Microsoft Graph API by Nilesh Shah SharePoint Saturday Toronto 2017
12 Clouds of Christmas 2012- Stormpath
Azure Update, July 2016
Spring one pivotal
WSO2Con USA 2017: Building an Effective API Architecture
Microservices: A developer's approach
SDLC, Agile methodologies and Career in Product management
Ad

Viewers also liked (12)

PDF
JavaScript framework overview
PDF
Scaling docker with kubernetes
PDF
Demystifying kubernetes
PDF
Kubernetes in 20 minutes - HDE Monthly Technical Session 24
PPTX
Kubernetes CI/CD with Helm
PDF
Container Orchestration Wars
PDF
Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...
PDF
Idea to Production - with Gitlab and Kubernetes
PDF
How to Monitor Microservices
PPTX
Stateful set in kubernetes implementation & usecases
PDF
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
PPTX
JavaScript framework overview
Scaling docker with kubernetes
Demystifying kubernetes
Kubernetes in 20 minutes - HDE Monthly Technical Session 24
Kubernetes CI/CD with Helm
Container Orchestration Wars
Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...
Idea to Production - with Gitlab and Kubernetes
How to Monitor Microservices
Stateful set in kubernetes implementation & usecases
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
Ad

Similar to Kubernetes - training micro-dragons without getting burnt (20)

PDF
Kubernetes: training micro-dragons for a serious battle
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PPTX
betterCode Workshop: Effizientes DevOps-Tooling mit Go
PPTX
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
PDF
Cloud-native applications with Java and Kubernetes - Yehor Volkov
PDF
Building Web Scale Apps with Docker and Mesos by Alex Rukletsov (Mesosphere)
PDF
Kubernetes: The Next Research Platform
PDF
DevEx | there’s no place like k3s
PDF
Get you Java application ready for Kubernetes !
PPTX
K8s best practices from the field!
PPTX
Introduction to kubernetes
PPTX
Deploying windows containers with kubernetes
PPTX
Microservices with containers in the cloud
PDF
Dockers zero to hero
PDF
Build Your Kubernetes Operator with the Right Tool!
PPTX
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
PDF
Exploring MySQL Operator for Kubernetes in Python
PPTX
Docker Enterprise Workshop - Technical
PDF
Kubernetes Intro
PDF
CI/CD Across Multiple Environments
Kubernetes: training micro-dragons for a serious battle
K8s in 3h - Kubernetes Fundamentals Training
betterCode Workshop: Effizientes DevOps-Tooling mit Go
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
Cloud-native applications with Java and Kubernetes - Yehor Volkov
Building Web Scale Apps with Docker and Mesos by Alex Rukletsov (Mesosphere)
Kubernetes: The Next Research Platform
DevEx | there’s no place like k3s
Get you Java application ready for Kubernetes !
K8s best practices from the field!
Introduction to kubernetes
Deploying windows containers with kubernetes
Microservices with containers in the cloud
Dockers zero to hero
Build Your Kubernetes Operator with the Right Tool!
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
Exploring MySQL Operator for Kubernetes in Python
Docker Enterprise Workshop - Technical
Kubernetes Intro
CI/CD Across Multiple Environments

Recently uploaded (20)

PPTX
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
Guide to Food Delivery App Development.pdf
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Computer Software - Technology and Livelihood Education
PPTX
Python is a high-level, interpreted programming language
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
CNN LeNet5 Architecture: Neural Networks
PPTX
Cybersecurity: Protecting the Digital World
PPTX
Lecture 5 Software Requirement Engineering
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
AI Guide for Business Growth - Arna Softech
PPTX
Airline CRS | Airline CRS Systems | CRS System
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PDF
Workplace Software and Skills - OpenStax
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
Full-Stack Developer Courses That Actually Land You Jobs
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
Guide to Food Delivery App Development.pdf
Topaz Photo AI Crack New Download (Latest 2025)
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Computer Software - Technology and Livelihood Education
Python is a high-level, interpreted programming language
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
CNN LeNet5 Architecture: Neural Networks
Cybersecurity: Protecting the Digital World
Lecture 5 Software Requirement Engineering
CCleaner 6.39.11548 Crack 2025 License Key
BoxLang Dynamic AWS Lambda - Japan Edition
AI Guide for Business Growth - Arna Softech
Airline CRS | Airline CRS Systems | CRS System
Internet Download Manager IDM Crack powerful download accelerator New Version...
Workplace Software and Skills - OpenStax

Kubernetes - training micro-dragons without getting burnt

  • 1. Kubernetes - training micro-dragons without getting burnt Amir Moghimi Senior Consultant in managed services Sixtree, Australia
  • 4. Train microservices Microservices architecture magnifies the need for: ● Fairly homogenous build artifacts ● Standard running platform ● Configuration and secret management ● Service Discovery
  • 5. Polyglot programming ● Pick right tool for the job ● Multiple teams with different expertise/perspectives ● Keep developers busy learning new language(s)
  • 6. Homogenous build artifacts Build artifacts: ● Java Jar and War files ● Ruby Gems and Rails apps ● Node packages and apps ● Go binaries Containerise everything (Docker): ● Universally deployable artifact
  • 7. Dockerfile FROM debian:jessie ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre RUN apt-get update && apt-get install -y openjdk-8-jre-headless COPY my-app.jar /my-app.jar ENV MY_APP_CONF_VAR super-cool-default-value CMD [“java”, “-jar”, “/my-app.jar”] docker build -t registry/image_name . docker push registry/image_name
  • 8. Configure and run docker run -d -e REDIS_NAMESPACE='staging' -e POSTGRES_ENV_POSTGRES_PASSWORD='foo' -e POSTGRES_ENV_POSTGRES_USER='bar' -e POSTGRES_ENV_DB_NAME='mysite_staging' -e POSTGRES_ADDR='docker-db-1.us-east-1.rds.amazonaws.com' -e SITE_URL='staging.mysite.com' -p 80:80 --restart=on-failure:10 --name container_name registry/image_name image_command cmd_arg1 cmd_arg2
  • 9. Configuration hell ● Application config ○ Env vars, config files, cmd line args ● Runtime environment config ○ Web server, JVM ● Runtime dependencies config ○ Volumes, logging, monitoring, stats
  • 10. Configuration management ● Train your app: ○ 12-factor app ● Configuration in a containerised world: ○ Log to stdout ○ Port mappings (from host to container) ○ SaaS blob storage (mount volumes only if providing a storage service) ○ Service discovery (Consul, Eureka, DNS) ○ Secrets (ideally only in memory but how?) ○ Environment Variables for everything else
  • 11. Configuration management tools ● Docker compose ○ State management? Templating? Secrets? Service discovery? Cluster- level volumes? ● Ansible Role (classic host-based approach + docker module) ● Kubernetes (container PaaS)
  • 12. Kubernetes key resources ● Namespace ● Pod (container) ● Replica Set ● ConfigMap ● Secret ● Service ● Deployment
  • 13. Kubernetes Master API Server Replica Set kubelet Node Pod Container Pod Container kubelet Node Pod Container Kubernetes Cluster = Label = Resource = Process
  • 14. Replica Set (Replication Controller) apiVersion: v1 kind: ReplicationController metadata: name: my-nginx-replica-set spec: replicas: 3 selector: app: dragon-web template: metadata: name: nginx-pod labels: app: dragon-web spec: containers: - name: nginx-container image: nginx env: - name: LOG_LEVEL value: INFO ports: - containerPort: 80 apiVersion: v1 kind: Pod kubectl create -f my-nginx-replica-set.yml
  • 15. ConfigMap apiVersion: v1 kind: ConfigMap metadata: name: dragon-config labels: environment: non-prod data: dragon.how.much: very dragon.type: fast apiVersion: v1 kind: Pod metadata: name: dragon-pod spec: containers: - name: dragon-container image: dragon-image env: - name: DRAGON_LEVEL valueFrom: configMapKeyRef: name: dragon-config key: dragon.how.much - name: DRAGON_TYPE valueFrom: configMapKeyRef: name: dragon-config key: dragon.type
  • 16. Secret apiVersion: v1 kind: Secret metadata: name: my-secret type: Opaque data: password: MWYyZDFlMmU2N2RmCg== username: my_admin apiVersion: v1 kind: Pod metadata: name: secret-user-pod Spec: volumes: name: secret-vol secret: secretName: my-secret containers: - name: nginx-container image: nginx volumeMounts: name: secret-vol mountPath: /etc/my-access-keys readOnly: true
  • 17. Service { "apiVersion": "v1", "kind": "Service", "metadata": { "name": "my-service" }, "spec": { "selector": { "app": "dragon-web" }, "ports": [{ "protocol": "TCP", "port": 80, "targetPort": 80 }] } }
  • 18. Service discovery ● DNS ○ Take extra care when playing with fire ○ No control over client ○ Time sensitive protocol ○ Use only if you have a reliable DNS service, i.e. AWS Route53 ● Provided environment variables ○ MY_DROGON_SERVICE_HOST=10.0.0.11 MY_DROGON_SERVICE_PORT=8080 ○ Create services before using them in pods ○ Only works per namespace ● Kubernetes REST API ○ GET /api/v1/namespaces/{namespace}/services/{service_name} DNS HAZARD
  • 19. Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 Declarative Server-side Revision tracking Easy rollback
  • 22. Demo