SlideShare a Scribd company logo
1 of 28
All You Need to Know to Deploy
Applications on Kubernetes
Eric Johnson, Google - @erjohnso
Oleksandr Slynko, Pivotal - @alex_sly
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
All you need is YAML
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The fine print...
We're making a few assumptions, so here are a few prerequisites. (e.g. not covered)
● Containers
● Image repositories
● Version control
● Build and test
● Security
● Monitoring and logging
● ...and more
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
What we'll actually cover...
● How to deploy an application?
● How to access it?
● How to keep it running?
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The app: Spring Music
https://github.com/cloudfoundry-samples/spring-music
● Spring Boot
● Database?
● ...andy mods?
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Plan
● How to deploy application?
● How to access it?
● How to keep it running?
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The image
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
image: s1pdemo/springmusic:v2
● Spring Music image
● Versioned
● Runnable (local dev)
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The container
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
● Single running process
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Configuration (environment variables)
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
env:
- name: SOMETHING
value: value
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Configuration (files)
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Pod
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
...
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
● Set of containers
● Communicate using files
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Pod
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
● Run some command before starting each pod
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Don’t use pods directly
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
ReplicaSet
● Make sure N pods are running at the same time
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Deployment
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
StatefulSet
● Applications with state (disks)
● Applications can only start/upgrade sequentially
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Plan
● How to deploy application?
● How to access it?
● How to keep it running?
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Service
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
● Internal - will have static ips inside the
cluster
● External - NodePort or Load Balancer
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Readiness probe
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Plan
● How to deploy application?
● How to access it?
● How to keep it running?
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Replicas
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
replicas: 3
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Replicate across cluster
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
affinity:
podAntiAffinity:
requiredDuringScheduling
IgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey:
"kubernetes.io/hostname"
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Survive upgrades
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
● How many pods can be
unavailable at any time
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Graceful shutdown
Handle SIGTERM signal
Pre-stop hook
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Kill unresponsive application
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: springone
name: springone
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: springone
type: LoadBalancer
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: springone
spec:
minAvailable: 2
selector:
matchLabels:
k8s-app: springone
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Great demo
labels:
k8s-app: springone
name: springone
namespace: default
spec:
progressDeadlineSeconds: 600
...
replicas: 3
selector:
matchLabels:
k8s-app: springone
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s-app: springone
name: springone
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springone
topologyKey: "kubernetes.io/hostname"
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
...
initContainers:
- name: run-migration
image: s1pdemo/springmusicmigration:v2
command: ["/bin/run_migration.sh"]
containers:
- image: s1pdemo/tweet_loader:21fab0554
name: poller
volumeMounts:
- name: shared-data
mountPath: /tweet-info
- image: s1pdemo/springmusic:v2
imagePullPolicy: Always
name: springone
env:
- name: SOMETHING
value: value
securityContext:
privileged: false
volumeMounts:
- name: shared-data
mountPath: /data/tweets
- name: config-volume
configMap:
name: springone
items:
- key: application.properties
path: application.properties
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 2
...
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds:
30
---
apiVersion: v1
data:
application.properties:
spring.music=springonedemoCONFIGVALUE
kind: ConfigMap
metadata:
name: springone
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 45
periodSeconds: 3
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Further reading
Secrets
Horizontal Pod Autoscaler
Pod Security Policies
Resource Limits
Pod Priority Class
Cluster DNS
Ingress Controllers
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Recap
● How to deploy application?
○ Deployments, Stateful Sets
● How to access it?
○ Service
● How to keep it running?
○ Replicas, Affinity Groups,
Graceful shutdown, Liveness
Probe
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Thank you!
Want to try this out for yourself?
● Create a Kubernetes cluster
○ Create a GKE cluster: https://cloud.google.com/kubernetes-engine/
■ Gets started for free: https://cloud.google.com/free/
○ Create a CFCR cluster - check the next talk
○ Or create a PKS cluster - https://pivotal.io/pks
● Big YAML: https://bit.ly/k8s-manifest
● Slides: https://bit.ly/all-you-need-is-yaml

More Related Content

What's hot

Cross platform-mobile-applications
Cross platform-mobile-applicationsCross platform-mobile-applications
Cross platform-mobile-applicationsmailalamin
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react MoonTechnolabsPvtLtd
 
