Skip to content

Commit f7583a7

Browse files
authored
Merge pull request kubernetes#3220 from KnVerey/catalog-crd-compat
KEP-2906: Update Catalog schema for CRD compatibility
2 parents 27fc35e + 2c96f05 commit f7583a7

File tree

3 files changed

+106
-56
lines changed

3 files changed

+106
-56
lines changed

keps/sig-cli/2906-kustomize-function-catalog/README.md

Lines changed: 92 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ A successful implementation of this API should have the following characteristic
243243

244244
### Non-Goals
245245

246-
1. Support anything other than KRM-style fyunctions that follow the [functions spec](https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md)
246+
1. Support anything other than KRM-style functions that follow the [functions spec](https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md)
247247
1. Directly implement capabilities to publish function or other resources to OCI registries
248248

249249
## Proposal
@@ -255,15 +255,18 @@ A `Catalog` will contain a collection of one or more functions that can be used
255255
A minimal example is shown below:
256256

257257
```yaml
258-
apiVersion: kustomize.io/v1
258+
apiVersion: config.kubernetes.io/v1alpha1
259259
kind: Catalog
260260
metadata:
261-
name: "example-co-functionss"
261+
name: "example-co-functions"
262262
spec:
263263
krmFunctions:
264-
- apiVersion: example.com/v1
265-
kind: JavaApplication
264+
- group: example.com
265+
names:
266+
kind: JavaApplication
266267
description: "A Kustomize function that represents a Java based app"
268+
versions:
269+
- name: v1
267270
runtime:
268271
container:
269272
image: example/module_providers/java:v1.0.0
@@ -300,15 +303,18 @@ Kustomize can at a later date provide a built in Catalog for supporting official
300303
In addition to container based functions, the `Catalog` will support discovery of Starlark and Exec based functions, via an HTTP(s), Git, or OCI reference as illustrated below:
301304

302305
```yaml
303-
apiVersion: kustomize.io/v1
306+
apiVersion: config.kubernetes.io/v1alpha1
304307
kind: Catalog
305308
metadata:
306309
name: "example-co-functions"
307310
spec:
308311
krmFunctions:
309-
- apiVersion: example.com/v1
310-
kind: GroovyApplication
312+
- group: example.com
313+
names:
314+
kind: GroovyApplication
311315
description: "A Kustomize function that can handle groovy apps"
316+
versions:
317+
- name: v1
312318
runtime:
313319
starlark: https://example.co/module_providers/starlark-func:v1.0.0
314320
```
@@ -328,27 +334,36 @@ To do this, I build a new `Catalog` API resource:
328334

329335
```yaml
330336
# catalog.yaml
331-
apiVersion: kustomize.io/v1
337+
apiVersion: config.kubernetes.io/v1alpha1
332338
kind: Catalog
333339
metadata:
334340
name: "example-co-functions"
335341
spec:
336342
krmFunctions:
337-
- apiVersion: example.com/v1
338-
kind: JavaApplication
343+
- group: example.com
344+
names:
345+
kind: JavaApplication
339346
description: "A Kustomize function that can handle Java apps"
347+
versions:
348+
- name: v1
340349
runtime:
341350
container:
342351
image: docker.example.co/functions/java:v1.0.0
343-
- apiVersion: example.com/v1
344-
kind: Logger
352+
- group: example.com
353+
names:
354+
kind: Logger
345355
description: "A Kustomize function that adds our bespoke logging"
356+
versions:
357+
- name: v1
346358
runtime:
347359
container:
348360
image: docker.example.co/functions/logger:v1.0.0
349-
- apiVersion: example.com/v1
350-
kind: SecretSidecar
361+
- group: example.com
362+
names:
363+
kind: SecretSidecar
351364
description: "A Kustomize function that adds our bespoke secret sidecar"
365+
versions:
366+
- name: v1
352367
runtime:
353368
container:
354369
image: docker.example.co/functions/secrets:v1.0.0
@@ -460,15 +475,18 @@ modules:
460475
As a Kustomize developer, I want to build an `official` Helm extension module and publish it via the Kustomize official extension catalog. I build and publish the extension to the official Kustomize `gcr.io` project (or alternative, such as Github Package Registry). I then update the official Kustomize extension catalog:
461476

