https://github.com/kubernetes/api/blob/master/core/v1/types.go
type Pod struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Specification of the desired behavior of the pod.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +optional
Spec PodSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// Most recently observed status of the pod.
// This data may not be up to date.
// Populated by the system.
// Read-only.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +optional
Status PodStatus `json:

本文主要探讨Kubernetes Pod的源码,通过分析Golang实现,揭示Pod的metadata结构及其json序列化过程中`omitempty`的使用,理解如何减少变量嵌套并了解当字段为空时在json中如何表示。
最低0.47元/天 解锁文章
669

被折叠的 条评论
为什么被折叠?



