This is the fourth day of my participation in the August More text Challenge. For details, see: August More Text Challenge

This column is for personal understanding, suitable for beginners. Can quickly help 0 basic students quickly start with landing a SET of K8S environment.

1. Why use K8S

Before reading this article, it is recommended that you know about Docker. In the current software environment, even small companies use a lot of middleware, and projects are broken down into many microservices. For example, my company uses Redis, RabbitMQ and ELK middleware. In terms of projects, the company split the business into six microservices and also used open source projects such as online preview. If the author uses Docker to publish, so the preliminary calculation requires more than 10 Docker containers.

So the question is, how do I manage so many Docker containers? So K8S comes into being.

conclusion

The K8S organizes and manages containers and provides many functions, such as similar deployment, capacity expansion, monitoring, load balancing, and logging.

2. Basic concepts

  • Node: Each K8S server is called a node.
  • Deployment: Used to control and manage POD.
  • Pod: the smallest component of K8s and can be understood as a container, such as a Docker container.
  • Master: a k8s host that manages other nodes.
  • Cluster: All nodes except the master are called clusters, and the master can control all other clusters.

3. Important components of K8S

  • Kubelet: Node and Pod control.
  • Kube-proxy: K8S network proxy component that runs on each Node and is used for service discovery and proxy-related.
  • Kubectl: Admin tool for running Kubernetes cluster commands.

The above content can be understood, the following installation will be mentioned.

4. K8s Common commands

Master the following commands, you can initially operate K8S.

Kubectl get pods from all namespaces; kubectl delete namespaces from kubernetes-dashboard Clusterrolebinding Obtains the clusterRoleBinding user (the binding between a role and a user). Kubectl delete ClusterroleBinding dashboark-admin Deletes the binding Kubectl delete ClusterRole Deletes a role. Kubectl get Nodes -o yaml Obtains nodes details. Sudo kubectl logs Kubernetes-dashboard -6dccb458d5-x7xft --namespace=kubernetes-dashboard systemctl status kubelet Check the kubelet systemctl status Start kubelet Starts kubelet systemctl daemon-reload && systemctl restart kubelet restarts kubelet systemctl daemon-reload && Systemctl stop kubelet stop kubelet journalctl - f - u kubelet. Service/journalctl - xefu kubelet view kubelet log kubectl drain. Tapping Nodename --force --ignore-daemonsets --delete-local-data kubectl delete node nodename # Create pods or services kubectl delete -f xxx.yaml # Delete Pods or services kubectl delete Pods --all --grace-period=0 --force # Delete k8s kubeadm reset -f modprobe -r ipip lsmod rm -rf ~/.kube/ rm -rf /etc/kubernetes/ rm -rf /etc/systemd/system/kubelet.service.d rm -rf /etc/systemd/system/kubelet.service rm -rf /usr/bin/kube* rm -rf /etc/cni rm -rf /opt/cni rm -rf /var/lib/etcd rm -rf /var/etcdCopy the code