Introduction to Kubernetes
Frank Heilmann
Platform Architect and Freelance Instructor
Stateful apps:
When interrupted or stopped, a new replica (Pod) can read the saved state and continue operating from this state
apiVersion
, kind
, metadata
, spec
, template
replicas
defines the number of Pods in the StatefulSet
selector
laterapiVersion: apps/v1
kind: StatefulSet
metadata:
name: <deployment name>
labels:
app: <a label for the application>
spec:
replicas: <number of initial replicas>
selector:
matchLabels:
app: <matches the label above>
template:
metadata:
labels:
app: <label to be given to each pod>
spec:
containers:
- name: <container name>
image: <the image to be used>
ports:
- containerPort: <ports for networking>
StatefulSet
is deployed similar toDeployments
:
kubectl apply -f <manifest.yml>
StatefulSet
is created different than a Deployment
:pod-0
, pod-1
, pod-2
. etc.StatefulSet
with different identity
can perform different roles in an applicationreplicas
in the Manifest and re-apply,kubectl scale statefulsets ...
pod-0
, pod-1
, pod-2
first pod-3
,
then pod-4
will be addedpod-4
, then pod-3
kubectl
for basic monitoring taskskubectl get pods
returns all pods in a StatefulSet
with their current statuskubectl get services
returns all services that
a StatefulSet may useIntroduction to Kubernetes