SlideShare a Scribd company logo
1 of 69
Download to read offline
65
66
Rolling
Updates &
Rollbacks
Rollout and Versioning
Revision 1
Revision 2
nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0
nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1
Rollout Command
> kubectl rollout status deployment/myapp-deployment
Waiting for rollout to finish: 0 of 10 updated replicas are available...
Waiting for rollout to finish: 1 of 10 updated replicas are available...
Waiting for rollout to finish: 2 of 10 updated replicas are available...
Waiting for rollout to finish: 3 of 10 updated replicas are available...
Waiting for rollout to finish: 4 of 10 updated replicas are available...
Waiting for rollout to finish: 5 of 10 updated replicas are available...
Waiting for rollout to finish: 6 of 10 updated replicas are available...
Waiting for rollout to finish: 7 of 10 updated replicas are available...
Waiting for rollout to finish: 8 of 10 updated replicas are available...
Waiting for rollout to finish: 9 of 10 updated replicas are available...
deployment "myapp-deployment" successfully rolled out
> kubectl rollout history deployment/myapp-deployment
deployments "myapp-deployment"
REVISION CHANGE-CAUSE
1 <none>
2 kubectl apply --filename=deployment-definition.yml --record=true
Deployment Strategy
nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1
Application
Down
Recreate
nginx:1.7.0 nginx:1.7.0 nginx:1.7.0
nginx:1.7.0 nginx:1.7.0
nginx:1.7.1 nginx:1.7.1 nginx:1.7.1
nginx:1.7.1
nginx:1.7.1
Rolling
Update
Kubectl apply
apiVersion:
kind:
metadata:
spec:
deployment-definition.yml
name: myapp-deployment
labels:
app: myapp
type: front-end
apps/v1
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas:
selector:
matchLabels:
type: front-end
template:
3
Deployment
:1.7.1
> kubectl apply –f deployment-definition.yml
deployment "myapp-deployment" configured
> kubectl set image deployment/myapp-deployment 
nginx=nginx:1.9.1
deployment "myapp-deployment" image is updated
Recreate RollingUpdate
Upgrades
Deployment
Replica Set - 1
POD POD POD POD POD
Replica Set - 2
POD POD POD POD POD
> kubectl get replicasets
NAME DESIRED CURRENT READY AGE
myapp-deployment-67c749c58c 0 0 0 22m
myapp-deployment-7d57dbdb8d 5 5 5 20m
Rollback
Deployment
Replica Set - 1
POD POD POD POD POD
Replica Set - 2
POD POD POD POD POD
> kubectl rollout undo deployment/myapp-deployment
deployment “myapp-deployment” rolled back
> kubectl get replicasets
NAME DESIRED CURRENT READY AGE
myapp-deployment-67c749c58c 0 0 0 22m
myapp-deployment-7d57dbdb8d 5 5 5 20m
> kubectl get replicasets
NAME DESIRED CURRENT READY AGE
myapp-deployment-67c749c58c 5 5 5 22m
myapp-deployment-7d57dbdb8d 0 0 0 20m
kubectl run
> kubectl run nginx --image=nginx
deployment "nginx" created
Summarize Commands
> kubectl rollout status deployment/myapp-deployment
> kubectl rollout history deployment/myapp-deployment
> kubectl create –f deployment-definition.yml
> kubectl get deployments
> kubectl apply –f deployment-definition.yml
> kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
> kubectl rollout undo deployment/myapp-deployment
Create
Get
Update
Status
Rollback
76
COMMANDS
&
ARGUMENTS
docker run ubuntu
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
45aacca36850 ubuntu "/bin/bash" 43 seconds ago Exited (0) 41 seconds ago
docker ps
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
??
docker run ubuntu [COMMAND]
docker run ubuntu sleep 5
1
2
3
4
5
FROM Ubuntu
CMD sleep 5
CMD [“command”, “param1”]
CMD command param1
CMD [“sleep”, “5”]
CMD sleep 5
CMD [“sleep 5”]
docker build –t ubuntu-sleeper .
docker run ubuntu-sleeper
1
2
3
4
5
sleep: missing operand
Try 'sleep --help' for more information.
FROM Ubuntu
CMD sleep 5
docker run ubuntu-sleeper sleep 10
docker run ubuntu-sleeper 10
FROM Ubuntu
ENTRYPOINT [“sleep”]
Command at Startup: sleep 10
Command at Startup:
sleep
10
docker run ubuntu-sleeper
Command at Startup:
sleep
Command at Startup:
sleep: missing operand
Try 'sleep --help' for more information.
docker run ubuntu-sleeper
Command at Startup:
FROM Ubuntu
ENTRYPOINT [“sleep”]
CMD [“5”]
sleep
5
docker run ubuntu-sleeper 10
10
sleep
docker run --entrypoint sleep2.0 ubuntu-sleeper 10
Command at Startup:
sleep2.0 10
apiVersion:
kind:
metadata:
spec:
pod-definition.yml
kubectl create –f pod-definition.yml
v1
Pod
name: ubuntu-sleeper-pod
containers:
- name:
image:
docker run --name ubuntu-sleeper ubuntu-sleeper
ubuntu-sleeper
docker run --name ubuntu-sleeper ubuntu-sleeper 10
ubuntu-sleeper
args:
[“10”]
apiVersion:
kind:
metadata:
spec:
pod-definition.yml
kubectl create –f pod-definition.yml
v1
Pod
name: ubuntu-sleeper-pod
containers:
- name:
image: ubuntu-sleeper
ubuntu-sleeper
args:[“10”]
FROM Ubuntu
ENTRYPOINT [“sleep”]
CMD [“5”]
docker run --name ubuntu-sleeper 
--entrypoint sleep2.0
ubuntu-sleeper 10
command:
[“sleep2.0”]
FROM Ubuntu
ENTRYPOINT [“sleep”]
CMD [“5”]
apiVersion:
kind:
metadata:
spec:
pod-definition.yml
v1
Pod
name: ubuntu-sleeper-pod
containers:
- name:
image: ubuntu-sleeper
ubuntu-sleeper
args:[“10”]
command:
[“sleep2.0”]
89
ENVIRONMENT
VARIABLES
import os
from flask import Flask
app = Flask(__name__)
…
…
color = "red"
@app.route("/")
def main():
print(color)
return render_template('hello.html', color=color)
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
python app.py
Environment Variables
import os
from flask import Flask
app = Flask(__name__)
…
…
color = "red"
@app.route("/")
def main():
print(color)
return render_template('hello.html', color=color)
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
Environment Variables
import os
from flask import Flask
app = Flask(__name__)
…
…
color = "red"
@app.route("/")
def main():
print(color)
return render_template('hello.html', color=color)
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
os.environ.get('APP_COLOR')
export APP_COLOR=blue; python app.py
Environment Variables
import os
from flask import Flask
app = Flask(__name__)
…
…
color = "red"
@app.route("/")
def main():
print(color)
return render_template('hello.html', color=color)
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
os.environ.get('APP_COLOR')
docker run simple-webapp-color
-e APP_COLOR=blue
ENV Variables in Docker
docker run simple-webapp-color
-e APP_COLOR=blue
docker run -e APP_COLOR=green simple-webapp-color
docker run -e APP_COLOR=pink simple-webapp-color
ENV Variables in Docker
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
pod-definition.yaml
env:
- name:
value:
APP_COLOR
pink
docker run -e APP_COLOR=pink simple-webapp-color
ENV Variables in Kubernetes
env:
- name:
value:
APP_COLOR
pink
ENV Value Types
Plain Key Value
1
ConfigMap
2
Secrets
3
env:
- name: APP_COLOR
valueFrom:
env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
secretKeyRef:
Course Objectives
Core Concepts
Multi-Container Pods
Observability
Configuration
Pod Design
Services & Networking
State Persistence
ConfigMaps
SecurityContexts
Resource Requirements
Secrets
ServiceAccounts
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
pod-definition.yaml
env:
- name:
value:
- name:
value:
APP_COLOR
blue
ConfigMaps
APP_MODE
prod
ConfigMap
APP_COLOR: blue
APP_MODE: prod
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
pod-definition.yaml
env:
- name:
value:
- name:
value:
ConfigMaps
ConfigMap
Create ConfigMap Inject into Pod
1 2
APP_MODE
APP_COLOR blue
prod
:
:
envFrom:
- configMapRef:
name: app-config
Create ConfigMaps
APP_COLOR: blue
APP_MODE: prod
ConfigMap
Create ConfigMap
1
kubectl create configmap
kubectl create –f
Declarative
Imperative
Create ConfigMaps
APP_COLOR: blue
APP_MODE: prod
ConfigMap
Create ConfigMap
1
kubectl create configmap
Imperative
<config-name> --from-literal=<key>=<value>
kubectl create configmap 
app-config --from-literal=APP_COLOR=blue
--from-literal=APP_MOD=prod

