当前位置:网站首页>Pod management
Pod management
2022-07-04 10:23:00 【Master Li of Buddhism】
# Set up image acceleration
cat /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"], # Here in k8s1.2 It is recommended to be consistent with this content when deploying versions above .
"registry-mirrors": ["https://zzypv4yy.mirror.aliyuncs.com"]
}
#--dry-run Output pod Created yaml file
[[email protected] ~]# kubectl run www --image=nginx --dry-run -o yaml
W0211 12:25:12.671160 43802 helpers.go:598] --dry-run is deprecated and can be replaced with --dry-run=client.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: www
name: www
spec:
containers:
- image: nginx
name: www
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
[[email protected] ~]# kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.71.133:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
namespace: app01
user: kubernetes-admin
name: [email protected]
current-context: [email protected]
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
# see api Object and version
[[email protected] ~]# kubectl api-resources
# see kube-sytem ns Medium pod Operation information
[[email protected] ~]# kubectl get pods -o wide -n kube-system
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-6d8c4cb4d-5x5gq 1/1 Running 8 (103m ago) 2d18h 10.244.0.31 k8s-master-01 <none> <none>
coredns-6d8c4cb4d-m2gjp 1/1 Running 8 (103m ago) 2d18h 10.244.0.30 k8s-master-01 <none> <none>
etcd-k8s-master-01 1/1 Running 10 (103m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
kube-apiserver-k8s-master-01 1/1 Running 10 (103m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
kube-controller-manager-k8s-master-01 1/1 Running 10 (103m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
kube-flannel-ds-8tzbw 1/1 Running 7 (101m ago) 2d18h 192.168.71.134 k8s-node-01 <none> <none>
kube-flannel-ds-d6fpt 1/1 Running 0 13h 192.168.71.135 k8s-node-02 <none> <none>
kube-flannel-ds-p46hm 1/1 Running 12 (102m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
kube-proxy-kfjhw 1/1 Running 0 13h 192.168.71.135 k8s-node-02 <none> <none>
kube-proxy-p5gws 1/1 Running 5 (101m ago) 2d18h 192.168.71.134 k8s-node-01 <none> <none>
kube-proxy-tmc9w 1/1 Running 8 (103m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
kube-scheduler-k8s-master-01 1/1 Running 10 (103m ago) 2d18h 192.168.71.133 k8s-master-01 <none> <none>
# see pod Content options
[[email protected] ~]# kubectl explain pod.spec
# see pod label
[[email protected] ~]# kubectl get pods --show-labels
# see pod Information
[[email protected] ~]# kubectl describe pod www
# see node Information
[[email protected] ~]# kubectl describe node k8s-node-01
# modify pod Information
[[email protected] ~]# kubectl edit pod www
# see event
[[email protected] ~]# kubectl get event
# Delete pod
[[email protected] ~]# kubectl delete pod www --grace-period=0 --force
# stay pod Middle execution command
[[email protected] ~]# kubectl exec -it www -- ls /
bin docker-entrypoint.d home media proc sbin tmp
boot docker-entrypoint.sh lib mnt root srv usr
dev etc lib64 opt run sys var
# Copy files from the host to pod Corresponding catalogue
[[email protected] ~]# kubectl cp /etc/hosts www:/tmp
[[email protected] ~]# kubectl exec -it www -- ls /tmp
hosts
# from pod Copy the file to the host
[[email protected] ~]# kubectl cp www:/etc/hosts hosts.bak
[[email protected] ~]# cat hosts.bak
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.1.15 www
# Enter designated pod Medium container
[[email protected] ~]# kubectl exec -it www -c www -- ls /tmp
hosts
# label
[[email protected] ~]# kubectl label nodes --all app=trust
[[email protected] ~]# kubectl label nodes --all app-
[[email protected] ~]# kubectl get pods -l app=www
#Taints
[[email protected] ~]# kubectl taint node k8s-node-01 xx=yy:NoSchedule
[[email protected] ~]# kubectl describe node k8s-node-01 | grep Taints
Taints: xx=yy:NoSchedule
## test Taint
[[email protected] ~]# kubectl run pod www --image=nginx --dry-run -o yaml
W0211 17:04:11.389901 16593 helpers.go:598] --dry-run is deprecated and can be replaced with --dry-run=client.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: pod
name: pod
spec:
containers:
- args:
- www
image: nginx
name: pod
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
## Copy the above content to www02.yaml And create pod, To the only one node The node is on Taint, It makes it impossible to schedule
[[email protected] ~]# kubectl apply -f www02.yaml
pod/pod created
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
pod 0/1 Pending 0 3s
## modify www02.yaml
[[email protected] ~]# cat www02.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: pod
name: www02
spec:
containers:
- image: nginx
name: nginx-01
tolerations:
- effect: NoSchedule
key: xx
value: yy
operator: Equal
dnsPolicy: ClusterFirst
restartPolicy: Always
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
www02 1/1 Running 0 42s
## Remove Taint
[[email protected] ~]# kubectl taint node k8s-node-01 xx:NoSchedule-
node/k8s-node-01 untainted
边栏推荐
- 【Day2】 convolutional-neural-networks
- libmysqlclient. so. 20: cannot open shared object file: No such file or directory
- Hands on deep learning (44) -- seq2seq principle and Implementation
- Differences among opencv versions
- Rhcsa day 10 operation
- Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- leetcode1-3
- Hands on deep learning (43) -- machine translation and its data construction
- 5g/4g wireless networking scheme for brand chain stores
猜你喜欢

Basic principle of servlet and application of common API methods

The time difference between the past time and the present time of uniapp processing, such as just, a few minutes ago, a few hours ago, a few months ago

Delayed message center design

MySQL develops small mall management system

Three schemes of ZK double machine room

From programmers to large-scale distributed architects, where are you (2)

5g/4g wireless networking scheme for brand chain stores

Rhcsa day 10 operation

2. Data type

Dynamic memory management
随机推荐
AUTOSAR from getting started to mastering 100 lectures (106) - SOA in domain controllers
Latex error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}
Differences among opencv versions
SQL replying to comments
A little feeling
MongoDB数据日期显示相差8小时 原因和解决方案
Hlk-w801wifi connection
If you don't know these four caching modes, dare you say you understand caching?
VLAN part of switching technology
Basic principle of servlet and application of common API methods
Batch distribution of SSH keys and batch execution of ansible
Use C to extract all text in PDF files (support.Net core)
OSPF summary
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
入职中国平安三周年的一些总结
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
El Table Radio select and hide the select all box
Idea SSH channel configuration
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
按键精灵打怪学习-识别所在地图、跑图、进入帮派识别NPC