462477
```yaml
463-
apiVersion: kustomize.io/v1
478+
apiVersion: config.kubernetes.io/v1alpha1
464479
kind: Catalog
465480
metadata:
466481
name: "official-kustomize-functions"
467482
spec:
468483
krmFunctions:
469-
- apiVersion: kustomize.io/v1
470-
kind: Helm
484+
- group: kustomize.io
485+
names:
486+
kind: Helm
471487
description: "A Kustomize function that can handle Helm charts"
488+
versions:
489+
- name: v1
472490
runtime:
473491
container:
474492
image: k8s.gcr.io/kustomize/helm-function:v1.0.0
@@ -491,21 +509,27 @@ I publish the implementation of my function as a container to a public Docker re
491509
Once this has been approved and included into the officially published catalog, my function is available for others to discover:
492510

493511
```yaml
494-
apiVersion: kustomize.io/v1
512+
apiVersion: config.kubernetes.io/v1alpha1
495513
kind: Catalog
496514
metadata:
497515
name: "official-kustomize-functions"
498516
spec:
499517
krmFunctions:
500-
- apiVersion: kustomize.io/v1
501-
kind: Helm
518+
- group: kustomize.io
519+
names:
520+
kind: Helm
502521
description: "A Kustomize function that can handle Helm charts"
522+
versions:
523+
- name: v1
503524
runtime:
504525
container:
505526
image: k8s.gcr.io/kustomize/helm-function:v1.0.0
506-
- apiVersion: example.co/v1
507-
kind: McGuffin
527+
- group: example.co
528+
names:
529+
kind: McGuffin
508530
description: "A KRM function that everyone is searching for"
531+
versions:
532+
- name: v1
509533
runtime:
510534
container:
511535
image: docker.example.io/krm/mcguffin-function:v1.0.0
@@ -522,27 +546,36 @@ As a platform developer at enterprise company Example Co, I wish to publish a tr
522546
Using the runtime information and the metadata for each function, I publish a trusted catalog for use at Example Co
523547

