Optional - Storage Classes, StatefulSets Flashcards
What is Static Provisioning?
- when creating PVs/PVCs etc you define what volume (azure, aws) should be used
- before it can be used, it first must be manually provisioned, using the same name
What are Storage Classes used for?
- used for dynamic provisioning underlying volume storage
- allows to define provisioners (like google storage) to dynamically provision storage on google cloud and attach that to pods when a claim is made
How do you define a Storage Class?
sc-definition.yaml
~~~
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: google-storage
provisioner: kubernetes.io/gce-pd
~~~
How are Storage Class yamls used?
- instead of PV.yaml
- in PVC.yaml:
~~~
spec:
accessModes:
- ReadWriteOnce
storageClassName: google-storage
resources:
requests:
storage: 500 Mi
~~~
How does dynamic provisioning work?
- when a new claim is created
- it uses the defined provisioner to provision a new disk with the required size
- then creates a persistent volume and then binds the pvc to that volume
Why do we need Stateful Sets? Why are deployments not enough?
- are similiar to deployments sets
- create pods based on a template
- scale up/down
- perform updates and rollbacks
BUT:
- pods are created in a sequential order
- first pod must be running, before the next one is deployed
- assign unique ordinal index to each pod
- maintain a sticky identity for pods
- name schema: set-name + pod nr (1-x)
- pods perform a clone from the previous nr, (2 from 1, etc)
How do you define a Stateful Set?
Like a Deployment but kind=StatefulSet und spec.serviceName (for the name of a headless service)
Take a set of database pods, why can you not use a regular service to read and write?
- because the default Loadbalancer would split the writes and reads among all db-instances
- but we want writes to happen only on the db-master instance
What is a headless Service? What does it do?
- created like a regular service
- but has no IP of its own
- does not perform any load balancing
- Creates DNS entries for each pod using the pod-name and a sub-domain
podname.headless-servicename.namespace.svc.cluster-domain.example
How do we create a headless service?
apiVersion: v1 kind: Service metadata: name: mysql-h spec: ports: - port: 3306 selector: app: mysql clusterIP: None
clusterIP: None is new
How do you point from a headless service to a pod?
- Pod definition yaml spec.subdomain needs to be the same as the name of the service
How do you create a DNS record for a service to point to specific pods?
in Pod-yaml, beside spec.subdomain, add:
- hostname:
What are Security Primitives?