当前位置:网站首页>Kubernetes cluster command line tool kubectl
Kubernetes cluster command line tool kubectl
2022-06-28 07:37:00 【Courageous steak】
List of articles
1 kubectl summary
kubectl yes Kubernetes Command line tools for clustering , adopt kubectl Be able to manage the cluster itself , And can install and deploy container applications on the cluster .
2 kubernetes command
2.1 kubectl The syntax of the command
kubectl [common] [TYPE] [NAME] [flags]
(1)comand: Specifies the action to be performed on the resource , for example create、get、describe and delete
(2)TYPE: Specify the type of resource , Resource types are case sensitive , Developers can use the singular number 、 Plural and abbreviated forms , for example :
kubectl get pod pod1
kubectl get pods pod1
kubectl get po pod1
(3)NAME: Specify the name of the resource , Names are also case sensitive . If you omit the name , All resources will be displayed .
kubectl get pods
(4)flags: Specify optional parameters . for example : You can use -s perhaps -server Parameter assignment Kubernetes API Server The address and port of .
kubectl get node
kubectl get nodes
kubectl get nodes master

Help order kubectl --help
See a specific operation
kubectl get --help
2.2 Common commands
nginx For example
establish nginx pod
kubectl create deployment nginx --image=nginx
External exposure port
kubectl expose deployment nginx --port=80 --type=NodePort
kubectl get pod, svc

View current health status
kubectl get cs
3 Use command
3.1 check
check pods
# View all pods Specify the namespace
kubectl get pods --all-namespaces
check service
# Check all service
kubectl get service
3.2 Deployment operation
see
kubectl get deployment
Delete
kubectl get deployment
kubectl delete deployment flask-demo
perhaps
kubectl delete-f app.yaml
4 Project deployment
vim app.yaml
# 1 Deployment information
apiVersion: apps/v1
kind: Deployment # use deployment Deploy
metadata:
name: flask-demo
namespace: default # Default namespace
labels:
app: flask-demo
spec:
replicas: 2 # Copy settings 1 individual
selector:
matchLabels:
app: flask-demo
template:
metadata:
labels:
app: flask-demo
spec:
containers: # Container related configuration
- name: flask-demo-app
image: vitcloud/flask_demo:latest # Mirror address
ports: # Container exposure port
- containerPort: 80
resources: # Resources to be used by the container
requests:
cpu: "1000m"
memory: "1Gi"
limits:
cpu: "2000m"
memory: "2Gi"
# service Information --- Associated with deployment
apiVersion: v1
kind: Service
metadata:
name: flask-demo-service
spec:
selector: # ==== Corresponding
app: flask-demo # Point to pod
type: NodePort # Open service through port
ports:
- name: web
port: 80
protocol: TCP
# targetPort: 80 # Container port
# nodePort: 30001 # External exposure port
Specified file
kubectl apply -f app.yaml
# see
kubectl get pods --all-namespaces -o wide
# View progress
watch kubectl get pods --all-namespaces -o wide
# View resource details
kubectl describe pods flask-demo-77f769cb94-7pw4q
边栏推荐
猜你喜欢

Recommended system series (Lecture 5): Optimization Practice of sorting model

Construction and exploration of vivo database and storage platform

Porting ucosiii to stm32f429

Application and Optimization Practice of redis in vivo push platform

"Three routines" of digital collection market
![[thanos source code analysis series]thanos query component source code analysis](/img/e4/2a87ef0d5cee0cc1c1e1b91b6fd4af.png)
[thanos source code analysis series]thanos query component source code analysis

在idea中,get和set方法爆红可能是没有安装Lombok插件

异或的应用。(提取出数字中最右侧的1,面试中经常用的到)

Practice and exploration of vivo live broadcast application technology

看似简单的光耦电路,实际使用中应该注意些什么?
随机推荐
Resizing node of rediscluster cluster cluster mode
R 语言 Hitters 数据分析
Design and implementation of spark offline development framework
R 语言 ggmap
Alibaba cloud server creates snapshots and rolls back disks
Mysql57 zip file installation
Force buckle 515 Find the maximum value in each tree row
Self discipline challenge 30 days
Sentinel mechanism of redis cluster
云原生(待更新)
Makefile
R 语言 ggmap 可视化集群
XML序列化向后兼容
剑指Offer||:链表(简单)
Porting ucosiii to stm32f429
Redis implements distributed locks
es6箭头函数中return的用法
Construction and exploration of vivo database and storage platform
Is it safe to open an account on Dongfang fortune
Sword finger offer II 091 Paint the house