RESTful:
GET,PUT,DELETE,POST。。。kubectl run ,get ,edit ...
资源:对象
workload: Pod,ReplicaSet,Deployment,StatefulSet,DeamonSet,Job,Cronjob...服务发现及均衡:Service,Ingress,。。。配置与存储:Volume,CSI ConfigMap,Secret DownwardAPI集群级的资源 Namespace,Node,Role,ClusterRole,RoleBinding,ClusterRoleBinding元数据型资源 HPA,PodTemplate,LimitRange查看pod的yaml资源列表 [root@ll-sas01 ~]# kubectl get pod myapp-848b5b879b-2bgl6 -o yaml
创建资源的方法:apiserver仅接收JSON格式的资源定义
yaml格式提供配置清单,apiserver可自动将其转为json格式,而后再提交
大部分资源的配置清单:
apiVersion:groupname/version 获取 kubectl api-versionskind:资源类别metadata:元数据 name namespace label annotations ownerReferences selfLink uid resourceVersion
每个资源的引用方式PATH/api/GROUP/VERSION/namespace/NAMESPACE/TYPE/NAMEspec:期望的状态,disired statestatus :当前状态,current state,本字段资源定义方式使用方式kubectl explain pods :获取pods的定义方式pods下的metadata获取kubectl explain pods.metadata
简单使用yaml来定义一个pod创建 vim pod-demo.yaml
apiVersion: v1kind: Podmetadata: name: pod-demo namespace: default labels: app: myapp tier: frontendspec: containers: - name: myapp image: ikubernetes/myapp:v1 - name: busybox image: busybox:latest command: - "/bin/sh" - "-c" - "sleep 3600"
基于yaml来创建pod
[root@ll-sas01 ~/manifests]# kubectl create -f pod-demo.yaml [root@ll-sas01 ~/manifests]# kubectl get podsNAME READY STATUS RESTARTS AGEpod-demo 2/2 Running 0 2m
查看容器信息:
[root@ll-sas01 ~/manifests]# kubectl describe pod pod-demo查看yaml日志:
[root@ll-sas01 ~/manifests]# kubectl logs pod-demo myapp10.244.0.0 - - [20/Sep/2018:02:49:43 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"10.244.0.0 - - [20/Sep/2018:02:49:45 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"10.244.0.0 - - [20/Sep/2018:02:49:46 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"[root@ll-sas01 ~/manifests]# kubectl logs pod-demo busybox/bin/sh: can't create /usr/share/nginx/html/index.html: nonexistent directory进入容器:
[root@ll-sas01 ~/manifests]# kubectl exec -it pod-demo -c myapp -- /bin/sh删除容器:
[root@ll-sas01 ~/manifests]# kubectl delete pod pod-demo或者[root@ll-sas01 ~/manifests]# kubectl delete -f pod-demo.yaml