524548
```yaml
525-
apiVersion: kustomize.io/v1
549+
apiVersion: config.kubernetes.io/v1alpha1
526550
kind: Catalog
527551
metadata:
528552
name: "example-co-aggregated-catalog"
529553
spec:
530554
krmFunctions:
531-
- apiVersion: banana.co/v1
532-
kind: Split
555+
- group: banana.co
556+
names:
557+
kind: Split
533558
description: "A KRM function that splits a deployment into multiple deployments"
559+
versions:
560+
- name: v1
534561
runtime:
535562
container:
536563
image: banana.gcr.io/functions/split-function:v1.0.0
537-
- apiVersion: watermelon.co/v1
538-
kind: Salt
564+
- group: watermelon.co
565+
names:
566+
kind: Salt
539567
description: "A KRM function that applies salt"
568+
versions:
569+
- name: v1
540570
runtime:
541571
container:
542572
image: watermelon.gcr.io/krm-functions/salt-function:v1.0.0
543-
- apiVersion: example.com/v1
544-
kind: JavaApplication
573+
- group: example.com
574+
names:
575+
kind: JavaApplication
545576
description: "A Kustomize function that can handle Java apps"
577+
versions:
578+
- name: v1
546579
runtime:
547580
container:
548581
image: example/module_providers/java:v1.0.0
@@ -587,22 +620,34 @@ info:
587620
title: KRM Function Metadata
588621
version: v1alpha1
589622
definitions:
590-
FunctionSpec:
623+
KRMFunctionDefinitionSpec:
591624
type: object
592625
description: spec contains the metadata for a KRM function.
593626
required:
594627
- group
595-
- kind
628+
- names
596629
- description
597630
- publisher
598631
- versions
599632
properties:
600633
group:
601634
description: group of the functionConfig
602635
type: string
603-
kind:
604-
description: kind of the functionConfig
636+
description:
637+
description: brief description of the KRM function.
638+
type: string
639+
publisher:
640+
description: the entity (e.g. organization) that produced and owns this KRM function.
605641
type: string
642+
names:
643+
description: the resource and kind names for the KRM function
644+
type: object
645+
required:
646+
- kind
647+
properties:
648+
kind:
649+
description: the Kind of the functionConfig
650+
type: string
606651
versions:
607652
description: the versions of the functionConfig
608653
type: array
@@ -743,30 +788,32 @@ definitions:
743788
type: array
744789
items:
745790
type: string
746-
KRMFunction:
791+
KRMFunctionDefinition:
747792
type: object
748-
description: KRMFunction is metadata of a KRM function.
793+
description: |
794+
KRMFunctionDefinition is metadata that defines a KRM function
795+
the same way a CustomResourceDefinition defines a custom resource.
749796
x-kubernetes-group-version-kind:
750797
- group: config.kubernetes.io
751-
kind: KRMFunction
798+
kind: KRMFunctionDefinition
752799
version: v1alpha1
753800
required:
754801
- apiVersion
755802
- kind
756803
- spec
757804
properties:
758805
apiVersion:
759-
description: apiVersion of KRMFunction. i.e. config.kubernetes.io/v1alpha1
806+
description: apiVersion of KRMFunctionDefinition. i.e. config.kubernetes.io/v1alpha1
760807
type: string
761808
enum:
762809
- config.kubernetes.io/v1alpha1
763810
kind:
764-
description: kind of the KRMFunction. It must be KRMFunction.
811+
description: kind of the KRMFunctionDefinition. It must be KRMFunctionDefinition.
765812
type: string
766813
enum:
767-
- KRMFunction
814+
- KRMFunctionDefinition
768815
spec:
769-
$ref: "#/definitions/FunctionSpec"
816+
$ref: "#/definitions/KRMFunctionDefinitionSpec"
770817
KRMFunctionCatalog:
771818
type: object
772819
description: KRMFunctionCatalog is the metadata of a collection of KRM functions.
@@ -799,7 +846,7 @@ definitions:
799846
krmFunctions:
800847
type: array
801848
items:
802-
$ref: "#/definitions/FunctionSpec"
849+
$ref: "#/definitions/KRMFunctionDefinitionSpec"
803850
paths: {}
804851
```
805852
</details>
@@ -811,7 +858,7 @@ When using OCI references, either a tag or digest reference can be provided. Exe
811858
An example representation is shown below:
812859
813860
```yaml
814-
apiVersion: kustomize.io/v1
861+
apiVersion: config.kubernetes.io/v1alpha1
815862
kind: Catalog
816863
metadata:
817864
name: "example-co-functions"
@@ -820,7 +867,8 @@ metadata:
820867
spec:
821868
krmFunctions:
822869
- group: example.com
823-
kind: SetNamespace
870+
names:
871+
kind: SetNamespace
824872
description: "A short description of the KRM function"
825873
publisher: example.com
826874
versions:

keps/sig-cli/2906-kustomize-function-catalog/kep.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ stage: alpha
2424
# The most recent milestone for which work toward delivery of this KEP has been
2525
# done. This can be the current (upcoming) milestone, if it is being actively
2626
# worked on.
27-
latest-milestone: "v1.23"
27+
latest-milestone: "v1.24"
2828

2929
# The milestone at which this feature was, or is targeted to be, at each stage.
3030
milestone:
31-
alpha: "v1.23"
32-
beta: "v1.24"
33-
stable: "v1.26"
31+
alpha: "v1.24"
32+
beta: "v1.25"
33+
stable: "v1.27"

keps/sig-cli/2985-public-krm-functions-registry/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,17 +559,18 @@ using [mdBook](https://github.com/rust-lang/mdBook).
559559

560560
### Function Metadata
561561

562-
We will use `KRMFunction` kind whose schema is defined in [KEP-2906](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2906-kustomize-function-catalog#function-metadata-schema) to capture the metadata for a single KRM function.
562+
We will use `KRMFunctionDefinition` kind whose schema is defined in [KEP-2906](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2906-kustomize-function-catalog#function-metadata-schema) to capture the metadata for a single KRM function.
563563

564564
The following is an example function metadata for a container-based KRM
565565
function. We will support it starting from the alpha phase.
566566

567567
```yaml
568-
apiVersion: config.k8s.io/v1alpha1
569-
kind: KRMFunction
568+
apiVersion: config.kubernetes.io/v1alpha1
569+
kind: KRMFunctionDefinition
570570
spec:
571571
group: example.com
572-
kind: SetNamespace
572+
names:
573+
kind: SetNamespace
573574
description: "A short description of the KRM function"
574575
publisher: example.com
575576
versions:
@@ -602,11 +603,12 @@ The following is an example for exec-based KRM function. We will support it
602603
starting from the beta phase.
603604
604605
```yaml
605-
apiVersion: config.k8s.io/v1alpha1
606-
kind: KRMFunction
606+
apiVersion: config.kubernetes.io/v1alpha1
607+
kind: KRMFunctionDefinition
607608
spec:
608609
group: example.com
609-
kind: SetNamespace
610+
names:
611+
kind: SetNamespace
610612
description: "A short description of the KRM function"
611613
publisher: example.com
612614
versions:
@@ -1172,4 +1174,4 @@ new subproject, repos requested, or GitHub details. Listing these here allows a
11721174
SIG to get the process for these resources started right away.
11731175
-->
11741176

1175-
[KRM functions spec]: https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md
1177+
[KRM functions spec]: https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md

0 commit comments

Comments
 (0)