Introduction to Kubernetes
Frank Heilmann
Platform Architect and Freelance Instructor
kubectl
: main command to interact with Kubernetes objectspod
, service
, etc.$$
Typical usage patterns:
kubectl create -f <Manifest.yml>
: create new objects, with
-f
for "filename"kubectl apply -f <Manifest.yml>
: create new objects &
change the state of objectskubectl get <object>
:
overview about objects deployed on Kuberneteskubectl describe <object>
: detailed information about an object$$
Detailed help available via command line option --help
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 5
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25.4
ports:
- containerPort: 80
Stateless apps:
When interrupted, a new replica of the stateless app is recreated and starts operating.
apiVersion
and kind
metadata
and spec
spec
defines number of replicas
, a selector
, and a template
selector
latertemplate
describes details for the creation the pods in the
DeploymentapiVersion: apps/v1
kind: Deployment
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>
kubectl apply -f <manifest.yml>
for creating pods and
applying changes. Introduction to Kubernetes