Kubernetes单Pod操作

本文将介绍如何使用kubectl run命令创建一个Pod,并通过Kubernetes集群进行管理。我们将探讨Pod的创建过程,确认其运行状态,所在Node以及通过describe命令查看详细信息。
摘要由CSDN通过智能技术生成

在上一篇文章中我们使用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
> done
host132
docker.io/sonarqube              latest              eea2f3093d50        5 days ago          790.9 MB
host133
docker.io/sonarqube                latest              eea2f3093d50        Less than a second ago   790.9 MB
host134
docker.io/sonarqube                latest              eea2f3093d50        Less than a second ago   790.9 MB
[root@host131 ~]#

事前确认

事前确认:没有pod

[root@host131 ~]# kubectl get pods
[root@host131 ~]#

创建pod

[root@host131 ~]# kubectl run example --image=sonarqube
deployment "example" created
[root@host131 ~]#

确认pod的创建结果

确认已经是running状态

[root@host131 ~]# kubectl get pods
NAME                       READY     STATUS    RESTARTS   AGE
example-3821493920-c7c8v   1/1       Running   0          1m
[root@host131 ~]#

确认pod所在的node

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

[root@host131 ~]# kubectl get pod -o wide
NAME                       READY     STATUS    RESTARTS   AGE       NODE
example-3821493920-c7c8v   1/1       Running   1          6m        host134
[root@host131 ~]#

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

describe pod

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

[root@host131 ~]# kubectl describe pod example-3821493920-c7c8v
Name:           example-3821493920-c7c8v
Namespace:      default
Node:           host134/192.168.32.134
Start Time:     Tue, 30 Aug 2016 13:01:03 -0400
Labels:         pod-template-hash=3821493920,run=example
Status:         Running
IP:             172.16.64.5
Controllers:    ReplicaSet/example-3821493920
Containers:
  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         False
Volumes:
  default-token-8209b:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-8209b
Events:
  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 ~]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值