kubectl create configmap
<config-name> --from-file=<path-to-file>
kubectl create configmap 
app-config --from-file=app_config.properties
Create ConfigMaps
APP_COLOR: blue
APP_MODE: prod
ConfigMap
Create ConfigMap
1
kubectl create –f
Declarative
apiVersion:
kind:
metadata:
data:
config-map.yaml
v1
ConfigMap
name: app-config
APP_COLOR: blue
APP_MODE: prod
kubectl create –f config-map.yaml
Create ConfigMaps
APP_COLOR: blue
APP_MODE: prod
app-config
Create ConfigMap
1
port: 6379
rdb-compression: yes
redis-config
port: 3306
max_allowed_packet: 128M
mysql-config
View ConfigMaps
kubectl get configmaps
NAME DATA AGE
app-config 2 3s
kubectl describe configmaps
Name: app-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
APP_COLOR:
----
blue
APP_MODE:
----
prod
Events: <none>
ConfigMap in Pods
Inject into Pod
2
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
labels:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
pod-definition.yaml
envFrom:
- configMapRef:
name:
apiVersion:
kind:
metadata:
data:
config-map.yaml
v1
ConfigMap
name: app-config
APP_COLOR: blue
APP_MODE: prod
app-config
kubectl create –f pod-definition.yaml
ConfigMap in Pods
envFrom:
- configMapRef:
name: app-config
env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
name: app-config
key: APP_COLOR
volumes:
- name: app-config-volume
configMap:
name: app-config
SINGLE ENV
VOLUME
ENV
107
Kubernetes
Secrets
Web-MySQL Application
import os
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
mysql.connector.connect(host=‘mysql', database='mysql’,
user='root', password=‘paswrd')
return render_template('hello.html', color=fetchcolor())
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
import os
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
mysql.connector.connect(host=‘mysql', database='mysql’,
user='root', password=‘paswrd')
return render_template('hello.html', color=fetchcolor())
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
Web-MySQL Application
import os
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
mysql.connector.connect(host=‘mysql', database='mysql’,
user='root', password=‘paswrd')
return render_template('hello.html', color=fetchcolor())
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")
app.py
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config-map.yaml
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Web-MySQL Application
Secret
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Secret
POD
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Environment Variable
Create Secret
Inject into Pod
1 2
DB_Host: bXlzcWw=
DB_User: cm9vdA==
DB_Password: cGFzd3Jk
Create Secrets
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Secret
Create Secret
1
kubectl create secret generic
kubectl create –f
Declarative
Imperative
Create Secrets
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Secret
Create Secret
1
kubectl create secret generic
Imperative
<secret-name> --from-literal=<key>=<value>
kubectl create secret generic 
app-secret --from-literal=DB_Host=mysql
--from-literal=DB_User=root

kubectl create secret generic
<secret-name> --from-file=<path-to-file>
kubectl create secret generic 
app-secret --from-file=app_secret.properties
--from-literal=DB_Password=paswrd
Create Secrets
Create Secret
1
kubectl create –f
Declarative
apiVersion:
kind:
metadata:
data:
secret-data.yaml
v1
Secret
name: app-secret
DB_Host: mysql
DB_User: root
DB_Password: paswrd
kubectl create –f secret-data.yaml
DB_Host: mysql
DB_User: root
DB_Password: paswrd
Secret
DB_Host: bXlzcWw=
DB_User: cm9vdA==
DB_Password: cGFzd3Jk
Encode Secrets
Create Secret
1
kubectl create –f
Declarative
apiVersion:
kind:
metadata:
data:
secret-data.yaml
v1
Secret
name: app-secret
DB_Host: mysql
DB_User: root
DB_Password: paswrd
kubectl create –f secret-data.yaml
Secret
DB_Host: bXlzcWw=
DB_User: cm9vdA==
DB_Password: cGFzd3Jk
DB_Host: mysql
DB_User: root
DB_Password: paswrd
echo –n ‘mysql’ | base64
bXlzcWw=
echo –n ‘root’ | base64
cm9vdA==
echo –n ‘paswrd’ | base64
cGFzd3Jk
View Secrets
kubectl get secrets
NAME TYPE DATA AGE
app-secret Opaque 3 10m
default-token-mvtkv kubernetes.io/service-account-token 3 2h
kubectl describe secrets
Name: app-secret
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
DB_Host: 10 bytes
DB_Password: 6 bytes
DB_User: 4 bytes
kubectl get secret app-secret –o yaml
apiVersion: v1
data:
DB_Host: bXlzcWw=
DB_Password: cGFzd3Jk
DB_User: cm9vdA==
kind: Secret
metadata:
creationTimestamp: 2018-10-18T10:01:12Z
labels:
name: app-secret
name: app-secret
namespace: default
uid: be96e989-d2bc-11e8-a545-080027931072
type: Opaque
Decode Secrets
Create Secret
1
kubectl create –f
Declarative
apiVersion:
kind:
metadata:
data:
secret-data.yaml
v1
Secret
name: app-secret
DB_Host: mysql
DB_User: root
DB_Password: paswrd
kubectl create –f secret-data.yaml
Secret
DB_Host: bXlzcWw=
DB_User: cm9vdA==
DB_Password: cGFzd3Jk
DB_Host: mysql
DB_User: root
DB_Password: paswrd
echo –n ‘bXlzcWw=’ | base64 --decode
mysql
echo –n ‘cm9vdA==’ | base64 --decode
root
echo –n ‘cGFzd3Jk’ | base64 --decode
paswrd
Secrets in Pods
Inject into Pod
2
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
labels:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
pod-definition.yaml
envFrom:
- secretRef:
name:
apiVersion:
kind:
metadata:
data:
secret-data.yaml
v1
Secret
name: app-secret
DB_Host: bXlzcWw=
DB_User: cm9vdA==
DB_Password: cGFzd3Jk
app-secret
kubectl create –f pod-definition.yaml
Secrets in Pods
envFrom:
- secretRef:
name: app-config
env:
- name: DB_Password
valueFrom:
secretKeyRef:
name: app-secret
key: DB_Password
volumes:
- name: app-secret-volume
secret:
secretName: app-secret
SINGLE ENV
VOLUME
ENV
Inside the Container
Secrets in Pods as Volumes
volumes:
- name: app-secret-volume
secret:
secretName: app-secret
VOLUME
ls /opt/app-secret-volumes
DB_Host DB_Password DB_User
cat /opt/app-secret-volumes/DB_Password
paswrd
121
Kubernetes
Multi-Container
PODs
MONOLITH
MICROSERVICES
MICROSERVICES
MICROSERVICES
MICROSERVICES
WEB Server
LOG Agent
WEB Server
LOG Agent
WEB Server
LOG Agent
POD
Multi-Container PODs
POD
Multi-Container PODs
POD
LIFECYCLE
NETWORK
STORAGE
Create
POD
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp
labels:
name: simple-webapp
spec:
containers:
- name: simple-webapp
image: simple-webapp
ports:
- containerPort: 8080
pod-definition.yaml
- name: log-agent
image: log-agent

More Related Content

Similar to Kubernetes+-CKA-+0400+-+Application+Lifecycle+Management.pdf

Openshift cheat rhce_r3v1 rhce
Openshift cheat rhce_r3v1 rhceOpenshift cheat rhce_r3v1 rhce
Openshift cheat rhce_r3v1 rhceDarnette A
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Cisco DevNet
 
From Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSFrom Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSSusan Potter
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient waySylvain Rayé
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionAlper Kanat
 
Présentation "Docker + Kubernetes" @ Pastis.tech #2
Présentation "Docker + Kubernetes" @ Pastis.tech #2Présentation "Docker + Kubernetes" @ Pastis.tech #2
Présentation "Docker + Kubernetes" @ Pastis.tech #2Blue Forest
 
Introduction to telepresence
Introduction to telepresenceIntroduction to telepresence
Introduction to telepresenceKyohei Mizumoto
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
 
Things I've learned working with Docker Support
Things I've learned working with Docker SupportThings I've learned working with Docker Support
Things I've learned working with Docker SupportSujay Pillai
 
Node.js basics
Node.js basicsNode.js basics
Node.js basicsBen Lin
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSYevgeniy Brikman
 
Deep dive in container service discovery
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discoveryDocker, Inc.
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installationAhmed Mekawy
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Ontico
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 

Similar to Kubernetes+-CKA-+0400+-+Application+Lifecycle+Management.pdf (20)

infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Openshift cheat rhce_r3v1 rhce
Openshift cheat rhce_r3v1 rhceOpenshift cheat rhce_r3v1 rhce
Openshift cheat rhce_r3v1 rhce
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!
 
From Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSFrom Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOS
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Simple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE LabSimple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE Lab
 
Présentation "Docker + Kubernetes" @ Pastis.tech #2
Présentation "Docker + Kubernetes" @ Pastis.tech #2Présentation "Docker + Kubernetes" @ Pastis.tech #2
Présentation "Docker + Kubernetes" @ Pastis.tech #2
 
Introduction to telepresence
Introduction to telepresenceIntroduction to telepresence
Introduction to telepresence
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Things I've learned working with Docker Support
Things I've learned working with Docker SupportThings I've learned working with Docker Support
Things I've learned working with Docker Support
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECS
 
Openshift31-tech.ppt
Openshift31-tech.pptOpenshift31-tech.ppt
Openshift31-tech.ppt
 
Deep dive in container service discovery
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discovery
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installation
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 

Kubernetes+-CKA-+0400+-+Application+Lifecycle+Management.pdf

  • 1. 65
  • 3. Rollout and Versioning Revision 1 Revision 2 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1
  • 4. Rollout Command > kubectl rollout status deployment/myapp-deployment Waiting for rollout to finish: 0 of 10 updated replicas are available... Waiting for rollout to finish: 1 of 10 updated replicas are available... Waiting for rollout to finish: 2 of 10 updated replicas are available... Waiting for rollout to finish: 3 of 10 updated replicas are available... Waiting for rollout to finish: 4 of 10 updated replicas are available... Waiting for rollout to finish: 5 of 10 updated replicas are available... Waiting for rollout to finish: 6 of 10 updated replicas are available... Waiting for rollout to finish: 7 of 10 updated replicas are available... Waiting for rollout to finish: 8 of 10 updated replicas are available... Waiting for rollout to finish: 9 of 10 updated replicas are available... deployment "myapp-deployment" successfully rolled out > kubectl rollout history deployment/myapp-deployment deployments "myapp-deployment" REVISION CHANGE-CAUSE 1 <none> 2 kubectl apply --filename=deployment-definition.yml --record=true
  • 5. Deployment Strategy nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 Application Down Recreate nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.0 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 nginx:1.7.1 Rolling Update
  • 6. Kubectl apply apiVersion: kind: metadata: spec: deployment-definition.yml name: myapp-deployment labels: app: myapp type: front-end apps/v1 metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-container image: nginx replicas: selector: matchLabels: type: front-end template: 3 Deployment :1.7.1 > kubectl apply –f deployment-definition.yml deployment "myapp-deployment" configured > kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1 deployment "myapp-deployment" image is updated
  • 8. Upgrades Deployment Replica Set - 1 POD POD POD POD POD Replica Set - 2 POD POD POD POD POD > kubectl get replicasets NAME DESIRED CURRENT READY AGE myapp-deployment-67c749c58c 0 0 0 22m myapp-deployment-7d57dbdb8d 5 5 5 20m
  • 9. Rollback Deployment Replica Set - 1 POD POD POD POD POD Replica Set - 2 POD POD POD POD POD > kubectl rollout undo deployment/myapp-deployment deployment “myapp-deployment” rolled back > kubectl get replicasets NAME DESIRED CURRENT READY AGE myapp-deployment-67c749c58c 0 0 0 22m myapp-deployment-7d57dbdb8d 5 5 5 20m > kubectl get replicasets NAME DESIRED CURRENT READY AGE myapp-deployment-67c749c58c 5 5 5 22m myapp-deployment-7d57dbdb8d 0 0 0 20m
  • 10. kubectl run > kubectl run nginx --image=nginx deployment "nginx" created
  • 11. Summarize Commands > kubectl rollout status deployment/myapp-deployment > kubectl rollout history deployment/myapp-deployment > kubectl create –f deployment-definition.yml > kubectl get deployments > kubectl apply –f deployment-definition.yml > kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1 > kubectl rollout undo deployment/myapp-deployment Create Get Update Status Rollback
  • 13. docker run ubuntu CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 45aacca36850 ubuntu "/bin/bash" 43 seconds ago Exited (0) 41 seconds ago docker ps docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
  • 14.
  • 15.
  • 16.
  • 17. ??
  • 18. docker run ubuntu [COMMAND] docker run ubuntu sleep 5 1 2 3 4 5
  • 19. FROM Ubuntu CMD sleep 5 CMD [“command”, “param1”] CMD command param1 CMD [“sleep”, “5”] CMD sleep 5 CMD [“sleep 5”] docker build –t ubuntu-sleeper . docker run ubuntu-sleeper 1 2 3 4 5
  • 20. sleep: missing operand Try 'sleep --help' for more information. FROM Ubuntu CMD sleep 5 docker run ubuntu-sleeper sleep 10 docker run ubuntu-sleeper 10 FROM Ubuntu ENTRYPOINT [“sleep”] Command at Startup: sleep 10 Command at Startup: sleep 10 docker run ubuntu-sleeper Command at Startup: sleep
  • 21. Command at Startup: sleep: missing operand Try 'sleep --help' for more information. docker run ubuntu-sleeper Command at Startup: FROM Ubuntu ENTRYPOINT [“sleep”] CMD [“5”] sleep 5 docker run ubuntu-sleeper 10 10 sleep docker run --entrypoint sleep2.0 ubuntu-sleeper 10 Command at Startup: sleep2.0 10
  • 22. apiVersion: kind: metadata: spec: pod-definition.yml kubectl create –f pod-definition.yml v1 Pod name: ubuntu-sleeper-pod containers: - name: image: docker run --name ubuntu-sleeper ubuntu-sleeper ubuntu-sleeper docker run --name ubuntu-sleeper ubuntu-sleeper 10 ubuntu-sleeper args: [“10”]
  • 23. apiVersion: kind: metadata: spec: pod-definition.yml kubectl create –f pod-definition.yml v1 Pod name: ubuntu-sleeper-pod containers: - name: image: ubuntu-sleeper ubuntu-sleeper args:[“10”] FROM Ubuntu ENTRYPOINT [“sleep”] CMD [“5”] docker run --name ubuntu-sleeper --entrypoint sleep2.0 ubuntu-sleeper 10 command: [“sleep2.0”]
  • 24. FROM Ubuntu ENTRYPOINT [“sleep”] CMD [“5”] apiVersion: kind: metadata: spec: pod-definition.yml v1 Pod name: ubuntu-sleeper-pod containers: - name: image: ubuntu-sleeper ubuntu-sleeper args:[“10”] command: [“sleep2.0”]
  • 26. import os from flask import Flask app = Flask(__name__) … … color = "red" @app.route("/") def main(): print(color) return render_template('hello.html', color=color) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py python app.py Environment Variables
  • 27. import os from flask import Flask app = Flask(__name__) … … color = "red" @app.route("/") def main(): print(color) return render_template('hello.html', color=color) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py Environment Variables
  • 28. import os from flask import Flask app = Flask(__name__) … … color = "red" @app.route("/") def main(): print(color) return render_template('hello.html', color=color) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py os.environ.get('APP_COLOR') export APP_COLOR=blue; python app.py Environment Variables
  • 29. import os from flask import Flask app = Flask(__name__) … … color = "red" @app.route("/") def main(): print(color) return render_template('hello.html', color=color) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py os.environ.get('APP_COLOR') docker run simple-webapp-color -e APP_COLOR=blue ENV Variables in Docker
  • 30. docker run simple-webapp-color -e APP_COLOR=blue docker run -e APP_COLOR=green simple-webapp-color docker run -e APP_COLOR=pink simple-webapp-color ENV Variables in Docker
  • 31. apiVersion: v1 kind: Pod metadata: name: simple-webapp-color spec: containers: - name: simple-webapp-color image: simple-webapp-color ports: - containerPort: 8080 pod-definition.yaml env: - name: value: APP_COLOR pink docker run -e APP_COLOR=pink simple-webapp-color ENV Variables in Kubernetes
  • 32. env: - name: value: APP_COLOR pink ENV Value Types Plain Key Value 1 ConfigMap 2 Secrets 3 env: - name: APP_COLOR valueFrom: env: - name: APP_COLOR valueFrom: configMapKeyRef: secretKeyRef:
  • 33. Course Objectives Core Concepts Multi-Container Pods Observability Configuration Pod Design Services & Networking State Persistence ConfigMaps SecurityContexts Resource Requirements Secrets ServiceAccounts
  • 34. apiVersion: v1 kind: Pod metadata: name: simple-webapp-color spec: containers: - name: simple-webapp-color image: simple-webapp-color ports: - containerPort: 8080 pod-definition.yaml env: - name: value: - name: value: APP_COLOR blue ConfigMaps APP_MODE prod ConfigMap
  • 35. APP_COLOR: blue APP_MODE: prod apiVersion: v1 kind: Pod metadata: name: simple-webapp-color spec: containers: - name: simple-webapp-color image: simple-webapp-color ports: - containerPort: 8080 pod-definition.yaml env: - name: value: - name: value: ConfigMaps ConfigMap Create ConfigMap Inject into Pod 1 2 APP_MODE APP_COLOR blue prod : : envFrom: - configMapRef: name: app-config
  • 36. Create ConfigMaps APP_COLOR: blue APP_MODE: prod ConfigMap Create ConfigMap 1 kubectl create configmap kubectl create –f Declarative Imperative
  • 37. Create ConfigMaps APP_COLOR: blue APP_MODE: prod ConfigMap Create ConfigMap 1 kubectl create configmap Imperative <config-name> --from-literal=<key>=<value> kubectl create configmap app-config --from-literal=APP_COLOR=blue --from-literal=APP_MOD=prod kubectl create configmap <config-name> --from-file=<path-to-file> kubectl create configmap app-config --from-file=app_config.properties
  • 38. Create ConfigMaps APP_COLOR: blue APP_MODE: prod ConfigMap Create ConfigMap 1 kubectl create –f Declarative apiVersion: kind: metadata: data: config-map.yaml v1 ConfigMap name: app-config APP_COLOR: blue APP_MODE: prod kubectl create –f config-map.yaml
  • 39. Create ConfigMaps APP_COLOR: blue APP_MODE: prod app-config Create ConfigMap 1 port: 6379 rdb-compression: yes redis-config port: 3306 max_allowed_packet: 128M mysql-config
  • 40. View ConfigMaps kubectl get configmaps NAME DATA AGE app-config 2 3s kubectl describe configmaps Name: app-config Namespace: default Labels: <none> Annotations: <none> Data ==== APP_COLOR: ---- blue APP_MODE: ---- prod Events: <none>
  • 41. ConfigMap in Pods Inject into Pod 2 apiVersion: v1 kind: Pod metadata: name: simple-webapp-color labels: name: simple-webapp-color spec: containers: - name: simple-webapp-color image: simple-webapp-color ports: - containerPort: 8080 pod-definition.yaml envFrom: - configMapRef: name: apiVersion: kind: metadata: data: config-map.yaml v1 ConfigMap name: app-config APP_COLOR: blue APP_MODE: prod app-config kubectl create –f pod-definition.yaml
  • 42. ConfigMap in Pods envFrom: - configMapRef: name: app-config env: - name: APP_COLOR valueFrom: configMapKeyRef: name: app-config key: APP_COLOR volumes: - name: app-config-volume configMap: name: app-config SINGLE ENV VOLUME ENV
  • 44. Web-MySQL Application import os from flask import Flask app = Flask(__name__) @app.route("/") def main(): mysql.connector.connect(host=‘mysql', database='mysql’, user='root', password=‘paswrd') return render_template('hello.html', color=fetchcolor()) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py
  • 45. import os from flask import Flask app = Flask(__name__) @app.route("/") def main(): mysql.connector.connect(host=‘mysql', database='mysql’, user='root', password=‘paswrd') return render_template('hello.html', color=fetchcolor()) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py Web-MySQL Application
  • 46. import os from flask import Flask app = Flask(__name__) @app.route("/") def main(): mysql.connector.connect(host=‘mysql', database='mysql’, user='root', password=‘paswrd') return render_template('hello.html', color=fetchcolor()) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080") app.py apiVersion: v1 kind: ConfigMap metadata: name: app-config data: config-map.yaml DB_Host: mysql DB_User: root DB_Password: paswrd Web-MySQL Application
  • 47. Secret DB_Host: mysql DB_User: root DB_Password: paswrd Secret POD DB_Host: mysql DB_User: root DB_Password: paswrd Environment Variable Create Secret Inject into Pod 1 2 DB_Host: bXlzcWw= DB_User: cm9vdA== DB_Password: cGFzd3Jk
  • 48. Create Secrets DB_Host: mysql DB_User: root DB_Password: paswrd Secret Create Secret 1 kubectl create secret generic kubectl create –f Declarative Imperative
  • 49. Create Secrets DB_Host: mysql DB_User: root DB_Password: paswrd Secret Create Secret 1 kubectl create secret generic Imperative <secret-name> --from-literal=<key>=<value> kubectl create secret generic app-secret --from-literal=DB_Host=mysql --from-literal=DB_User=root kubectl create secret generic <secret-name> --from-file=<path-to-file> kubectl create secret generic app-secret --from-file=app_secret.properties --from-literal=DB_Password=paswrd
  • 50. Create Secrets Create Secret 1 kubectl create –f Declarative apiVersion: kind: metadata: data: secret-data.yaml v1 Secret name: app-secret DB_Host: mysql DB_User: root DB_Password: paswrd kubectl create –f secret-data.yaml DB_Host: mysql DB_User: root DB_Password: paswrd Secret DB_Host: bXlzcWw= DB_User: cm9vdA== DB_Password: cGFzd3Jk
  • 51. Encode Secrets Create Secret 1 kubectl create –f Declarative apiVersion: kind: metadata: data: secret-data.yaml v1 Secret name: app-secret DB_Host: mysql DB_User: root DB_Password: paswrd kubectl create –f secret-data.yaml Secret DB_Host: bXlzcWw= DB_User: cm9vdA== DB_Password: cGFzd3Jk DB_Host: mysql DB_User: root DB_Password: paswrd echo –n ‘mysql’ | base64 bXlzcWw= echo –n ‘root’ | base64 cm9vdA== echo –n ‘paswrd’ | base64 cGFzd3Jk
  • 52. View Secrets kubectl get secrets NAME TYPE DATA AGE app-secret Opaque 3 10m default-token-mvtkv kubernetes.io/service-account-token 3 2h kubectl describe secrets Name: app-secret Namespace: default Labels: <none> Annotations: <none> Type: Opaque Data ==== DB_Host: 10 bytes DB_Password: 6 bytes DB_User: 4 bytes kubectl get secret app-secret –o yaml apiVersion: v1 data: DB_Host: bXlzcWw= DB_Password: cGFzd3Jk DB_User: cm9vdA== kind: Secret metadata: creationTimestamp: 2018-10-18T10:01:12Z labels: name: app-secret name: app-secret namespace: default uid: be96e989-d2bc-11e8-a545-080027931072 type: Opaque
  • 53. Decode Secrets Create Secret 1 kubectl create –f Declarative apiVersion: kind: metadata: data: secret-data.yaml v1 Secret name: app-secret DB_Host: mysql DB_User: root DB_Password: paswrd kubectl create –f secret-data.yaml Secret DB_Host: bXlzcWw= DB_User: cm9vdA== DB_Password: cGFzd3Jk DB_Host: mysql DB_User: root DB_Password: paswrd echo –n ‘bXlzcWw=’ | base64 --decode mysql echo –n ‘cm9vdA==’ | base64 --decode root echo –n ‘cGFzd3Jk’ | base64 --decode paswrd
  • 54. Secrets in Pods Inject into Pod 2 apiVersion: v1 kind: Pod metadata: name: simple-webapp-color labels: name: simple-webapp-color spec: containers: - name: simple-webapp-color image: simple-webapp-color ports: - containerPort: 8080 pod-definition.yaml envFrom: - secretRef: name: apiVersion: kind: metadata: data: secret-data.yaml v1 Secret name: app-secret DB_Host: bXlzcWw= DB_User: cm9vdA== DB_Password: cGFzd3Jk app-secret kubectl create –f pod-definition.yaml
  • 55. Secrets in Pods envFrom: - secretRef: name: app-config env: - name: DB_Password valueFrom: secretKeyRef: name: app-secret key: DB_Password volumes: - name: app-secret-volume secret: secretName: app-secret SINGLE ENV VOLUME ENV
  • 56. Inside the Container Secrets in Pods as Volumes volumes: - name: app-secret-volume secret: secretName: app-secret VOLUME ls /opt/app-secret-volumes DB_Host DB_Password DB_User cat /opt/app-secret-volumes/DB_Password paswrd
  • 66.
  • 69. Create POD apiVersion: v1 kind: Pod metadata: name: simple-webapp labels: name: simple-webapp spec: containers: - name: simple-webapp image: simple-webapp ports: - containerPort: 8080 pod-definition.yaml - name: log-agent image: log-agent