7 network programmability concepts api
7 network programmability concepts api7 network programmability concepts api
7 network programmability concepts apiSagarR24
 
What makes xamarin the best choice for multiplatform app development
What makes xamarin the best choice for multiplatform app development What makes xamarin the best choice for multiplatform app development
What makes xamarin the best choice for multiplatform app development MoonTechnolabsPvtLtd
 
SAP Kapsel Plugins For Cordova
SAP Kapsel Plugins For CordovaSAP Kapsel Plugins For Cordova
SAP Kapsel Plugins For CordovaChris Whealy
 
React native vs react js
React native vs react jsReact native vs react js
React native vs react jsJessica655282
 
IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016Trayan Iliev
 
React native vs. ionic – which one is better and why
React native vs. ionic – which one is better and why React native vs. ionic – which one is better and why
React native vs. ionic – which one is better and why Moon Technolabs Pvt. Ltd.
 
The Phonegap Architecture
The Phonegap ArchitectureThe Phonegap Architecture
The Phonegap ArchitectureFrank Gielen
 
Should you choose react native or swift for i os app development
Should you choose react native or swift for i os app development Should you choose react native or swift for i os app development
Should you choose react native or swift for i os app development Moon Technolabs Pvt. Ltd.
 
Xamarin vs. native script which one is the ideal cross-platform framework fo...
Xamarin vs. native script  which one is the ideal cross-platform framework fo...Xamarin vs. native script  which one is the ideal cross-platform framework fo...
Xamarin vs. native script which one is the ideal cross-platform framework fo...Moon Technolabs Pvt. Ltd.
 
Flutter App Development Services
Flutter App Development ServicesFlutter App Development Services
Flutter App Development ServicesThe NineHertz
 
An overview of the architecture of electron.js
An overview of the architecture of electron.jsAn overview of the architecture of electron.js
An overview of the architecture of electron.jsMoon Technolabs Pvt. Ltd.
 
The Best Alternatives To The Ionic Framework.pdf
The Best Alternatives To The Ionic Framework.pdfThe Best Alternatives To The Ionic Framework.pdf
The Best Alternatives To The Ionic Framework.pdfMoon Technolabs Pvt. Ltd.
 
Felgo vs. Flutter vs. React Native: An in-Depth Comparison
Felgo vs. Flutter vs. React Native: An in-Depth ComparisonFelgo vs. Flutter vs. React Native: An in-Depth Comparison
Felgo vs. Flutter vs. React Native: An in-Depth ComparisonKaty Slemon
 
Top reasons why flutter become a trend in application development
Top reasons why flutter become a trend in application developmentTop reasons why flutter become a trend in application development
Top reasons why flutter become a trend in application developmentAndolasoft Inc
 

What's hot (20)

Cross platform-mobile-applications
Cross platform-mobile-applicationsCross platform-mobile-applications
Cross platform-mobile-applications
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react
 
7 network programmability concepts api
7 network programmability concepts api7 network programmability concepts api
7 network programmability concepts api
 
What makes xamarin the best choice for multiplatform app development
What makes xamarin the best choice for multiplatform app development What makes xamarin the best choice for multiplatform app development
What makes xamarin the best choice for multiplatform app development
 
SAP Kapsel Plugins For Cordova
SAP Kapsel Plugins For CordovaSAP Kapsel Plugins For Cordova
SAP Kapsel Plugins For Cordova
 
React native vs react js
React native vs react jsReact native vs react js
React native vs react js
 
[IJCT-V3I2P36] Authors: Amarbir Singh
[IJCT-V3I2P36] Authors: Amarbir Singh[IJCT-V3I2P36] Authors: Amarbir Singh
[IJCT-V3I2P36] Authors: Amarbir Singh
 
IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016
 
React native vs. ionic – which one is better and why
React native vs. ionic – which one is better and why React native vs. ionic – which one is better and why
React native vs. ionic – which one is better and why
 
The Phonegap Architecture
The Phonegap ArchitectureThe Phonegap Architecture
The Phonegap Architecture
 
Should you choose react native or swift for i os app development
Should you choose react native or swift for i os app development Should you choose react native or swift for i os app development
Should you choose react native or swift for i os app development
 
