1. 首页
  2. 主题
  3. Go语言

关于go中的标签

zackzhangkai · · 1207 次点击
```go type Deployment struct { metav1.TypeMeta `json:",inline"` //这个逗号加inline是啥意思? metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } ``` 经常看到这个结构体,这个结构体是k8s deployment的结构体,这个逗号加inline一直没有完全明白。 比如下面的是我的deployment的声明式结构: ``` apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" creationTimestamp: "2020年07月05日T09:04:09Z" generation: 1 labels: k8s-app: kube-dns name: coredns namespace: kube-system resourceVersion: "929" selfLink: /apis/apps/v1/namespaces/kube-system/deployments/coredns uid: 7ff5c68f-b7d2-431b-b533-57be6f903d22 spec: progressDeadlineSeconds: 600 replicas: 2 revisionHistoryLimit: 10 ... status: availableReplicas: 2 ``` 这个结构中定义分别为 apiVersion,kind, metadata, spec, status。其中后面三个可以跟代码中的定义匹配上,但是前面两个apiVersion,kind应该是对应的 ,inline,我现在就没有明白这个。
真是非常不好意思,我理解错你的意思了,评论也删不掉, ‘,’可能就是编码方便,没其它意思
#3
更多评论
只是猜想 inline是 kubectl label deployment $name label_key = label_value ,使用kubectl create deployment $xxxx .... 创建deployment。
#1
####kind表示K8s的资源类型,k8s除了deployment ,还有service,pod, pvc ... ####apiVersion: 可能想要表示k8s一个镜像可以运行多个版本
#2

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中