分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
在上一篇文章中我们使用RC的方式创建了一个sonarqube的方式的pod,这篇文章中将会使用kubectl run的方式来创建一个pod,并会简单确认一下这两者有何不同。
构成说明
演示程序使用下列的集群构成。
No | type | IP | OS |
---|---|---|---|
1 | master | 192.168.32.131 | CENTOS7.2 |
2 | etcd | 192.168.32.131 | CENTOS7.2 |
3 | minion | 192.168.32.132 | CENTOS7.2 |
3 | minion | 192.168.32.133 | CENTOS7.2 |
3 | minion | 192.168.32.134 | CENTOS7.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
