SlideShare a Scribd company logo
1 of 31
Kubernetes
#4. Volume & StatefulSet
조대협 (http://bcho.tistory.com)
Agenda
● Volume
● PersistentVolume and PersistentVolumeClaim
● StatefulSet
Volume
Volume is
● Disk resource which is described as a part of Pod
● It can be shared across containers in Pod
● It must be mounted to container which wants to access the volume
● Life cycle is managed by Pod
Volume is created when Pod is started and deleted when Pod is deleted.
(Not along with container)
Volume type
Temp Local Network
emptyDir hostPath GlusterFS
gitRepo
NFS
iSCSI
gcePersistentDisk
AWS EBS
azureDisk
Fiber Channel
Secret
VshereVolume
Volume type - empyDir
● A simple empty directory used for storing transient data
● It is good for ephemeral storage and good for file sharing across container
emptyDir can use Memory as a disk
Volume type - hostPath
● It posts to a specific file or directory on the node’s file system
● Pods running on same node and using the same path in their volume
● hostPath volume is not deleted when Pod is torn down
(If new Pod is started, the files in the hostPath volume will be remained)
Node
Pod Pod
/mydirectory/
Node
Pod
/mydirectory/
If you’re thinking of using a hostPath volume as the place to store a database’s data directory, think again.
Because the volume’s contents are stored on a specific node’s filesystem, when the database pod gets
rescheduled to another node, it will no longer see the data.
Pod
Volume type - gitRepo
● A gitRepo volume is basically an emptyDir volume
● It gets populated by cloning a Git repository and checking out a specific revision
when the pod is starting up (but before its containers are created)
● Useful to provisioning static (HTML) data or script source from git
Container
gitRepo
<<emptyDir>> Clone
apiVersion: v1
kind: Pod
metadata:
name: gitrepo-volume-pod
spec:
containers:
- image: nginx:alpine
name: web-server
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
readOnly: true
ports:
- containerPort: 80
protocol: TCP
volumes:
- name: html
gitRepo:
repository: https://github.com/luksa/kubia-website-example.git
revision: master
directory: .
PersistentVolume
& PersitentVolumeClaim
PersistentVolume
● PersistentVolume
Life cycle is managed by k8s cluster (not pod)
Admin can create PersistentVolume (Static provisioning) and developer just
use the volume thru PersistentVolumeClaim without understanding of
infrastructure
(It is more common to use dynamic volume provisioning instead of volume provisioning by admin)
Pod
Container
Volume
Bind
PersistentVolu
meClaim
PersistentVolume
<<Created by admin>>
create
admin
Select
Physical disk
create
PersistentVolume
● PersistentVolume
● Capacity : Storage size
In future it will include IOPS,throughput etc
● VolumeMode (from 1.9) : Filesystem(default) or
rawblock device
● Reclaim Policy
○ Retain – manual reclamation
○ Recycle – basic scrub (rm -rf /thevolume/*)
○ Delete – associated storage asset such as
AWS EBS, GCE PD, Azure Disk, or OpenStack
Cinder volume is deleted
● Mount Option
Additional mount options for when a Persistent
Volume is mounted on a node
Currently, only NFS and HostPath support recycling. AWS
EBS, GCE PD, Azure Disk, and Cinder volumes support
deletion.
PersistentVolume
● AccessModes
○ ReadWriteOnce (RWO)– the
volume can be mounted as
read-write by a single node
○ ReadOnlyMany (ROX) – the
volume can be mounted
read-only by many nodes
○ ReadWriteMany (RWX) – the
volume can be mounted as
read-write by many nodes
A volume can only be mounted using
one access mode at a time, even if it
supports many. For example, a
GCEPersistentDisk can be mounted as
ReadWriteOnce by a single node or
ReadOnlyMany by many nodes, but not
at the same time.
RWO를 여러 Pod에 붙일려고 하면 에러가 남
PersistentVolume Phase
● Available - a free resource that yet is not bound to a claim
● Bound - the volume is bound to a claim
● Released - the claim has been deleted but the resource is not yet reclaimed
by the cluster
● Failed - the volume has failed its automatic reclamation
Lifecycle of volume and claim
Provisioning
● Static
● Dynamic : Dynamically create volume with storage class.
Binding
● Bind PV to PVC
Using
● Bind PVC to Pod and starts to use
Reclaiming
PersistentVolumeClaim (PVC)
Claiming a PersistentVolume is a completely separate process from creating a pod, because you want
the same PersistentVolumeClaim to stay available even if the pod is rescheduled (remember,
rescheduling means the previous pod is deleted and a new one is created
apiVersion: v1 kind: PersistentVolumeClaim
metadata:
name: mongodb-pvc
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
storageClassName: ""
List PersistentVolume
List PersistentVolumeClaim
쿠버네티스 인액션 예제
Nobody else can claim the same volume until you release it.
PersistentVolumeClaim (PVC)
https://kubernetes.io/docs/concepts/s
torage/persistent-
volumes/#persistentvolumeclaims
● accessMode : same as volume
● VolumeMode : same as volume
● Resource : Claims, like pods, can request specific
quantities of a resource. In this case, the request is for
storage. The same resource model applies to both volumes
and claims.
● Selector : Claims can specify a label selector to further
filter the set of volumes. Only the volumes whose labels
match the selector can be bound to the claim
All of the requirements, from both matchLabels and
matchExpressions are ANDed together – they must all be
satisfied in order to match
Using PVC in Pod
쿠버네티스 인액션 예제
Google Cloud Kubernetes example
Recycling
● When a user is done with their volume, they can delete PVC object which allows
reclamation of the resource
● Reclaim policy for PersistentVolume tell the cluster what to do with the volume after it
has been released of its claim
● Reclaim policy
○ Retain (remain / cannot reuse)
After PVC is deleted, PV still exists and volume is marked as “released”. It cannot
be reused by other PVC. (it needs to delete manually)
○ Delete
Delete volume as well as associated storage asset in external infrastructure
○ Recycle (remain / can reuse)
Perform basic scrub (rm -f /thevolume/*) on volume and makes it available again
for a new claim
The Recycle reclaim policy is deprecated. Instead, the recommended approach
is to use dynamic provisioning.
Volume retaining test
Change Reclaim policy from DELETE to Retain
Recreat PVC & POD
Delete Pod and PVC
Dynamic Provisioning
From k8s 1.6. Without manual provisioning of PersistentVolume. Kubernetes can dynamically create
volume based on PersistentVolumeClaim (and storage class)
Pod
Container
Volume
Bind
PersistentVolu
meClaim
PersistentVolume
<<DynamicVoume>>
k8s
Dynamically
created
Instead of admin to create PV manually, admin can deploy Persistent volume provisioner and define one
or more storage class object to let users choose type of PV.
PersistentVolume
<<DynamicVoume>>
Dynamically
created
Request Volume with storage class
Dynamic Provisioning
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/gce-
pd
parameters:
type: pd-ssd
zone: europe-west1-b
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongodb-pvc
spec:
storageClassName: fast
resources:
requests:
storage: 100Mi
accessModes:
- ReadWriteOnce
Storage Class
Example
Storage Class
Get default storage class
StatefulSet
Replicating stateful pod
● With ReplicaSet
All pod will refer same PVC and same PV
● Option : Create RS per Pod
Statefulset
● To support stateful application (like database)
● It is supported from k8s 1.9(GA)
● Pod Naming : ${Stateful set name}-${ordinary index}
It is not that the pods having a predictable name and hostname.
It is better to use service for naming.
● When Pod (under statefulset) is restarted (by crash), Pod name will not be changed.
Cf. in case of RS, the Pod name is changed to new one.
StatefulSet specification example
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labels
serviceName: "nginx"
replicas: 3 # by default is 1
template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "my-storage-class"
resources:
requests:
storage: 1Gi
StatefulSet
Pod to PV mapping
● Each pod will get its own PVC and PV
● The PVC will be created “Volume claim template” in StatefulSet specification
POD-1 PVC-1 PV-1
POD-2 PVC-2 PV-2
POD-3 PVC-3 PV-3
Volume claim
template
Pod Template
Create
Create
Scale in & out
● Scale in
POD-1 PVC-1 PV-1
POD-2 PVC-2 PV-2
PVC-3 PV-3
POD-1 PVC-1 PV-1
POD-2 PVC-2 PV-2
POD-3 PVC-3 PV-3
POD-3 is removed by scale in , But PVC-3 and PV-3 are not deleted
● Scale out
POD-3 is added by scale out. It is attached previous PVC-3 and PV-3
It enables POD connect to same PVC and PV and it POD to retain same stateful information in disk
Because of this reason, PVC and PV are not automatically deleted. To delete PVC and PV,
admin needs to manually delete the PVC and PV
Pod management policies
● .spec.podManagementPolicy
○ OrderedReady (default) : start and terminate Pod sequential.
○ Parallel : start Pod and terminate in parallel
End of document

More Related Content

What's hot

Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistenceJanakiram MSV
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)DongHyeon Kim
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for BeginnersOktay Esgul
 
Starting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesStarting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesKohei Tokunaga
 
Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Janakiram MSV
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionPeng Xiao
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introductionSparkbit
 
Autoscaling Kubernetes
Autoscaling KubernetesAutoscaling Kubernetes
Autoscaling Kubernetescraigbox
 
Deep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingDeep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingSreenivas Makam
 
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeAcademy
 
User authentication and authorizarion in Kubernetes
User authentication and authorizarion in KubernetesUser authentication and authorizarion in Kubernetes
User authentication and authorizarion in KubernetesNeependra Khare
 

What's hot (20)

Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistence
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)
 
Kubernetes PPT.pptx
Kubernetes PPT.pptxKubernetes PPT.pptx
Kubernetes PPT.pptx
 
Helm.pptx
Helm.pptxHelm.pptx
Helm.pptx
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for Beginners
 
Starting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesStarting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of Images
 
Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
 
Autoscaling Kubernetes
Autoscaling KubernetesAutoscaling Kubernetes
Autoscaling Kubernetes
 
Deep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingDeep dive into Kubernetes Networking
Deep dive into Kubernetes Networking
 
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101
 
What Is Helm
 What Is Helm What Is Helm
What Is Helm
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
User authentication and authorizarion in Kubernetes
User authentication and authorizarion in KubernetesUser authentication and authorizarion in Kubernetes
User authentication and authorizarion in Kubernetes
 
Kubernetes networking & Security
Kubernetes networking & SecurityKubernetes networking & Security
Kubernetes networking & Security
 

Similar to Kubernetes #4 volume &amp; stateful set

Persistent Storage with Containers with Kubernetes & OpenShift
Persistent Storage with Containers with Kubernetes & OpenShiftPersistent Storage with Containers with Kubernetes & OpenShift
Persistent Storage with Containers with Kubernetes & OpenShiftRed Hat Events
 
Persistent Storage in Docker Platform
Persistent Storage in Docker PlatformPersistent Storage in Docker Platform
Persistent Storage in Docker PlatformAnusha Ragunathan
 
Gluster Contenarized Storage for Cloud Applications
Gluster Contenarized Storage for Cloud ApplicationsGluster Contenarized Storage for Cloud Applications
Gluster Contenarized Storage for Cloud ApplicationsHumble Chirammal
 
Gluster Containerized Storage for Cloud Applications
Gluster Containerized Storage for Cloud ApplicationsGluster Containerized Storage for Cloud Applications
Gluster Containerized Storage for Cloud ApplicationsGluster.org
 
Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Idan Atias
 
Persistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFSPersistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFSHumble Chirammal
 
Containarized Gluster Storage in Kubernetes
Containarized Gluster Storage in KubernetesContainarized Gluster Storage in Kubernetes
Containarized Gluster Storage in KubernetesNeependra Khare
 
Velero search &amp; practice 20210609
Velero search &amp; practice 20210609Velero search &amp; practice 20210609
Velero search &amp; practice 20210609KAI CHU CHUNG
 
Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Hesham Amin
 
Running Java Applications inside Kubernetes with Nested Container Architectur...
Running Java Applications inside Kubernetes with Nested Container Architectur...Running Java Applications inside Kubernetes with Nested Container Architectur...
Running Java Applications inside Kubernetes with Nested Container Architectur...Jelastic Multi-Cloud PaaS
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerDmytro Patkovskyi
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 
Cluster management with Kubernetes
Cluster management with KubernetesCluster management with Kubernetes
Cluster management with KubernetesSatnam Singh
 
DTW18 - code08 - Everything You Need To Know About Storage with Kubernetes
DTW18 - code08 - Everything You Need To Know About Storage with KubernetesDTW18 - code08 - Everything You Need To Know About Storage with Kubernetes
DTW18 - code08 - Everything You Need To Know About Storage with KubernetesKendrick Coleman
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Rook - cloud-native storage
Rook - cloud-native storageRook - cloud-native storage
Rook - cloud-native storageKarol Chrapek
 
Container Orchestration using Kubernetes
Container Orchestration using KubernetesContainer Orchestration using Kubernetes
Container Orchestration using KubernetesHesham Amin
 
Deep dive into OpenStack storage, Sean Cohen, Red Hat
Deep dive into OpenStack storage, Sean Cohen, Red HatDeep dive into OpenStack storage, Sean Cohen, Red Hat
Deep dive into OpenStack storage, Sean Cohen, Red HatSean Cohen
 
Deep Dive into Openstack Storage, Sean Cohen, Red Hat
Deep Dive into Openstack Storage, Sean Cohen, Red HatDeep Dive into Openstack Storage, Sean Cohen, Red Hat
Deep Dive into Openstack Storage, Sean Cohen, Red HatCloud Native Day Tel Aviv
 

Similar to Kubernetes #4 volume &amp; stateful set (20)

Persistent Storage with Containers with Kubernetes & OpenShift
Persistent Storage with Containers with Kubernetes & OpenShiftPersistent Storage with Containers with Kubernetes & OpenShift
Persistent Storage with Containers with Kubernetes & OpenShift
 
Persistent Storage in Docker Platform
Persistent Storage in Docker PlatformPersistent Storage in Docker Platform
Persistent Storage in Docker Platform
 
Gluster Contenarized Storage for Cloud Applications
Gluster Contenarized Storage for Cloud ApplicationsGluster Contenarized Storage for Cloud Applications
Gluster Contenarized Storage for Cloud Applications
 
Gluster Containerized Storage for Cloud Applications
Gluster Containerized Storage for Cloud ApplicationsGluster Containerized Storage for Cloud Applications
Gluster Containerized Storage for Cloud Applications
 
Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)
 
Persistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFSPersistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFS
 
Containarized Gluster Storage in Kubernetes
Containarized Gluster Storage in KubernetesContainarized Gluster Storage in Kubernetes
Containarized Gluster Storage in Kubernetes
 
OpenStack Cinder
OpenStack CinderOpenStack Cinder
OpenStack Cinder
 
Velero search &amp; practice 20210609
Velero search &amp; practice 20210609Velero search &amp; practice 20210609
Velero search &amp; practice 20210609
 
Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017Kubernetes talk at DDDSydney 2017
Kubernetes talk at DDDSydney 2017
 
Running Java Applications inside Kubernetes with Nested Container Architectur...
Running Java Applications inside Kubernetes with Nested Container Architectur...Running Java Applications inside Kubernetes with Nested Container Architectur...
Running Java Applications inside Kubernetes with Nested Container Architectur...
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and Docker
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
Cluster management with Kubernetes
Cluster management with KubernetesCluster management with Kubernetes
Cluster management with Kubernetes
 
DTW18 - code08 - Everything You Need To Know About Storage with Kubernetes
DTW18 - code08 - Everything You Need To Know About Storage with KubernetesDTW18 - code08 - Everything You Need To Know About Storage with Kubernetes
DTW18 - code08 - Everything You Need To Know About Storage with Kubernetes
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Rook - cloud-native storage
Rook - cloud-native storageRook - cloud-native storage
Rook - cloud-native storage
 
Container Orchestration using Kubernetes
Container Orchestration using KubernetesContainer Orchestration using Kubernetes
Container Orchestration using Kubernetes
 
Deep dive into OpenStack storage, Sean Cohen, Red Hat
Deep dive into OpenStack storage, Sean Cohen, Red HatDeep dive into OpenStack storage, Sean Cohen, Red Hat
Deep dive into OpenStack storage, Sean Cohen, Red Hat
 
Deep Dive into Openstack Storage, Sean Cohen, Red Hat
Deep Dive into Openstack Storage, Sean Cohen, Red HatDeep Dive into Openstack Storage, Sean Cohen, Red Hat
Deep Dive into Openstack Storage, Sean Cohen, Red Hat
 

More from Terry Cho

Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced schedulingTerry Cho
 
Kubernetes #3 security
Kubernetes #3   securityKubernetes #3   security
Kubernetes #3 securityTerry Cho
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring Terry Cho
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 introTerry Cho
 
머신러닝으로 얼굴 인식 모델 개발 삽질기
머신러닝으로 얼굴 인식 모델 개발 삽질기머신러닝으로 얼굴 인식 모델 개발 삽질기
머신러닝으로 얼굴 인식 모델 개발 삽질기Terry Cho
 
5. 솔루션 카달로그
5. 솔루션 카달로그5. 솔루션 카달로그
5. 솔루션 카달로그Terry Cho
 
4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴Terry Cho
 
3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐Terry Cho
 
서비스 지향 아키텍쳐 (SOA)
서비스 지향 아키텍쳐 (SOA)서비스 지향 아키텍쳐 (SOA)
서비스 지향 아키텍쳐 (SOA)Terry Cho
 
1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스Terry Cho
 
애자일 스크럼과 JIRA
애자일 스크럼과 JIRA 애자일 스크럼과 JIRA
애자일 스크럼과 JIRA Terry Cho
 
REST API 설계
REST API 설계REST API 설계
REST API 설계Terry Cho
 
모바일 개발 트랜드
모바일 개발 트랜드모바일 개발 트랜드
모바일 개발 트랜드Terry Cho
 
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해Terry Cho
 
Micro Service Architecture의 이해
Micro Service Architecture의 이해Micro Service Architecture의 이해
Micro Service Architecture의 이해Terry Cho
 
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개Terry Cho
 
R 프로그래밍-향상된 데이타 조작
R 프로그래밍-향상된 데이타 조작R 프로그래밍-향상된 데이타 조작
R 프로그래밍-향상된 데이타 조작Terry Cho
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법Terry Cho
 
R 기본-데이타형 소개
R 기본-데이타형 소개R 기본-데이타형 소개
R 기본-데이타형 소개Terry Cho
 
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화Terry Cho
 

More from Terry Cho (20)

Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced scheduling
 
Kubernetes #3 security
Kubernetes #3   securityKubernetes #3   security
Kubernetes #3 security
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 intro
 
머신러닝으로 얼굴 인식 모델 개발 삽질기
머신러닝으로 얼굴 인식 모델 개발 삽질기머신러닝으로 얼굴 인식 모델 개발 삽질기
머신러닝으로 얼굴 인식 모델 개발 삽질기
 
5. 솔루션 카달로그
5. 솔루션 카달로그5. 솔루션 카달로그
5. 솔루션 카달로그
 
4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴
 
3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐
 
서비스 지향 아키텍쳐 (SOA)
서비스 지향 아키텍쳐 (SOA)서비스 지향 아키텍쳐 (SOA)
서비스 지향 아키텍쳐 (SOA)
 
1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스
 
애자일 스크럼과 JIRA
애자일 스크럼과 JIRA 애자일 스크럼과 JIRA
애자일 스크럼과 JIRA
 
REST API 설계
REST API 설계REST API 설계
REST API 설계
 
모바일 개발 트랜드
모바일 개발 트랜드모바일 개발 트랜드
모바일 개발 트랜드
 
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
 
Micro Service Architecture의 이해
Micro Service Architecture의 이해Micro Service Architecture의 이해
Micro Service Architecture의 이해
 
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
 
R 프로그래밍-향상된 데이타 조작
R 프로그래밍-향상된 데이타 조작R 프로그래밍-향상된 데이타 조작
R 프로그래밍-향상된 데이타 조작
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법
 
R 기본-데이타형 소개
R 기본-데이타형 소개R 기본-데이타형 소개
R 기본-데이타형 소개
 
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Kubernetes #4 volume &amp; stateful set

  • 1. Kubernetes #4. Volume & StatefulSet 조대협 (http://bcho.tistory.com)
  • 2. Agenda ● Volume ● PersistentVolume and PersistentVolumeClaim ● StatefulSet
  • 4. Volume is ● Disk resource which is described as a part of Pod ● It can be shared across containers in Pod ● It must be mounted to container which wants to access the volume ● Life cycle is managed by Pod Volume is created when Pod is started and deleted when Pod is deleted. (Not along with container)
  • 5. Volume type Temp Local Network emptyDir hostPath GlusterFS gitRepo NFS iSCSI gcePersistentDisk AWS EBS azureDisk Fiber Channel Secret VshereVolume
  • 6. Volume type - empyDir ● A simple empty directory used for storing transient data ● It is good for ephemeral storage and good for file sharing across container emptyDir can use Memory as a disk
  • 7. Volume type - hostPath ● It posts to a specific file or directory on the node’s file system ● Pods running on same node and using the same path in their volume ● hostPath volume is not deleted when Pod is torn down (If new Pod is started, the files in the hostPath volume will be remained) Node Pod Pod /mydirectory/ Node Pod /mydirectory/ If you’re thinking of using a hostPath volume as the place to store a database’s data directory, think again. Because the volume’s contents are stored on a specific node’s filesystem, when the database pod gets rescheduled to another node, it will no longer see the data.
  • 8. Pod Volume type - gitRepo ● A gitRepo volume is basically an emptyDir volume ● It gets populated by cloning a Git repository and checking out a specific revision when the pod is starting up (but before its containers are created) ● Useful to provisioning static (HTML) data or script source from git Container gitRepo <<emptyDir>> Clone apiVersion: v1 kind: Pod metadata: name: gitrepo-volume-pod spec: containers: - image: nginx:alpine name: web-server volumeMounts: - name: html mountPath: /usr/share/nginx/html readOnly: true ports: - containerPort: 80 protocol: TCP volumes: - name: html gitRepo: repository: https://github.com/luksa/kubia-website-example.git revision: master directory: .
  • 10. PersistentVolume ● PersistentVolume Life cycle is managed by k8s cluster (not pod) Admin can create PersistentVolume (Static provisioning) and developer just use the volume thru PersistentVolumeClaim without understanding of infrastructure (It is more common to use dynamic volume provisioning instead of volume provisioning by admin) Pod Container Volume Bind PersistentVolu meClaim PersistentVolume <<Created by admin>> create admin Select Physical disk create
  • 11. PersistentVolume ● PersistentVolume ● Capacity : Storage size In future it will include IOPS,throughput etc ● VolumeMode (from 1.9) : Filesystem(default) or rawblock device ● Reclaim Policy ○ Retain – manual reclamation ○ Recycle – basic scrub (rm -rf /thevolume/*) ○ Delete – associated storage asset such as AWS EBS, GCE PD, Azure Disk, or OpenStack Cinder volume is deleted ● Mount Option Additional mount options for when a Persistent Volume is mounted on a node Currently, only NFS and HostPath support recycling. AWS EBS, GCE PD, Azure Disk, and Cinder volumes support deletion.
  • 12. PersistentVolume ● AccessModes ○ ReadWriteOnce (RWO)– the volume can be mounted as read-write by a single node ○ ReadOnlyMany (ROX) – the volume can be mounted read-only by many nodes ○ ReadWriteMany (RWX) – the volume can be mounted as read-write by many nodes A volume can only be mounted using one access mode at a time, even if it supports many. For example, a GCEPersistentDisk can be mounted as ReadWriteOnce by a single node or ReadOnlyMany by many nodes, but not at the same time. RWO를 여러 Pod에 붙일려고 하면 에러가 남
  • 13. PersistentVolume Phase ● Available - a free resource that yet is not bound to a claim ● Bound - the volume is bound to a claim ● Released - the claim has been deleted but the resource is not yet reclaimed by the cluster ● Failed - the volume has failed its automatic reclamation
  • 14. Lifecycle of volume and claim Provisioning ● Static ● Dynamic : Dynamically create volume with storage class. Binding ● Bind PV to PVC Using ● Bind PVC to Pod and starts to use Reclaiming
  • 15. PersistentVolumeClaim (PVC) Claiming a PersistentVolume is a completely separate process from creating a pod, because you want the same PersistentVolumeClaim to stay available even if the pod is rescheduled (remember, rescheduling means the previous pod is deleted and a new one is created apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mongodb-pvc spec: resources: requests: storage: 1Gi accessModes: - ReadWriteOnce storageClassName: "" List PersistentVolume List PersistentVolumeClaim 쿠버네티스 인액션 예제 Nobody else can claim the same volume until you release it.
  • 16. PersistentVolumeClaim (PVC) https://kubernetes.io/docs/concepts/s torage/persistent- volumes/#persistentvolumeclaims ● accessMode : same as volume ● VolumeMode : same as volume ● Resource : Claims, like pods, can request specific quantities of a resource. In this case, the request is for storage. The same resource model applies to both volumes and claims. ● Selector : Claims can specify a label selector to further filter the set of volumes. Only the volumes whose labels match the selector can be bound to the claim All of the requirements, from both matchLabels and matchExpressions are ANDed together – they must all be satisfied in order to match
  • 17. Using PVC in Pod 쿠버네티스 인액션 예제 Google Cloud Kubernetes example
  • 18. Recycling ● When a user is done with their volume, they can delete PVC object which allows reclamation of the resource ● Reclaim policy for PersistentVolume tell the cluster what to do with the volume after it has been released of its claim ● Reclaim policy ○ Retain (remain / cannot reuse) After PVC is deleted, PV still exists and volume is marked as “released”. It cannot be reused by other PVC. (it needs to delete manually) ○ Delete Delete volume as well as associated storage asset in external infrastructure ○ Recycle (remain / can reuse) Perform basic scrub (rm -f /thevolume/*) on volume and makes it available again for a new claim The Recycle reclaim policy is deprecated. Instead, the recommended approach is to use dynamic provisioning.
  • 19. Volume retaining test Change Reclaim policy from DELETE to Retain Recreat PVC & POD Delete Pod and PVC
  • 20. Dynamic Provisioning From k8s 1.6. Without manual provisioning of PersistentVolume. Kubernetes can dynamically create volume based on PersistentVolumeClaim (and storage class) Pod Container Volume Bind PersistentVolu meClaim PersistentVolume <<DynamicVoume>> k8s Dynamically created Instead of admin to create PV manually, admin can deploy Persistent volume provisioner and define one or more storage class object to let users choose type of PV. PersistentVolume <<DynamicVoume>> Dynamically created Request Volume with storage class
  • 21. Dynamic Provisioning apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/gce- pd parameters: type: pd-ssd zone: europe-west1-b apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mongodb-pvc spec: storageClassName: fast resources: requests: storage: 100Mi accessModes: - ReadWriteOnce
  • 23. Storage Class Get default storage class
  • 25. Replicating stateful pod ● With ReplicaSet All pod will refer same PVC and same PV ● Option : Create RS per Pod
  • 26. Statefulset ● To support stateful application (like database) ● It is supported from k8s 1.9(GA) ● Pod Naming : ${Stateful set name}-${ordinary index} It is not that the pods having a predictable name and hostname. It is better to use service for naming. ● When Pod (under statefulset) is restarted (by crash), Pod name will not be changed. Cf. in case of RS, the Pod name is changed to new one.
  • 27. StatefulSet specification example apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: selector: matchLabels: app: nginx # has to match .spec.template.metadata.labels serviceName: "nginx" replicas: 3 # by default is 1 template: metadata: labels: app: nginx # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: - name: nginx image: k8s.gcr.io/nginx-slim:0.8 ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] storageClassName: "my-storage-class" resources: requests: storage: 1Gi
  • 28. StatefulSet Pod to PV mapping ● Each pod will get its own PVC and PV ● The PVC will be created “Volume claim template” in StatefulSet specification POD-1 PVC-1 PV-1 POD-2 PVC-2 PV-2 POD-3 PVC-3 PV-3 Volume claim template Pod Template Create Create
  • 29. Scale in & out ● Scale in POD-1 PVC-1 PV-1 POD-2 PVC-2 PV-2 PVC-3 PV-3 POD-1 PVC-1 PV-1 POD-2 PVC-2 PV-2 POD-3 PVC-3 PV-3 POD-3 is removed by scale in , But PVC-3 and PV-3 are not deleted ● Scale out POD-3 is added by scale out. It is attached previous PVC-3 and PV-3 It enables POD connect to same PVC and PV and it POD to retain same stateful information in disk Because of this reason, PVC and PV are not automatically deleted. To delete PVC and PV, admin needs to manually delete the PVC and PV
  • 30. Pod management policies ● .spec.podManagementPolicy ○ OrderedReady (default) : start and terminate Pod sequential. ○ Parallel : start Pod and terminate in parallel

Editor's Notes

  1. https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/ DynamicVolume (2017.03 from K8s 1.6)
  2. https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/ DynamicVolume (2017.03 from K8s 1.6)
  3. Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 46m default-scheduler Successfully assigned nginx to gke-terrycho-gke10-default-pool-d32c133e-phhw Warning FailedAttachVolume 46m attachdetach-controller Multi-Attach error for volume "pvc-c7218b58-63b8-11e8-b940-42010a920151" Volume is already used by pod(s) redis Normal SuccessfulMountVolume 46m kubelet, gke-terrycho-gke10-default-pool-d32c133e-phhw MountVolume.SetUp succeeded for volume "default-token-45kpp" Warning FailedMount 1m (x20 over 44m) kubelet, gke-terrycho-gke10-default-pool-d32c133e-phhw Unable to mount volumes for pod "nginx_default(fa5b322b-63c5-11e8-b940-42010a920151)": timeout expired waiting for volumes to attach or mount for pod "default"/"nginx". list of unmounted volumes=[nginx-data]. list of unattached volumes=[nginx-data default-token-45kpp]
  4. https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/ DynamicVolume (2017.03 from K8s 1.6)
  5. https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/ DynamicVolume (2017.03 from K8s 1.6)