Kubernetes创建资源对象(六)

Kubernetes支持YAML和JSON格式创建资源对象

1、JSON格式用于接口之间消息的传递

2、YAML格式用于配置和管理

YAML是一种简洁的非标记性语言

语法格式:

  缩进标识层级关系

  不支持制表符缩进,使用空格缩进

  通常开头缩进两个空格

  字符后缩进一个空格,如冒号,逗号等

  “---”表示YAML格式,一个文件的开始

  “#”表示注释

查看具体资源的详细信息

1、创建pod

[root@localhost ~]#  kubectl run nginx --image=nginx:latest --port=80 --replicas=3
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx created

2、查看pod,状态为ContainerCreating

[root@localhost ~]# kubectl get pods
NAME                     READY   STATUS              RESTARTS   AGE
nginx-7697996758-j5cwn   0/1     ContainerCreating   0          17s
nginx-7697996758-nw2v4   0/1     ContainerCreating   0          17s
nginx-7697996758-sxkp9   0/1     ContainerCreating   0          17s

3、处于动态监听状态

[root@localhost ~]# kubectl get pods -w
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7697996758-j5cwn   1/1     Running   0          39s
nginx-7697996758-nw2v4   1/1     Running   0          39s
nginx-7697996758-sxkp9   1/1     Running   0          39s

4、再查看,状态为Running

[root@localhost ~]# kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7697996758-j5cwn   1/1     Running   0          79s
nginx-7697996758-nw2v4   1/1     Running   0          79s
nginx-7697996758-sxkp9   1/1     Running   0          79s

5、查看镜像资源

[root@localhost ~]# kubectl describe pod nginx-7697996758-j5cwn
Name:               nginx-7697996758-j5cwn
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               192.168.35.102/192.168.35.102
Start Time:         Wed, 12 Feb 2020 00:07:58 +0800
Labels:             pod-template-hash=7697996758
                    run=nginx
Annotations:        <none>
Status:             Running
IP:                 172.17.68.2
Controlled By:      ReplicaSet/nginx-7697996758
Containers:
  nginx:
    Container ID:   docker://a55be62040ad1bc1667d48a5b4adab626af857bcbb3f4985591381cf19b1f3ff
    Image:          nginx:latest
    Image ID:       docker-pullable://nginx@sha256:ad5552c786f128e389a0263104ae39f3d3c7895579d45ae716f528185b36bc6f
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Wed, 12 Feb 2020 00:08:14 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-r5ql5 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-r5ql5:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-r5ql5

6、查看deployment资源

[root@loc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值