Xamarin vs. native script which one is the ideal cross-platform framework fo...
Xamarin vs. native script  which one is the ideal cross-platform framework fo...Xamarin vs. native script  which one is the ideal cross-platform framework fo...
Xamarin vs. native script which one is the ideal cross-platform framework fo...
 
Flutter App Development Services
Flutter App Development ServicesFlutter App Development Services
Flutter App Development Services
 
GSOC 2016 mifos
GSOC 2016 mifosGSOC 2016 mifos
GSOC 2016 mifos
 
Codename one
Codename oneCodename one
Codename one
 
mobicon_paper
mobicon_papermobicon_paper
mobicon_paper
 
An overview of the architecture of electron.js
An overview of the architecture of electron.jsAn overview of the architecture of electron.js
An overview of the architecture of electron.js
 
The Best Alternatives To The Ionic Framework.pdf
The Best Alternatives To The Ionic Framework.pdfThe Best Alternatives To The Ionic Framework.pdf
The Best Alternatives To The Ionic Framework.pdf
 
Felgo vs. Flutter vs. React Native: An in-Depth Comparison
Felgo vs. Flutter vs. React Native: An in-Depth ComparisonFelgo vs. Flutter vs. React Native: An in-Depth Comparison
Felgo vs. Flutter vs. React Native: An in-Depth Comparison
 
Top reasons why flutter become a trend in application development
Top reasons why flutter become a trend in application developmentTop reasons why flutter become a trend in application development
Top reasons why flutter become a trend in application development
 

Similar to All you need to know to deploy applications on Kubernetes

riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott AndrewsVMware Tanzu
 
Spring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterSpring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterVMware Tanzu
 
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidLiving on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidVMware Tanzu
 
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidLiving on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidVMware Tanzu
 
Policy Enforcement on Kubernetes with Open Policy Agent
Policy Enforcement on Kubernetes with Open Policy AgentPolicy Enforcement on Kubernetes with Open Policy Agent
Policy Enforcement on Kubernetes with Open Policy AgentVMware Tanzu
 
Spring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterSpring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterVMware Tanzu
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor CaliforniumStéphane Maldini
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...cornelia davis
 
Automation and Culture Changes for 40M Subscriber Platform Operation
Automation and Culture Changes for 40M Subscriber Platform OperationAutomation and Culture Changes for 40M Subscriber Platform Operation
Automation and Culture Changes for 40M Subscriber Platform OperationVMware Tanzu
 
Spring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniSpring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniVMware Tanzu
 
How to Manage Microservices and APIs with Apigee and Istio
How to Manage Microservices and APIs with Apigee and IstioHow to Manage Microservices and APIs with Apigee and Istio
How to Manage Microservices and APIs with Apigee and IstioVMware Tanzu
 
Developer Secure Containers for the Cyberspace Battlefield
Developer Secure Containers for the Cyberspace BattlefieldDeveloper Secure Containers for the Cyberspace Battlefield
Developer Secure Containers for the Cyberspace BattlefieldVMware Tanzu
 
Innovating Faster with Continuous Application Security
Innovating Faster with Continuous Application Security Innovating Faster with Continuous Application Security
Innovating Faster with Continuous Application Security Jeff Williams
 
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...VMware Tanzu
 
P to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to ContainersP to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to ContainersVMware Tanzu
 
IO State In Distributed API Architecture
IO State In Distributed API ArchitectureIO State In Distributed API Architecture
IO State In Distributed API ArchitectureOwen Rubel
 
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...VMware Tanzu
 

Similar to All you need to know to deploy applications on Kubernetes (20)

riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott Andrews
 
Spring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterSpring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan Baxter
 
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidLiving on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
 
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora IberkleidLiving on the Edge With Spring Cloud Gateway - Cora Iberkleid
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
 
Policy Enforcement on Kubernetes with Open Policy Agent
Policy Enforcement on Kubernetes with Open Policy AgentPolicy Enforcement on Kubernetes with Open Policy Agent
Policy Enforcement on Kubernetes with Open Policy Agent
 
Spring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan BaxterSpring Cloud Gateway - Ryan Baxter
Spring Cloud Gateway - Ryan Baxter
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor Californium
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
 
Automation and Culture Changes for 40M Subscriber Platform Operation
Automation and Culture Changes for 40M Subscriber Platform OperationAutomation and Culture Changes for 40M Subscriber Platform Operation
Automation and Culture Changes for 40M Subscriber Platform Operation
 
