In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
Original link address: "Advanced article" kubernetes basic cluster command of docker (35)
Now let's try how to operate and control it. Let's start with the simplest command and try the official introduction to kubernetes: the content of playground. Learn how to create a pod,deployments and view their information to gain a deeper understanding of their relationship. Source code: https://github.com/limingios/msA-docker K8s branch and https://github.com/limingios/kubernetes-starter basic cluster construction view sections 32 to 34
Kubernetes contact Command kubectl version
View version
Kubectl get nodes
View nodes
Kubectl get pods
View pods
Pull the official image
The memory is a little low and slow.
Kubectl run kubernetes-bootcamp-- image=jocatalin/kubernetes-bootcamp:v1-- port=8080! [] (https://upload-images.jianshu.io/upload_images/11223715-e83d0671839f03b9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)- to view the details of deploy ```bashkubectl describe deploy kubernetes-bootcamp
View the details of pods
Kubectl describe pods kubernetes-bootcamp-6b7849c495-xmmvh
How to access port 8080 just now, because it is on that machine, and it can be accessed by apiserver.
Start 2 windows and one window to start the agent command
Kubectl proxy
Then manipulate another window
Curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/kubernetes-bootcamp-6b7849c495-xmmvh/
Expansion and reduction of capacity
K8s will use the machine evenly, and there will not be a situation where a machine uses too much and a machine uses very little.
# if you need to change from 2 to 1, you can also use this command kubectl scale deploy kubernetes-bootcamp-- replicas=2# can see that an instance is running on 102and an instance kubectl get pods-o wide is running on 103rd.
Promote Mirror
Current state
Kubectl describe deploy kubernetes-bootcamp
Promote Mirror
# it turned out that v1 was upgraded to v2kubectl set image deploy kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2kubectl describe deploy kubernetes-bootcamp
Status of deploy
Kubectl rollout status deploy kubernetes-bootcamp
Roll back the mirror
Kubectl rollout undo deploy kubernetes-bootcamp# has changed back to v1, kubectl describe deploy kubernetes-bootcamp.
Delete deploy
Kubectl delete deploy kubernetes-bootcamp
Configuration file
The above uses a lot of commands, the old iron digests and absorbs, of course, it is really inconvenient to use commands to manage the cluster all the time, and it is difficult to be competent when there are a large number of applications. K8s also provides a way to manage configuration files. It's kind of similar to swarm's. There are some differences in design and function.
Yaml file to create podmkdir servicescd servicesvi nginx-pod.yaml
Nginx-pod.yaml file
ApiVersion: v1kind: Podmetadata:name: nginxspec:containers:-name: nginximage: nginx:1.7.9ports:-containerPort: 80
Command to generate pod
If you create a pod specified in the kubectl create-f nginx-pod.yaml# file, it is impossible to create a deploykubectl get deploykubectl get pods-o wide.
Start the agent to try to access nginx
The old routine, one window starts, one window curl
# ip101 launch Agent kubectl proxy#ip101 another window to access curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/nginx/
Yaml file to create deploymentvi nginx-Deployment.yaml
Nginx-Deployment.yaml file
ApiVersion: apps/v1beta1kind: Deploymentmetadata:name: nginx-deploymentspec:replicas: 2template:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.7.9ports:- containerPort: 80
Command to generate deployment
Kubectl create-f nginx-Deployment.yamlkubectl get deploykubectl get pods-o widekubectl get pods-l app=nginxkubectl get pods-l app=nginx-o wide
PS: that's all for the usual commands. Let's talk about service and dns next time.
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
Open the bookmark in a new tab: browser.tabs.loadBookmarksInTabs;true
© 2024 shulou.com SLNews company. All rights reserved.