前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >27 Nov 2021 cka练习(五)

27 Nov 2021 cka练习(五)

作者头像
俊采
发布2023-10-17 10:36:05
1310
发布2023-10-17 10:36:05
举报
文章被收录于专栏:LEo的网络日志LEo的网络日志

1 pod包含多个container

代码语言:javascript
复制
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: c1
    image: quay.io/prometheus/busybox:latest
    command: ['sh', '-c', 'echo The c1 is running! && sleep 3600']
  - name: c2
    image: quay.io/prometheus/busybox:latest
    command: ['sh', '-c', 'echo The c2 is running! && sleep 3600']
EOF
$ kgp
NAME        READY   STATUS    RESTARTS   AGE
myapp-pod   2/2     Running   0          90s
$ k logs myapp-pod c1
The c1 is running!
$ k logs myapp-pod c2
The c2 is running!

2 统计ready节点数量

代码语言:javascript
复制
$ k get no | grep -w Ready | wc -l
6
$ k describe no | grep -i taints | grep -i nochedule | wc -l
0
$ echo 6 > /opt/nodenum

3 调度pod到指定节点

代码语言:javascript
复制
$ k get no
NAME                           STATUS                     ROLES    AGE   VERSION
ip-10-0-128-182.ec2.internal   Ready,SchedulingDisabled   master   47h   v1.21.1+f36aa36
ip-10-0-129-62.ec2.internal    Ready                      worker   47h   v1.21.1+f36aa36
ip-10-0-144-211.ec2.internal   Ready                      worker   47h   v1.21.1+f36aa36
ip-10-0-158-94.ec2.internal    Ready                      master   47h   v1.21.1+f36aa36
ip-10-0-167-32.ec2.internal    Ready                      worker   47h   v1.21.1+f36aa36
ip-10-0-171-215.ec2.internal   Ready                      master   47h   v1.21.1+f36aa36
$ k label no ip-10-0-167-32.ec2.internal disktype=ssd
node/ip-10-0-167-32.ec2.internal labeled
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd
EOF
$ k get po
NAME        READY   STATUS    RESTARTS   AGE
myapp-pod   2/2     Running   0          13m
nginx       1/1     Running   0          10s
$ kd po nginx | grep ip-10-0-167-32.ec2.internal
Node:         ip-10-0-167-32.ec2.internal/10.0.167.32
  Normal  Scheduled       27s   default-scheduler  Successfully assigned ssli/nginx to ip-10-0-167-32.ec2.internal

LEo at 12:12

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 pod包含多个container
  • 2 统计ready节点数量
  • 3 调度pod到指定节点
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档