当前位置:网站首页>[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 startTo initialize and start minikube. - Can be used later
minikube stopTo 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/xxxCheck out the upgrade process , Is to replace each... One by one pod.
have access tokubectl rollout undo deployments/xxxQuickly 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
边栏推荐
- opds sql组件能不能将流程参数通过上下文传给下一个组件
- Sleep revolution - find the right length of rest
- Static routing job
- 在Dialog中使用透明的【X】叉叉按钮图片
- Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
- Geek University cloud native training camp
- More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
- Address mapping of virtual memory paging mechanism
- Bridging mode -- law firm
- 海泰前沿技术|隐私计算技术在医疗数据保护中的应用
猜你喜欢

DHCP operation

Read all text from stdin to a string

Does the developer want to change to software testing?

After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked

Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI

Microsoft Certification (dynamic 365) test

Pytest test framework II

Power apps Guide

Agency mode -- Jiangnan leather shoes factory

Capture the whole process of accessing web pages through Wireshark
随机推荐
Create a multithreaded thread class
Realization of truth table assignment by discrete mathematical programming
JMeter response assertion
Bean lifecycle flowchart
Packaging_ Conversion between basic type and string type
Leetcode (146) - LRU cache
It was Tencent who jumped out of the job with 26k. It really wiped my ass with sandpaper. It gave me a hand
海泰前沿技术|隐私计算技术在医疗数据保护中的应用
Can the OPDS SQL component pass process parameters to the next component through context
Several common command operations in win system
主数据建设的背景
Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI
Network layer
Markdown use
What will you do if you have been ignored by your leaders at work?
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
Variable setting in postman
Web automation: web control interaction / multi window processing / Web page frame
Static routing job supplement
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time