当前位置:网站首页>[cloud native learning notes] kubernetes practice command
[cloud native learning notes] kubernetes practice command
2022-06-24 21:14:00 【The night owl of the second dimension】
List of articles
Preface
I introduced some information about k8s Basic theoretical knowledge of cluster , This time, we will deepen our understanding of theory in combination with practice .
One 、Kubernetes install
Given the limitations of the learning environment , This installation Minikube.minikube It's local Kubernetes, Focus on making Kubernetes Easy to learn and develop .k8s Commonly used in linux In the system , Because it is only used for learning and familiarity k8s command , This time, it will be based on the system used , install windows Version of Minikube. The official tutorial
- download .exe Installation package Installation .
- Add the installation directory to the system environment variable Path. The default installation directory is
C:\Program Files\Kubernetes\Minikube
- Need to be advanced Install well docker, The same is windows Version and launch .
- stay cmd Run command in
minikube start
To initialize and start minikube. - Can be used later
minikube stop
To stop the cluster
Minikube Will start a virtual machine ,Kubernetes The cluster runs on a virtual machine .minikube with dashboard service , For visual monitoring and viewing minikube situation . In the new cmd Running on the terminal minikube dashboard
To activate the function .
Two 、 Cluster interaction
adopt kubectl Command can be root Kubernetes Interaction .kubectl The common format of the command is :kubectl action resources
. The function is to perform the specified action on the specified resource . Execute the run command kubectl
You can get all the information about resources and actions . Official documents There are also detailed instructions .
1、 Check the cluster status
see kubectl Is the installation successful , It is generally reflected by the view version :
kubectl version
You'll see... At the same time client and server Two version numbers . among ,client Corresponding kubectl Version of ,server Corresponding Master Installed on Kubernetes Version of .
View the details of the cluster :kubectl cluster-info
View cluster node:kubectl get nodes
2、 About deploying applications
adopt kubectl run
The command can run the specified image in the cluster . For deploying images , In terms of launching applications , What is actually commonly used is not kubectl run
, It is kubectl creat
perhaps kubectl apply
.apply
Use relatively more .
kubectl creat: Create a new resource with configuration , Since the resource name should be unique in the namespace , When repeated , Will report a mistake .
kubectl apply: Apply configuration to resources . If the resource does not exist , Create a new resource . When repeated , If the configuration is modified, the resource will be updated , Otherwise, the resources will not change .
Use here kubectl run
Run the application deployment :
kubectl run kubernetes-bootcamp --image=jocatalin/kubernetes-bootcamp:v1 --port=8080
Check pod state running Success after :
kubectl get pod -A | grep kubernetes-bootcamp
default kubernetes-bootcamp 1/1 Running 0 28m
Applications are deployed in clusters , If the application services are not exposed outside the cluster , So use url You can't access the service directly .
Direct access will prompt to reject the link :
curl http://localhost:8001/version
curl: (7) Failed to connect to localhost port 8001 after 2203 ms: Connection refused
kubectl proxy
Command can create a proxy , Forward communications to a cluster wide private network . The agent can pass control-C End , And no output will be displayed at run time , You can run the agent in other terminal windows .
Revisit :
curl http://localhost:8001/version
{
"major": "1",
"minor": "23",
"gitVersion": "v1.23.1",
"gitCommit": "86ec240af8cbd1b60bcc4c03c20da9b98005b92e",
"gitTreeState": "clean",
"buildDate": "2021-12-16T11:34:54Z",
"goVersion": "go1.17.5",
"compiler": "gc",
"platform": "linux/amd64"
}
Here, you can access our deployed applications through the forwarding provided by the cluster :
$ curl http://localhost:8001/api/v1/namespaces/default/pods/kubernetes-bootcamp/proxy/
Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp | v=1
3、 ... and 、 About the characteristics of the cluster
- Automatic load balancing : Automatically assign requests to each pod To respond to .
- Service scaling : Update applied pod Copy number
- Service version upgrade : The image used by the update application is used for upgrading .
have access tokubectl rollout status deployments/xxx
Check out the upgrade process , Is to replace each... One by one pod.
have access tokubectl rollout undo deployments/xxx
Quickly go back to the previous version . - Common commands for troubleshooting cluster resources are :
kubectl get
: List resourceskubectl describe
: Show details about the resourcekubectl logs
: Print logkubectl exec
: Go to the container and execute the command
边栏推荐
- Bean lifecycle flowchart
- yeb_ Back first day
- List set Introduction & common methods
- What will you do if you have been ignored by your leaders at work?
- Memo mode - game archiving
- JMeter response assertion
- Variable setting in postman
- Static routing job
- PHP script calls command to get real-time output
- Alibaba cloud schedules tasks and automatically releases them
猜你喜欢
Mapstacks: data normalization and layered color layer loading
Common data model (updating)
Agency mode -- Jiangnan leather shoes factory
[普通物理] 光栅衍射
After 5 months' test, it took 15K to come for an interview. When I asked, it was not worth even 5K. It was really
A/B测试助力游戏业务增长
Web automation: summary of special scenario processing methods
网络安全审查办公室对知网启动网络安全审查
Summary of message protocol problems
Talking about the range of data that MySQL update will lock
随机推荐
Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
Network flow 24 questions (round table questions)
(to be optimized and modified) vivado DDR4 SDRAM (MIG) (2.2) IP core learning record
go_ keyword
DHCP operation
Subnet partition operation
VIM usage
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
Background of master data construction
JMeter basic learning records
Simple analysis of WordPress architecture
Minimum cost and maximum flow (template question)
Jar package operation
Web automation: web control interaction / multi window processing / Web page frame
Adding subscribers to a list using mailchimp's API V3
NPM download speed is slow
Tool composition in JMeter
[普通物理] 光栅衍射
Static routing job supplement
Network security review office starts network security review on HowNet