Spring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniSpring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane Maldini
 
How to Manage Microservices and APIs with Apigee and Istio
How to Manage Microservices and APIs with Apigee and IstioHow to Manage Microservices and APIs with Apigee and Istio
How to Manage Microservices and APIs with Apigee and Istio
 
Developer Secure Containers for the Cyberspace Battlefield
Developer Secure Containers for the Cyberspace BattlefieldDeveloper Secure Containers for the Cyberspace Battlefield
Developer Secure Containers for the Cyberspace Battlefield
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud Gateway
 
Innovating Faster with Continuous Application Security
Innovating Faster with Continuous Application Security Innovating Faster with Continuous Application Security
Innovating Faster with Continuous Application Security
 
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
 
P to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to ContainersP to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to Containers
 
S1P: Spring Cloud on PKS
S1P: Spring Cloud on PKSS1P: Spring Cloud on PKS
S1P: Spring Cloud on PKS
 
Serverless Spring 오충현
Serverless Spring 오충현Serverless Spring 오충현
Serverless Spring 오충현
 
IO State In Distributed API Architecture
IO State In Distributed API ArchitectureIO State In Distributed API Architecture
IO State In Distributed API Architecture
 
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...
Cloud Foundry Services on PKS with No Extra Code, "We Bosh So You Don’t Have ...
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

All you need to know to deploy applications on Kubernetes

  • 1. All You Need to Know to Deploy Applications on Kubernetes Eric Johnson, Google - @erjohnso Oleksandr Slynko, Pivotal - @alex_sly
  • 2. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ All you need is YAML apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone
  • 3. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The fine print... We're making a few assumptions, so here are a few prerequisites. (e.g. not covered) ● Containers ● Image repositories ● Version control ● Build and test ● Security ● Monitoring and logging ● ...and more
  • 4. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What we'll actually cover... ● How to deploy an application? ● How to access it? ● How to keep it running?
  • 5. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The app: Spring Music https://github.com/cloudfoundry-samples/spring-music ● Spring Boot ● Database? ● ...andy mods?
  • 6. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Plan ● How to deploy application? ● How to access it? ● How to keep it running?
  • 7. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The image apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone image: s1pdemo/springmusic:v2 ● Spring Music image ● Versioned ● Runnable (local dev)
  • 8. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The container apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone ● Single running process
  • 9. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Configuration (environment variables) apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone env: - name: SOMETHING value: value
  • 10. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Configuration (files) apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties
  • 11. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Pod apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 ... volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: ● Set of containers ● Communicate using files
  • 12. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Pod apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] ● Run some command before starting each pod
  • 13. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Don’t use pods directly
  • 14. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ ReplicaSet ● Make sure N pods are running at the same time
  • 15. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Deployment apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone
  • 16. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ StatefulSet ● Applications with state (disks) ● Applications can only start/upgrade sequentially
  • 17. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Plan ● How to deploy application? ● How to access it? ● How to keep it running?
  • 18. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Service apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer ● Internal - will have static ips inside the cluster ● External - NodePort or Load Balancer
  • 19. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Readiness probe apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2
  • 20. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Plan ● How to deploy application? ● How to access it? ● How to keep it running?
  • 21. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Replicas apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone replicas: 3
  • 22. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Replicate across cluster apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone affinity: podAntiAffinity: requiredDuringScheduling IgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname"
  • 23. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Survive upgrades apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone ● How many pods can be unavailable at any time
  • 24. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Graceful shutdown Handle SIGTERM signal Pre-stop hook
  • 25. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Kill unresponsive application apiVersion: v1 kind: Service metadata: labels: k8s-app: springone name: springone spec: ports: - port: 80 targetPort: 8080 selector: k8s-app: springone type: LoadBalancer --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: springone spec: minAvailable: 2 selector: matchLabels: k8s-app: springone --- apiVersion: apps/v1 kind: Deployment metadata: annotations: description: Great demo labels: k8s-app: springone name: springone namespace: default spec: progressDeadlineSeconds: 600 ... replicas: 3 selector: matchLabels: k8s-app: springone strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: k8s-app: springone name: springone spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: k8s-app operator: In values: - springone topologyKey: "kubernetes.io/hostname" volumes: - name: shared-data emptyDir: {} - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties ... initContainers: - name: run-migration image: s1pdemo/springmusicmigration:v2 command: ["/bin/run_migration.sh"] containers: - image: s1pdemo/tweet_loader:21fab0554 name: poller volumeMounts: - name: shared-data mountPath: /tweet-info - image: s1pdemo/springmusic:v2 imagePullPolicy: Always name: springone env: - name: SOMETHING value: value securityContext: privileged: false volumeMounts: - name: shared-data mountPath: /data/tweets - name: config-volume configMap: name: springone items: - key: application.properties path: application.properties readinessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 10 periodSeconds: 3 successThreshold: 2 ... livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3 dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 --- apiVersion: v1 data: application.properties: spring.music=springonedemoCONFIGVALUE kind: ConfigMap metadata: name: springone livenessProbe: httpGet: path: /actuator/health port: 8080 initialDelaySeconds: 45 periodSeconds: 3
  • 26. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Further reading Secrets Horizontal Pod Autoscaler Pod Security Policies Resource Limits Pod Priority Class Cluster DNS Ingress Controllers
  • 27. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Recap ● How to deploy application? ○ Deployments, Stateful Sets ● How to access it? ○ Service ● How to keep it running? ○ Replicas, Affinity Groups, Graceful shutdown, Liveness Probe
  • 28. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Thank you! Want to try this out for yourself? ● Create a Kubernetes cluster ○ Create a GKE cluster: https://cloud.google.com/kubernetes-engine/ ■ Gets started for free: https://cloud.google.com/free/ ○ Create a CFCR cluster - check the next talk ○ Or create a PKS cluster - https://pivotal.io/pks ● Big YAML: https://bit.ly/k8s-manifest ● Slides: https://bit.ly/all-you-need-is-yaml

