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