In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to analyze the core functions of K8s, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Deploy the application
Execute the command:
Kubectl run kubernetes-bootcamp\-image=docker.io/jocatalin/kubernetes-bootcamp:v1\-port=8080
Here we deploy an application through kubectl run, named kubernetes-bootcamp.
The Docker image is specified by-- image.
-- port sets the port on which external services are applied.
Here deployment is a term for Kubernetes and can be understood as an application.
Kubernetes also has an important term Pod.
A Pod is a collection of containers, which usually put a set of closely related containers into one Pod. All containers in the same Pod share the IP address and Port space, that is, they are in the same network namespace.
Pod is the smallest unit of Kubernetes scheduling, and containers in the same Pod are always scheduled together.
Run kubectl get pods to view the current Pod.
Kubernetes-bootcamp-390780338-q9p1t is the Pod of the application.
Access application
By default, all Pod can only be accessed within the cluster. For the above example, to access the application, you can only directly access port 8080 of the container. In order to be able to access the application from the outside, we need to map port 8080 of the container to the port of the node.
Execute the following command:
Kubectl expose deployment/kubernetes-bootcamp\-type= "NodePort"\-port 8080
Execute the command kubectl get services to see which port the application is mapped to.
There are two service, and service can be understood as port mapping for the time being, which we will discuss in more detail later.
Kubernetes is the default service, so don't worry about it for the time being. Kubernetes-bootcamp is the service,8080 port that we applied has been mapped to port 32320 of host01. The port number is randomly assigned, and you can execute the following command to access the application:
Curl host01:32320
Scale application
By default, the application runs only one copy, and you can check the number of copies through kubectl get deployments.
Execute the following command to increase the number of copies to 3:
Kubectl scale deployments/kubernetes-bootcamp-replicas=3
Through kubectl get pods, you can also see that the current Pod has also increased to 3.
Through curl access to the application, you can see that each request is sent to a different Pod and three copies are polled for processing, thus achieving load balancing.
It is also convenient to scale down. Execute the command:
Kubectl scale deployments/kubernetes-bootcamp-replicas=2
One of the copies was deleted.
Scrolling update
The image version used by the current application is v1. Execute the following command to upgrade it to v2:
Kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2
The process of rolling updates can be observed through kubectl get pods: the Pod of v1 is deleted one by one, and a new v2 Pod is launched. Access the new version of the application after the update is complete.
If it is also easy to fall back to the v1 version, execute the kubectl rollout undo command:
Kubectl rollout undo deployments/kubernetes-bootcamp
Verify that the version has been rolled back to v1.
So far, we have quickly experienced the functions and usage of Kubernetes through the interactive tutorials on the official website.
The above content is how to analyze the core functions of K8s. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.