Editor's Notes

  1. Link to talk: https://springoneplatform.io/2018/sessions/all-you-need-to-know-to-deploy-applications-on-kubernetes [E & A] - intros [E] Ok, let's get started. We're going to show you All you need to know to deploy apps on k8s. We spent a lot of time thinking about how to make this as straightforward as possible. So, here you go...
  2. [E] All you need is YAML! If you're having trouble reading it, please move closer to the front. Since this is really all you need, we'll give you about 20 minutes to read through it and then take questions. [E] Ok... bad joke! While this is a comprehensive example of the YAML needed to deploy an app to k8s, we'll explain this in more detail. [E] Oh, and we're not really going to cover "ALL you need to know..."
  3. [E] There's a few things we're going to assume you have some knowledge of and other best practices for deploying and operating k8s. For a common starting point, let's assume we have an application in mind and know the basics of packing it as an image and storing the image in a repository. And while we're not going to go into details here, we're going to assume you have access to a Kubernetes cluster. For our talk, we'll be using Google Kubernetes Engine already pre-provisioned for us.
  4. [E] The talk will really focus on these necessary aspects of an app on k8s. How to deploy, access, and make sure it's available.
  5. [E] Since this is a Spring conference, we thought a good app to use would be the Spring Music sample app. If you're not already familiar with it, this is an excellent way to get started with Spring Boot (and if you're so inclined, deploying it to Cloud Foundry). But in this case, we'll deploy to K8s.
  6. [E] Alright, let's get started. Alex, let's go back and look at that wall of YAML and highlight what you need to know with respect to deployment.
  7. [A] First, we need image used for the application, it should be runnable, and versioned. There are multiple guides for how to building docker images. We'll pull this image when we deploy and when later when scaling up. Runnable for local developement And we'll be using a Spring app for the demo
  8. When you have the image, you now build the container You'll need name, location, and policy. When we scale up, the imagePulPolicy means to pull the latest image. This is why nicknames/versions are important. The version name can be anything you like but should not be mutable (any changes to your app should result in a new name/version.
  9. [A] There are two ways to configure. You can use environment variables (map of name/value). The other way is to use volumes for example a confgmap where the configuration is stored within k8s. For example, you can store your spring boot app properties in the config map. [E] Oh, I didn't you could do two ways. Which is the preferred way, or what you recommend? [A] It depends!!! But, one nice feature of using configmap with spring cloud library is that it checks for configmap changes and recreate your container when you change something.
  10. [A] There are two ways to configure. You can use environment variables (map of name/value). The other way is to use volumes for example a confgmap where the configuration is stored within k8s. For example, you can store your spring boot app properties in the config map. [E] Oh, I didn't you could do two ways. Which is the preferred way, or what you recommend? [A] It depends!!! But, one nice feature of using configmap with spring cloud library is that it checks for configmap changes and recreate your container when you change something.
  11. A container is a minimal runnable process - but for K8s the minimal entity "pods". It allows group multiple containers in a pod and including shared storage. All those containers will be started together. You should consider separating functionality of your app into separate pods. For example, keep your database pods separate from your application pods. This will allow you to more easily scale your application and/or database independently.
  12. [E] But how would you handle something like a database migration? [A] You can use initContaiers for something like that. If you need to perform operations on the database, or configuration changes, then initContainers allow you to execute commands before the pod is created. For deletion you can use some hooks, but lets not jump ahead ( slide about graceful shutdown
  13. [A] But don't use pods directly for deploying an application [E] Why is that Alex? [A] Pods are connected to a single node, if a node goes down, the pod (as a primitive) won't be rescheduled by k8s. Another good reason is scaling up/down. Also, pod is immutable. If you want to change something, you have to delete old pod and create a new one.
  14. Kubernetes has abstraction to keep specific amount of pods up and running. But it does not include updates. So for green-blue deployments it has a special object called Deployment
  15. Deployment specifies all the definitions that required to run the application and helps with upgrades, it also allows to rollback to previous working version . [E] How does deploy? [A] Under the cover deployment creates a replicaset. For each change, it creates a new replicaset and gradually create new pods and delete old ones. By default it ensures that at most 25% extra pods created and at least 75% of desired amount of pods are available at any given time. [E] What is the order the deletion happen? [A] There is no order. If you need some order for your application, you should use stateful set
  16. AS the name suggests, stateful sets help with the applications that have state. For example that use disk, or that have to be started in specific order.
  17. ???
  18. [E] why do you need to create internal service? [A] I told you that pods are immutable. So every time you change something – pod is recreated. That means that every time you change something – pod IP address is going to change. Services have their own network and have the same ip address all the time which will be resolved to different pods. External lserice exposes port on the node which then points to the service ip address. Load balancer points that exposed port. So each service just adds something down the way. [E] So when I have a service and new pod is created, it starts to receive traffic from the service? [A] Yes, when pod is ready, it starts getting traffic. And there is a way to show that pod is ready.
  19. [A] Obviously, to make your application highly available you need several replicas. As I mentioned before, pods can be terminated at any moment. [E] Will 3 replicas be deployed on separate VMs?
  20. [A] Kubernetes by default tries to schedule pods on different nodes, but there is no guarantee. [E] Why there so many options? (????) [A] It is very configurable and supports multiple use-cases. First affinity and antiAffinity, so deploy pods when condition match or not deploy. This long key says require this condition to match before scheduling. There is also preferred. Next - label selector. It can have labels that are not set by your application. You can have additional replicas that do not receive traffic and deploy them on the nodes that do not have main service. As you can see pod anti affinity is an option, there is also affinity option that requires pods to be on some condition match. Topology key allows to choose where to deploy application by hostname, availability zone or instance type. [E] So should I always use requiredDuringScheduling? [A] Not really. It guarantees that pods will be scheduled on different virtual machines. But it also won’t let you scale above the amount of VMs. [E] But if I have multiple pods on the same node, they will all be unavailable during the upgrade (???) [A] It can be fixed with Pod Disruption budget
  21. [A] Pod disruption allows you to specify how many pods could unavailable at any given moment or how many should be available This can help,during upgrade or rollout of Kubernetes deployment. Especially when stopping the pod takes time. [E] I thought that upgrade just destroys the container [A] No, the developer can actually control the deletion.
  22. [A] And should control to provide graceful shutdown. There are three steps to stop each pod. First, pod is marked that it is deleting. After that the pod is removed from service backend, and pre-stop hook is executed. After it finishes or grace period expires, each container gets SIGTERM signal. If the application is not closed after grace period it is killed. [E] Spring handles SIGTERM signal, so it possible to add shutdown hook to finish processing. (Transition t the next slide ??? )
  23. [A] This are the nice-to-haves. It worth checking them after you have can start your application in K8s.