@@ -1070,6 +1070,49 @@ for a request to convert `CronTab` objects to `example.com/v1`:
1070
1070
下面的示例显示了包含在 `ConversionReview` 对象中的数据,
1071
1071
该请求意在将 `CronTab` 对象转换为 `example.com/v1`:
1072
1072
1073
+ <!--
1074
+ ` ` ` yaml
1075
+ {
1076
+ "apiVersion": "apiextensions.k8s.io/v1",
1077
+ "kind": "ConversionReview",
1078
+ "request": {
1079
+ # Random uid uniquely identifying this conversion call
1080
+ "uid": "705ab4f5-6393-11e8-b7cc-42010a800002",
1081
+
1082
+ # The API group and version the objects should be converted to
1083
+ "desiredAPIVersion": "example.com/v1",
1084
+
1085
+ # The list of objects to convert.
1086
+ # May contain one or more objects, in one or more versions.
1087
+ "objects": [
1088
+ {
1089
+ "kind": "CronTab",
1090
+ "apiVersion": "example.com/v1beta1",
1091
+ "metadata": {
1092
+ "creationTimestamp": "2019-09-04T14:03:02Z",
1093
+ "name": "local-crontab",
1094
+ "namespace": "default",
1095
+ "resourceVersion": "143",
1096
+ "uid": "3415a7fc-162b-4300-b5da-fd6083580d66"
1097
+ },
1098
+ "hostPort": "localhost:1234"
1099
+ },
1100
+ {
1101
+ "kind": "CronTab",
1102
+ "apiVersion": "example.com/v1beta1",
1103
+ "metadata": {
1104
+ "creationTimestamp": "2019-09-03T13:02:01Z",
1105
+ "name": "remote-crontab",
1106
+ "resourceVersion": "12893",
1107
+ "uid": "359a83ec-b575-460d-b553-d859cedde8a0"
1108
+ },
1109
+ "hostPort": "example.com:2345"
1110
+ }
1111
+ ]
1112
+ }
1113
+ }
1114
+ ` ` `
1115
+ -->
1073
1116
{{< tabs name="ConversionReview_request" >}}
1074
1117
{{% tab name="apiextensions.k8s.io/v1" %}}
1075
1118
` ` ` yaml
@@ -1113,6 +1156,50 @@ for a request to convert `CronTab` objects to `example.com/v1`:
1113
1156
}
1114
1157
` ` `
1115
1158
{{% /tab %}}
1159
+ <!--
1160
+ ` ` ` yaml
1161
+ {
1162
+ # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
1163
+ "apiVersion": "apiextensions.k8s.io/v1beta1",
1164
+ "kind": "ConversionReview",
1165
+ "request": {
1166
+ # Random uid uniquely identifying this conversion call
1167
+ "uid": "705ab4f5-6393-11e8-b7cc-42010a800002",
1168
+
1169
+ # The API group and version the objects should be converted to
1170
+ "desiredAPIVersion": "example.com/v1",
1171
+
1172
+ # The list of objects to convert.
1173
+ # May contain one or more objects, in one or more versions.
1174
+ "objects": [
1175
+ {
1176
+ "kind": "CronTab",
1177
+ "apiVersion": "example.com/v1beta1",
1178
+ "metadata": {
1179
+ "creationTimestamp": "2019-09-04T14:03:02Z",
1180
+ "name": "local-crontab",
1181
+ "namespace": "default",
1182
+ "resourceVersion": "143",
1183
+ "uid": "3415a7fc-162b-4300-b5da-fd6083580d66"
1184
+ },
1185
+ "hostPort": "localhost:1234"
1186
+ },
1187
+ {
1188
+ "kind": "CronTab",
1189
+ "apiVersion": "example.com/v1beta1",
1190
+ "metadata": {
1191
+ "creationTimestamp": "2019-09-03T13:02:01Z",
1192
+ "name": "remote-crontab",
1193
+ "resourceVersion": "12893",
1194
+ "uid": "359a83ec-b575-460d-b553-d859cedde8a0"
1195
+ },
1196
+ "hostPort": "example.com:2345"
1197
+ }
1198
+ ]
1199
+ }
1200
+ }
1201
+ ` ` `
1202
+ -->
1116
1203
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
1117
1204
` ` ` yaml
1118
1205
{
@@ -1187,6 +1274,52 @@ Webhook 响应包含 200 HTTP 状态代码、`Content-Type: application/json`,
1187
1274
1188
1275
Webhook 的最简单成功响应示例:
1189
1276
1277
+ <!--
1278
+ ` ` ` yaml
1279
+ {
1280
+ "apiVersion": "apiextensions.k8s.io/v1",
1281
+ "kind": "ConversionReview",
1282
+ "response": {
1283
+ # must match <request.uid>
1284
+ "uid": "705ab4f5-6393-11e8-b7cc-42010a800002",
1285
+ "result": {
1286
+ "status": "Success"
1287
+ },
1288
+ # Objects must match the order of request.objects, and have apiVersion set to <request.desiredAPIVersion>.
1289
+ # kind, metadata.uid, metadata.name, and metadata.namespace fields must not be changed by the webhook.
1290
+ # metadata.labels and metadata.annotations fields may be changed by the webhook.
1291
+ # All other changes to metadata fields by the webhook are ignored.
1292
+ "convertedObjects": [
1293
+ {
1294
+ "kind": "CronTab",
1295
+ "apiVersion": "example.com/v1",
1296
+ "metadata": {
1297
+ "creationTimestamp": "2019-09-04T14:03:02Z",
1298
+ "name": "local-crontab",
1299
+ "namespace": "default",
1300
+ "resourceVersion": "143",
1301
+ "uid": "3415a7fc-162b-4300-b5da-fd6083580d66"
1302
+ },
1303
+ "host": "localhost",
1304
+ "port": "1234"
1305
+ },
1306
+ {
1307
+ "kind": "CronTab",
1308
+ "apiVersion": "example.com/v1",
1309
+ "metadata": {
1310
+ "creationTimestamp": "2019-09-03T13:02:01Z",
1311
+ "name": "remote-crontab",
1312
+ "resourceVersion": "12893",
1313
+ "uid": "359a83ec-b575-460d-b553-d859cedde8a0"
1314
+ },
1315
+ "host": "example.com",
1316
+ "port": "2345"
1317
+ }
1318
+ ]
1319
+ }
1320
+ }
1321
+ ` ` `
1322
+ -->
1190
1323
{{< tabs name="ConversionReview_response_success" >}}
1191
1324
{{% tab name="apiextensions.k8s.io/v1" %}}
1192
1325
` ` ` yaml
@@ -1234,6 +1367,53 @@ Webhook 的最简单成功响应示例:
1234
1367
}
1235
1368
` ` `
1236
1369
{{% /tab %}}
1370
+ <!--
1371
+ ` ` ` yaml
1372
+ {
1373
+ # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
1374
+ "apiVersion": "apiextensions.k8s.io/v1beta1",
1375
+ "kind": "ConversionReview",
1376
+ "response": {
1377
+ # must match <request.uid>
1378
+ "uid": "705ab4f5-6393-11e8-b7cc-42010a800002",
1379
+ "result": {
1380
+ "status": "Failed"
1381
+ },
1382
+ # Objects must match the order of request.objects, and have apiVersion set to <request.desiredAPIVersion>.
1383
+ # kind, metadata.uid, metadata.name, and metadata.namespace fields must not be changed by the webhook.
1384
+ # metadata.labels and metadata.annotations fields may be changed by the webhook.
1385
+ # All other changes to metadata fields by the webhook are ignored.
1386
+ "convertedObjects": [
1387
+ {
1388
+ "kind": "CronTab",
1389
+ "apiVersion": "example.com/v1",
1390
+ "metadata": {
1391
+ "creationTimestamp": "2019-09-04T14:03:02Z",
1392
+ "name": "local-crontab",
1393
+ "namespace": "default",
1394
+ "resourceVersion": "143",
1395
+ "uid": "3415a7fc-162b-4300-b5da-fd6083580d66"
1396
+ },
1397
+ "host": "localhost",
1398
+ "port": "1234"
1399
+ },
1400
+ {
1401
+ "kind": "CronTab",
1402
+ "apiVersion": "example.com/v1",
1403
+ "metadata": {
1404
+ "creationTimestamp": "2019-09-03T13:02:01Z",
1405
+ "name": "remote-crontab",
1406
+ "resourceVersion": "12893",
1407
+ "uid": "359a83ec-b575-460d-b553-d859cedde8a0"
1408
+ },
1409
+ "host": "example.com",
1410
+ "port": "2345"
1411
+ }
1412
+ ]
1413
+ }
1414
+ }
1415
+ ` ` `
1416
+ -->
1237
1417
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
1238
1418
` ` ` yaml
1239
1419
{
@@ -1494,33 +1674,13 @@ The following is an example procedure to upgrade from `v1beta1` to `v1`.
1494
1674
3. 从 CustomResourceDefinition 的 `status.storedVersions` 字段中删除 `v1beta1`。
1495
1675
1496
1676
{{< note >}}
1497
- <!--
1498
- The flag `--subresource` is used with the kubectl get, patch, edit, and replace commands to
1499
- fetch and update the subresources, `status` and `scale`, for all the API resources that
1500
- support them. This flag is available starting from kubectl version v1.24. Previously, reading
1501
- subresources (like `status`) via kubectl involved using `kubectl --raw`, and updating
1502
- subresources using kubectl was not possible at all. Starting from v1.24, the `kubectl` tool
1503
- can be used to edit or patch the `status` subresource on a CRD object. See [How to patch a Deployment using the subresource flag](/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#scale-kubectl-patch).
1504
- -->
1505
- ` --subresource` 标志在 kubectl get、patch、edit 和 replace 命令中用于获取和更新所有支持它们的
1506
- API 资源的子资源、`status` 和 `scale`。此标志从 kubectl 版本 v1.24 开始可用。
1507
- 以前通过 kubectl 读取子资源(如 `status`)涉及使用 `kubectl --raw`,并且根本不可能使用 kubectl 更新子资源。
1508
- 从 v1.24 开始,`kubectl` 工具可用于编辑或修补有关 CRD 对象的 `status` 子资源。
1509
- 请参阅[如何使用子资源标志修补 Deployment](/zh-cn/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#scale-kubectl-patch)。
1510
1677
1511
1678
<!--
1512
- This page is part of the documentation for Kubernetes v{{< skew currentVersion >}}.
1513
- If you are running a different version of Kubernetes, consult the documentation for that release.
1514
-
1515
1679
Here is an example of how to patch the `status` subresource for a CRD object using `kubectl` :
1516
1680
-->
1517
- 此页面是 Kubernetes v{{< skew currentVersion >}} 文档的一部分。
1518
- 如果你运行的是不同版本的 Kubernetes,请查阅相应版本的文档。
1519
-
1520
1681
以下是如何使用 `kubectl` 为一个 CRD 对象修补 `status` 子资源的示例:
1521
1682
1522
1683
` ` ` bash
1523
1684
kubectl patch customresourcedefinitions <CRD_Name> --subresource='status' --type='merge' -p '{"status":{"storedVersions":["v1"]}}'
1524
1685
` ` `
1525
1686
{{< /note >}}
1526
-
0 commit comments