当前位置:网站首页>[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
边栏推荐
- Network security review office starts network security review on HowNet
- Power apps Guide
- Go coding specification
- 主数据建设的背景
- 红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
- Basic concepts and definitions of Graphs
- Appium desktop introduction
- Alibaba cloud schedules tasks and automatically releases them
- A/B测试助力游戏业务增长
- Batch capitalization of MySQL table names
猜你喜欢

Appium desktop introduction

Am, FM, PM modulation technology

Enjoy yuan mode -- a large number of flying dragons

Does the developer want to change to software testing?

Prototype mode -- clone monster Army

Pytest test framework II

A/B测试助力游戏业务增长

Learn to use a new technology quickly

Codeforces Round #720 (Div. 2)

The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
随机推荐
Typescript syntax
Basic database syntax learning
Php-pdo parameter binding problem
Network flow 24 questions (round table questions)
Appium introduction and environment installation
Nifi fast authentication configuration
海泰前沿技术|隐私计算技术在医疗数据保护中的应用
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
Golang reflection operation collation
Markdown use
Bean lifecycle flowchart
Self signed certificate generation
What are the problems with traditional IO? Why is zero copy introduced?
I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
Leetcode(455)——分发饼干
刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
Dijkstra seeking secondary short circuit (easy to understand)
A/B测试助力游戏业务增长
Format method and parse method of dateformat class
[performance tuning basics] performance tuning strategy