5 min read · tagged ccp1, cloud, kubernetes
Containers vs Virtual Machines:
Hardware -> Host OS -> Hypervisor -> VM1..n (Guest OS -> Libs -> App)
Hardware -> Host OS -> Container Engine -> Container1..n (Libs -> App)
Platform for automating deployment, scaling and management of containerized applications. Sits on top of machines (physical or virtual) and provides abstraction of a single machine.
Components in master node (control plane)
Components on worker nodes (k8 nodes, minions)
Cluster: Set of machines where pods are deployed, managed, scaled
Controller: Reconciliation loop that drives actual to desired cluster state
Label: Key-value pairs on any API object
Consistent object API with three basic fields
Goals
Affinity: Containers need to be placed on same node (tight cooperation)
Anti-affinity: Containers need to be placed on different nodes (redundancy)
Pod: One or more containers that are guaranteed to be co-located on the same machine
Tightly-coupled containers: multiple containers per pod Loosely-coupled containers: one container per pod
Pod definition is declaration of desired state.
Shared between containers in same pod with same lifecycle as pod (unless persistent volume)
Types:
emptyDir (erased at pod deletion)
volumes:
name: www-data
emtpyDir: {}
hostPath (persisted with host machine lifetime, cloud vendor volumes), e.g. gcePersistentDisk, awsElasticBlockStore, azureFileVolume
volumes:
name test-volume
awsElasticBlockStorage:
volumeID: <id>
fsType: ext4
secret (used to mount sensitive information, backed by tmpfs which is in RAM)
nfs (persisted network file system)
Persistent volumes can be mounted directly or through PersistentVolumeClaim (PVC)
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myClaim
Creation
kubectl create -f pod-nginx.yml
List
kubectl get pods
Delete by name
kubectl delete pod nginx
Replacement for Replication Controller with additional features to update software without disruption.
Deployments
View deployments
kubectl get deployments
Check rollout status
kubectl rollout status deployment/mginx-deployment
Update with set
kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
Update with edit
kubectl edit deployment/nginx-deployment
Rescheduling: on node failure or pod termination
Scaling: change replicas from user command or autoscaling
Rolling updates:
Creation
kubectl create -f replication.yml
List
kubectl get rs
Describe
kubectl describe rs/apache.zurmo
Delete
kubectl delete rs/apache.zurmo
Resize
kubectl scale --replicas=COUNT rs/NAME
Logical set of pods that work together
Services can be exposed in different ways
Pods always receive new IP addresses. Services provide reliable networking endpoints.
Labels are used to assign pods to services. Services define a label selector which is a set of conditions on the label keys.
apiVersion: v1
kind: Service
metadata:
name: zurmo-apache
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
name: apache.zurmo
type: LoadBalancer
In a cluster we want containers to move freely without port forwarding but still talk to each other without NAT.
Use overlay network (SDN) that provide a flat network. Use packet encapsulation.
For high-availability the master node can be replicated to avoid failure of the master node.
Three-way replication
Simon Anliker Someone has to write all this stuff.