转载自 https://blog.csdn.net/yrx420909/article/details/105678325

1.什么是资源清单

在k8s中,一般使用yaml格式的文件来创建符合我们预期期望的pod,这样的yaml文件我们一般称为资源清单

2.资源清单的格式

  1. apiVersion: group/apiversion # 如果没有给定group名称,那么默认为croe,可以使用kubectl api-versions 获取当前k8s版本上所有的apiVersion版本信息(每个版本可能不同)
  2. kind: #资源类别
  3. metadata #资源元数据
  4. name
  5. namespace #k8s自身的namespace
  6. lables
  7. annotations #主要目的是方便用户阅读查找
  8. spec:期望的状态(disired state
  9. status:当前状态,本字段有kubernetes自身维护,用户不能去定义

配置清单主要有五个一级字段,其中status用户不能定义,由k8s自身维护

3.获取资源的apiVersion版本及资源配置的帮助

1)获取apiVersion版本信息

  1. [root@k8s-5-138 pod_template]# kubectl api-versions
  2. admissionregistration.k8s.io/v1
  3. admissionregistration.k8s.io/v1beta1
  4. apiextensions.k8s.io/v1
  5. apiextensions.k8s.io/v1beta1
  6. apiregistration.k8s.io/v1
  7. apiregistration.k8s.io/v1beta1
  8. apps/v1
  9. authentication.k8s.io/v1
  10. authentication.k8s.io/v1beta1
  11. authorization.k8s.io/v1
  12. authorization.k8s.io/v1beta1
  13. autoscaling/v1
  14. autoscaling/v2beta1
  15. autoscaling/v2beta2
  16. batch/v1
  17. batch/v1beta1
  18. certificates.k8s.io/v1beta1
  19. coordination.k8s.io/v1
  20. coordination.k8s.io/v1beta1
  21. discovery.k8s.io/v1beta1
  22. events.k8s.io/v1beta1
  23. extensions/v1beta1
  24. networking.k8s.io/v1
  25. networking.k8s.io/v1beta1
  26. node.k8s.io/v1beta1
  27. policy/v1beta1
  28. rbac.authorization.k8s.io/v1
  29. rbac.authorization.k8s.io/v1beta1
  30. scheduling.k8s.io/v1
  31. scheduling.k8s.io/v1beta1
  32. storage.k8s.io/v1
  33. storage.k8s.io/v1beta1
  34. v1

2)获取资源的apiVersion版本信息

  1. [root@k8s-5-138 pod_template]# kubectl explain DaemonSet
  2. KIND: DaemonSet
  3. VERSION: apps/v1
  4. DESCRIPTION:
  5. DaemonSet represents the configuration of a daemon set.
  6. FIELDS:
  7. apiVersion <string>
  8. APIVersion defines the versioned schema of this representation of an
  9. object. Servers should convert recognized schemas to the latest internal
  10. value, and may reject unrecognized values. More info:
  11. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
  12. kind <string>
  13. Kind is a string value representing the REST resource this object
  14. represents. Servers may infer this from the endpoint the client submits
  15. requests to. Cannot be updated. In CamelCase. More info:
  16. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
  17. metadata <Object>
  18. Standard object's metadata. More info:
  19. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
  20. spec <Object>
  21. The desired behavior of this daemon set. More info:
  22. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
  23. status <Object>
  24. The current status of this daemon set. This data may be out of date by some
  25. window of time. Populated by the system. Read-only. More info:
  26. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

可以看的出来,不同的资源可能属于不同的apiVersion版本