Kubernetes单Pod操作

本文介绍如何使用kubectl run命令在Kubernetes集群中创建Pod,并通过describe命令查看Pod详细信息,对比与RC创建的区别。内容包括事前准备、确认Pod状态及所在Node等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

                       
 

在上一篇文章中我们使用RC的方式创建了一个sonarqube的方式的pod,这篇文章中将会使用kubectl run的方式来创建一个pod,并会简单确认一下这两者有何不同。

构成说明

 

演示程序使用下列的集群构成。

                                               
NotypeIPOS
1master192.168.32.131CENTOS7.2
2etcd192.168.32.131CENTOS7.2
3minion192.168.32.132CENTOS7.2
3minion192.168.32.133CENTOS7.2
3minion192.168.32.134CENTOS7.2

事前准备

 

事前将所需镜像提前pull下的各个minion节点

[root@host131 ~]# for h in host132 host133 host134> do> echo "$h"> ssh $h docker images |grep sonarqube> donehost132docker.io/sonarqube              latest              eea2f3093d50        5 days ago          790.9 MBhost133docker.io/sonarqube                latest              eea2f3093d50        Less than a second ago   790.9 MBhost134docker.io/sonarqube                latest              eea2f3093d50        Less than a second ago   790.9 MB[root@host131 ~]#
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

事前确认

 

事前确认:没有pod

[root@host131 ~]# kubectl get pods[root@host131 ~]#
  
  • 1
  • 2

创建pod

[root@host131 ~]# kubectl run example --image=sonarqubedeployment "example" created[root@host131 ~]#
  
  • 1
  • 2
  • 3

确认pod的创建结果

 

确认已经是running状态

[root@host131 ~]# kubectl get podsNAME                       READY     STATUS    RESTARTS   AGEexample-3821493920-c7c8v   1/1       Running   0          1m[root@host131 ~]#
  
  • 1
  • 2
  • 3
  • 4

确认pod所在的node

 

我们有3个node,到底是在哪台node上运行这个pod呢

[root@host131 ~]# kubectl get pod -o wideNAME                       READY     STATUS    RESTARTS   AGE       NODEexample-3821493920-c7c8v   1/1       Running   1          6m        host134[root@host131 ~]#
  
  • 1
  • 2
  • 3
  • 4

通过rancher,也可以确认到在host134上跑这个这个example-3821493920-c7c8v
这里写图片描述

describe pod

 

通过kubectl describe pod来确认一下详细信息,可以和RC创建的方式进行比较。

[root@host131 ~]# kubectl describe pod example-3821493920-c7c8vName:           example-3821493920-c7c8vNamespace:      defaultNode:           host134/192.168.32.134Start Time:     Tue, 30 Aug 2016 13:01:03 -0400Labels:         pod-template-hash=3821493920,run=exampleStatus:         RunningIP:             172.16.64.5Controllers:    ReplicaSet/example-3821493920Containers:  example:    Container ID:       docker://363971c9af13a301a3998c54957bc0579f78e66f66d2064ee61940bb49325f54    Image:              sonarqube    Image ID:           docker://sha256:eea2f3093d50fde1a5cf90faea4e20b6cc966768885ee9b264ec2c616d803cd2    Port:    QoS Tier:      cpu:              BestEffort      memory:           BestEffort    State:              Terminated      Reason:           Completed      Exit Code:        0      Started:          Tue, 30 Aug 2016 13:01:39 -0400      Finished:         Tue, 30 Aug 2016 13:04:22 -0400    Ready:              False    Restart Count:      0    Environment Variables:Conditions:  Type          Status  Ready         FalseVolumes:  default-token-8209b:    Type:       Secret (a volume populated by a Secret)    SecretName: default-token-8209bEvents:  FirstSeen     LastSeen        Count   From                    SubobjectPath                   Type            Reason          Message  ---------     --------        -----   ----                    -------------                   --------        ------          -------  7d            7d              1       {kubelet host134}       spec.containers{example}        Normal          Pulling         pulling image "sonarqube"  7d            7d              1       {kubelet host134}       spec.containers{example}        Normal          Pulled          Successfully pulled image "sonarqube"  7d            7d              1       {kubelet host134}       spec.containers{example}        Normal          Created         Created container with docker id 363971c9af13  7d            7d              1       {kubelet host134}       spec.containers{example}        Normal          Started         Started container with docker id 363971c9af13  3m            3m              1       {default-scheduler }                                    Normal          Scheduled       Successfully assigned example-3821493920-c7c8v to host134[root@host131 ~]#
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
           

给我老师的人工智能教程打call!http://blog.youkuaiyun.com/jiangjunshow
这里写图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值