What is Kubernetes?
Kubernetes is a portable, extensible open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.
Popular container orchestration system
- Automatic binpacking (Managing container)
- Horizontal scaling
- Automated rollouts and rollbacks
- Service discovery and load balancing
- Secret and configuration management
Ref: Kubernetes & helm 활용
- Master Components
- Node Components
Master components provide the cluster’s control plane
Component on the master that exposes the Kubernetes API. It is the front-end for the Kubernetes control plane.
Consistent and highly-available key value store used as Kubernetes’ backing store for all cluster data.
Component on the master that watches newly created pods that have no node assigned, and selects a node for them to run on.
Component on the master that runs controllers.
- Node Controller: Responsible for noticing and responding when nodes go down.
- Replication Controller: Responsible for maintaining the correct number of pods for every replication controller object in the system.
- Endpoints Controller: Populates the Endpoints object (that is, joins Services & Pods).
- Service Account & Token Controllers: Create default accounts and API access tokens for new namespaces.
cloud-controller-manager runs controllers that interact with the underlying cloud providers. (etc. AWS, GCP, AZURE …)
kubernetes agent on each node
check pod state(running and healthy)
kubelet is not container. -> binary file
Maintaining network rules on the host and performing connection forwarding.
Docker, rkt, runc, any OCI runtime-spec implementation.
Containers started by Kubernetes automatically include this DNS server in their DNS searches.
Web UI (Dashboard)
kubrnetes architecture – 1
kubernetes architecture – 2
The Kubernetes API also serves as the foundation for the declarative configuration schema for the system.
The kubectl command-line tool can be used to create, update, delete, and get API objects.
OpenAPI and Swagger definitions
To make it easier to eliminate fields or restructure resource representations, Kubernetes supports multiple API versions, each at a different API path, such as /api/v1 or /apis/extensions/v1beta1.
- The core group, often referred to as the legacy group, is at the REST path
- The named groups are at REST path
/apis/$GROUP_NAME/$VERSION, and use
apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: dreg.be/tkwon/nginx-test:latest
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: replicas: 1 template: spec: containers: - name: nginx image: nginx:alpine ports: - containerPort: 80
The Kubernetes API – Kubernetes
Just Only need remember this one.
Kubernetes Object Management
kubectl command-line tool
kubectl run nginx --image nginx
kubectl create deployment nginx --image nginx
or more important object
kubectl apply -f nginx.yaml
- A Pod is the basic building block of Kubernetes
- the smallest and simplest unit
- Represents a unit of deployment
- Pods that run a single container.
- Pods that run multiple containers that need to work together.
Example for multiple containers in the Pod
The specific instances in which your containers are tightly coupled.
Pods provide two kinds of shared resources for their constituent containers: networking and storage.
Containers inside a Pod can communicate with one another using
Pods and Controllers
A Controller can create and manage multiple Pods
To provides Declarative updates for Pods and ReplicaSets
deployment, replica set and pod
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
The workload API object used to manage stateful applications
To provides guarantees about the ordering and uniqueness of these Pods.
- Stable, unique network identifiers.
- Stable, persistent storage.
- Ordered, graceful deployment and scaling.
- Ordered, automated rolling updates.
Deleting and/or scaling a StatefulSet down will not delete the volumes associated with the StatefulSet.
StatefulSet Pods have a unique identity
The identity sticks to the Pod, regardless of which node it’s (re)scheduled on.
$(statefulset name)-$(ordinal). The example above will create three Pods named
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod.
ex> Node exporter for prometheus
Services and Network
Pods and can make commnunication between Pods.
kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
- Match ELB on AWS
Service is kind of L4 network
Ingress is kind of L7 network.
Service map to AWS ELB,
Ingress map to AWS ALB
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - http: paths: - path: /testpath backend: serviceName: test servicePort: 80
- Persistent Volumes
- Storage Classes
Kubernetes Pod Network
I think network is so importance to understand kubernetes.
You should check below references to understand it.
Container Networking From Scratch
About Linux network namespace