学习总结：按照教程，一步一步的操作在线 k8s 集群，了解了 k8s 一些基础概念，比如：Pod, Node, Service, Deployment 等。 另外，也学习了一些 kubectl 常见命令，这些命令在之后的实践中应该会经常用到。
创建一个 Kubernetes 集群
- Kubernetes 集群是什么？
- Minikube 是什么？
- 使用在线终端来启动一个 Kubernetes 集群。
- Kubernetes coordinates a highly available cluster of computers that are connected to work as a single unit.
- Kubernetes automates the distribution and scheduling of application containers across a cluster in a more efficient way.
A Kubernetes cluster consists of two types of resources:
- The Master coordinates the cluster
- Nodes are the workers that run applications
- The Master is responsible for managing the cluster.
- A node is a VM or a physical computer that serves as a worker machine
in a Kubernetes cluster.
- Each node has a Kubelet
- A Kubernetes cluster that handles production traffic should have a minimum of three nodes.
- The nodes communicate with the master using the Kubernetes API
- 使用 kubectl 部署第一个应用
- 学习 Kubernetes Pods
- 学习 Kubernetes Nodes
A Pod is a Kubernetes abstraction that represents a group of one or more application containers, and some shared resources for those containers.
Those resources include:
- Shared storage, as Volumes
- Networking, as a unique cluster IP address
- Information about how to run each container(image version/port)
The containers in a Pod share an IP Address and port space, are always co-located and co-scheduled, and run in a shared context on the same Node.
Pods are the atomic unit on the Kubernetes platform.
Pod -> One or more Containers
A Pod always runs on a Node.
A Node can have multiple pods, and the Kubernetes master automatically handles scheduling the pods across the Nodes in the cluster.
Every Kubernetes Node runs at least:
- Kubelet, a process responsible for communication
between the Kubernetes Master and the Node
- A container runtime (like Docker, rkt) responsible for pulling
the container image from a registry, unpacking the container, and running the application. Containers should only be scheduled together in a single Pod if they are tightly and coupled need to share resources such as disk.
Troubleshooting with kubectl
一些 kubectl 常用命令
- kubectl get - list resources
- kubectl describe - show detailed information about a resource
- kubectl logs - print the logs from a container in a pod
- kubectl exec - execute a command on a container in a pod
- 学习 Kubernetes Service
- 理解 labels 和 LabelSelector 对象是怎样关联到 Service 的
- 使用 Service 将应用暴露到 Kubernetes 集群外面
When a worker node dies, the Pods running on the Node are also lost. ReplicationController might then dynamically drive the cluster back to desired state via creation of new Pods to keep your application running.
A Service in Kubernetes is an abstraction which defines a logical set of Pods and a policy by which to access them.
Services enable a loose coupling between dependent Pods. A Service is defined using YAML (preferred) or JSON, like all Kubernetes objects.
Although each Pod has a unique IP address, those IPs are not exposed outside the cluster without a Service.
Services and Labels
A Service routes traffic across a set of Pods. Services are the abstraction that allow pods to die and replicate in Kubernetes without impacting your application.
Scaling is accomplished by changing the number of replicas in a Deployment