5cbce04c05ecc9493552c264642445ffa18533ae
\345\237\272\344\272\216k8s\345\256\236\347\216\260\345\205\203\346\225\260\346\215\256\347\232\204\345\220\214\346\255\245.md
| ... | ... | @@ -14,8 +14,15 @@ CRD定义的yaml文件如下: |
| 14 | 14 | apiVersion: apiextensions.k8s.io/v1 |
| 15 | 15 | kind: CustomResourceDefinition |
| 16 | 16 | metadata: |
| 17 | + creationTimestamp: "2025-05-01T07:21:38Z" |
|
| 18 | + generation: 1 |
|
| 17 | 19 | name: appmodels.iidp.com |
| 20 | + resourceVersion: "1067883926" |
|
| 21 | + selfLink: /apis/apiextensions.k8s.io/v1/customresourcedefinitions/appmodels.iidp.com |
|
| 22 | + uid: 16777c57-b6ac-4441-b770-abb8373bb52f |
|
| 18 | 23 | spec: |
| 24 | + conversion: |
|
| 25 | + strategy: None |
|
| 19 | 26 | group: iidp.com |
| 20 | 27 | names: |
| 21 | 28 | kind: AppModel |
| ... | ... | @@ -32,20 +39,35 @@ spec: |
| 32 | 39 | properties: |
| 33 | 40 | spec: |
| 34 | 41 | properties: |
| 42 | + app: |
|
| 43 | + description: App name of the model |
|
| 44 | + type: string |
|
| 35 | 45 | models: |
| 46 | + description: Model list of the iidp-model |
|
| 36 | 47 | items: |
| 37 | - type: string |
|
| 48 | + properties: |
|
| 49 | + name: |
|
| 50 | + description: Model identifier |
|
| 51 | + type: string |
|
| 52 | + version: |
|
| 53 | + description: version of model |
|
| 54 | + type: string |
|
| 55 | + required: |
|
| 56 | + - name |
|
| 57 | + - version |
|
| 58 | + type: object |
|
| 59 | + minItems: 1 |
|
| 38 | 60 | type: array |
| 39 | - type: |
|
| 40 | - type: string |
|
| 41 | 61 | version: |
| 62 | + description: Version of app |
|
| 42 | 63 | type: string |
| 43 | 64 | type: object |
| 44 | 65 | type: object |
| 45 | 66 | served: true |
| 46 | 67 | storage: true |
| 47 | 68 | ``` |
| 48 | -该crd文件定义了一个类型为AppModel的 appmodel k8s资源,它的spec包括三个字段,分别是两个string类型的type和version字段和一个string数组类型的models字段。models字段表示一个app可以有多个model名称,比如一个名为 iiot 的app包含有 iiot_dataservice、iiot_edge_project、iiot_data_query等元模型。 |
|
| 69 | +该crd文件定义了一个类型为AppModel的 appmodel k8s资源,它的spec包括三个字段,分别是两个string类型的app和version字段和一个Model数组类型的models字段。models字段表示一个app可以有多个model名称,比如一个名为 iiot 的app包含有 iiot_dataservice、iiot_edge_project、iiot_data_query等元模型。 |
|
| 70 | +注意不管是app还是model,它们都各自包含各自的version用于描述自身的版本信息,比如可用于判断版本是否改变等。 |
|
| 49 | 71 | |
| 50 | 72 | #### 2. CRD的创建 |
| 51 | 73 | 通过kubectl 或者 在代码中自动创建crd都可以,创建完以后我们查看一下具体的crd: |
| ... | ... | @@ -54,12 +76,12 @@ PS C:\Users\lzb\Desktop> k25 get crd appmodels.iidp.com -oyaml |
| 54 | 76 | apiVersion: apiextensions.k8s.io/v1 |
| 55 | 77 | kind: CustomResourceDefinition |
| 56 | 78 | metadata: |
| 57 | - creationTimestamp: "2025-04-24T03:39:09Z" |
|
| 79 | + creationTimestamp: "2025-05-01T07:21:38Z" |
|
| 58 | 80 | generation: 1 |
| 59 | 81 | name: appmodels.iidp.com |
| 60 | - resourceVersion: "1060306843" |
|
| 82 | + resourceVersion: "1067883926" |
|
| 61 | 83 | selfLink: /apis/apiextensions.k8s.io/v1/customresourcedefinitions/appmodels.iidp.com |
| 62 | - uid: 49d3eba2-f2ed-4d10-b885-6e6154bb7baf |
|
| 84 | + uid: 16777c57-b6ac-4441-b770-abb8373bb52f |
|
| 63 | 85 | spec: |
| 64 | 86 | conversion: |
| 65 | 87 | strategy: None |
| ... | ... | @@ -79,13 +101,27 @@ spec: |
| 79 | 101 | properties: |
| 80 | 102 | spec: |
| 81 | 103 | properties: |
| 104 | + app: |
|
| 105 | + description: App name of the model |
|
| 106 | + type: string |
|
| 82 | 107 | models: |
| 108 | + description: Model list of the iidp-model |
|
| 83 | 109 | items: |
| 84 | - type: string |
|
| 110 | + properties: |
|
| 111 | + name: |
|
| 112 | + description: Model identifier |
|
| 113 | + type: string |
|
| 114 | + version: |
|
| 115 | + description: version of model |
|
| 116 | + type: string |
|
| 117 | + required: |
|
| 118 | + - name |
|
| 119 | + - version |
|
| 120 | + type: object |
|
| 121 | + minItems: 1 |
|
| 85 | 122 | type: array |
| 86 | - type: |
|
| 87 | - type: string |
|
| 88 | 123 | version: |
| 124 | + description: Version of app |
|
| 89 | 125 | type: string |
| 90 | 126 | type: object |
| 91 | 127 | type: object |
| ... | ... | @@ -100,12 +136,12 @@ status: |
| 100 | 136 | - am |
| 101 | 137 | singular: appmodel |
| 102 | 138 | conditions: |
| 103 | - - lastTransitionTime: "2025-04-24T03:39:09Z" |
|
| 139 | + - lastTransitionTime: "2025-05-01T07:21:38Z" |
|
| 104 | 140 | message: no conflicts found |
| 105 | 141 | reason: NoConflicts |
| 106 | 142 | status: "True" |
| 107 | 143 | type: NamesAccepted |
| 108 | - - lastTransitionTime: "2025-04-24T03:39:09Z" |
|
| 144 | + - lastTransitionTime: "2025-05-01T07:21:38Z" |
|
| 109 | 145 | message: the initial names have been accepted |
| 110 | 146 | reason: InitialNamesAccepted |
| 111 | 147 | status: "True" |