K8s定义:
- open source container orchestration tool.
- help to manage containerized applications in different environments
K8s architecture
- a master node
- a couple of worker nodes, where each node has a k8s process running on it.
- each node has containers of different applications deployed on it.
- worker nodes are where the actual work is happening.
- On master nodes, important k8s processing are running.
- API server,which is also a container. This is the entrypoint to K8s cluster.
- Controller Manager: keeps trach of what happening in the cluster.
- scheduler, ensures pods placement.
- k8s allows the cluster to communicate each other and excute some tasks on those nodes.
- etcd key-velue stroage: holds at any time the current state of the k8s cluster. It holds the current status of any k8s component. K8s gets the status data from here.
- visual network:
- worker nodes VS master nodes:
- work node:
- higher workload
- much bigger and more resources
- Control node plane nodes:
- handful of master processes
- much more important
- work node:
Main k8s components
Pod(node)
- smallest unit in K8s
- Abstraction over container
- basically what pod does is it creates this running environment or a layer on top of the container.
- k8s wants to abstract the container runtime or container technoligies. You only interact with the K8s layer.
- Uaually 1 application per Pod
- Each pod gets its own IP address. It's internal ip address.
- New Ip address on re-creation.Pod are ephemeral!
Service and Ingress
service:
- Permanent Ip address
- Life cycle of service and pod not connected. Even the pod dies, the service and its ip address will stay.
Ingress:
- request goes first into ingress and it does forwarding then to the service.
- route traffic into cluster
ConfigMap
- external configuration of your application
- it's for non-confidential data only!
Secret
- used to store secret data
- for data persistence
volume
- it attaches a physical storage on a hard drive to your pod.
- storage on local machine
- or remote, outside of the k8s cluster.
- simply think of it as an external hard drive plugged into the k8s cluster.
- k8s doesn't manage data persistance!
Deployment
- "blueprint" of "my-app" Pods
- you create Deployments where you can specify how many replicas.
StatefulSet
- for stateful apps (such as db applications )
DaemonSet
K8s configuration
all the configuration in k8s cluster actually goes through a master node with the process called API SERVER.
these all talk to the api server and they send their configuration requests to the API server, which is the main or the only entry point to the server. These requests have to be either in yaml format or jason format.
- k8s client could be a UI(a k8s dashboard)
- API could be script or curel command or a command line tool.
3 parts of a k8s configuration
- metadata: such as the name of components
- specification: Attributes of "spec" are specific to the kind.
- status: Automatically generated and added by Kubernetes.
Minikube and Kubetcl
minikube: a mini cube is basically one node cluster where the master processes and node processes both run on ONE machine.
kubeetcl: command line tool for k8s cluster.
2 layers of Docker
- Minikube runs as Docker container.
- Docker inside Minikube to run our application containers.
简单操作
minikube is basically just for the startup and for deleting cluster.
everything else configuring we're going to be doing through kubectl.
kubectl get node