Kubernetes is a distributed container orchestration platform
for automating deployment and management of applications at scale.
Node: a physical or virtual machine that contributes resources
Cluster: a group of master control plane and worker data plane nodes
image: https://faun.pub/kubernetes-chronicles-k8s-01-introduction-to-kubernetes-architecture-18cad51d270f
kube-apiserver: allows user interaction with the cluster (CLI/UI)
etcd: stores key-value pairs for cluster configuration (state, parameters, secrets)
kube-scheduler: decides which node a pod will run on
kube-controller-manager: shifts the actual state of the cluster to the desired state (acts as cluster thermostat)
For high availability,
the control plane runs on multiple nodes.
kubelet: agent ensures that containers are running, reports to the kube-apiserver
kube-proxy: facilitates networking between pods and handles external traffic
container runtime: (ie. Docker) pulls and runs container images from a registry
Pod: the smallest computational unit, plugs&plays container(s), ephemeral in nature
*
Deployment: manages the lifecycle of identical pods by scaling, updating, self-healing
*
ConfigMap/Secret: holds data as key-value pairs, passwords and apikeys kept secret
*
Service: provides a stable IP address and domain name for reaching a deployment
StatefulSet: same as a deployment but for applications with persistent storage
*
Persistent Volume (PV): represents a piece of storage that can be attached to pods
*
Persistent Volume Claim (PVC): requests PV resources with specific characteristics
*
Namespace: groups and isolates kubernetes objects in seperate cluster spaces
Label: nametags kubernetes objects; useful to select, identify, inform
brew install minikube
minikube start
minikube dashboard
docker ps # 🤯
minikube config set memory 4096
kubectl config
watch kubectl get all
an important file: ~/.kube/config
kubectl apply -f hello-k8s-message.yaml # or through dashboard
kubectl apply -f kubesnake.yaml # or through dashboard
minikube ip # or minikube service --url
minikube stop/delete # 💥
example1: hello-k8s-message.yaml
| example2: kubesnake.yaml
.
├── container.env
├── docker-compose.yml
├── private.key
└── public.cert
services:
dev-idp:
# [..]
env_file:
- ./container.env
secrets:
- private_key
- public_cert
secrets:
private_key:
file: ./private.key
public_cert:
file: ./public.cert
apiVersion: v1
kind: Secret
metadata:
name: django-secrets
type: Opaque
data:
DJANGO_SECRET_KEY: dG9wc3lfa3JldHMK
apiVersion: v1
kind: ConfigMap
metadata:
name: django-config-map
data:
DJANGO_HOST: "idp.example.org" # Change this to the domain you get from the ingress
DJANGO_DB_TYPE: "sqlite"
DJANGO_SQLLITE_FILE: "/data/db.sqlite3"
# [..]
# deployment.yaml
containers:
- name: dev-idp
envFrom:
- configMapRef:
name: django-config-map
- secretRef:
name: django-secrets
apiVersion: v1
kind: Secret
metadata:
name: django-certs
type: Opaque
data:
private.key: [base64 encoded private key]
public.cert: [base64 encoded public cert]
# deployment.yaml
# [..]
volumes:
- name: django-certs
secret:
secretName: django-certs
# [..]
containers:
- name: dev-idp
volumeMounts:
- name: django-certs
mountPath: /certs