当前位置:网站首页>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
边栏推荐
猜你喜欢
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
kubelet驱逐机制的源码分析
8 张图 | 剖析 Eureka 的首次同步注册表
Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
Analyze 5 indicators of NFT project
异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
Recommended system series (Lecture 5): Optimization Practice of sorting model
goland IDE和delve调试位于kubernetes集群中的go程序
在idea中,get和set方法爆红可能是没有安装Lombok插件
Block transmission by golang gin framework
随机推荐
Cloud native (to be updated)
剑指Offer||:链表(简单)
异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
Real time database - Notes
一个小工具可以更快的写爬虫
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
mysql57 zip文件安装
Spark 离线开发框架设计与实现
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
Rediscluster cluster mode capacity expansion node
golang gin框架进行分块传输
Sword finger offer|: linked list (simple)
NDK 交叉编译
Section 5: zynq interrupt
分析 NFT 项目的 5 个指标
R 语言 Hitters 数据分析
Solving the longest palindrome substring by dynamic programming
vite2.9 中指定路径别名
Section 9: dual core startup of zynq
pip 更新到最新的版本