Skip to content

Commit a20d3a6

Browse files
authored
KEP 2299: Kustomize Plugin Composition API (#2300)
* KEP for Kustomize Plugin Composition * Incorporate feedback * Add comparison of Kustomization and Composition with transformer config transformations * Update ToC
1 parent 0406326 commit a20d3a6

File tree

14 files changed

+775
-0
lines changed

14 files changed

+775
-0
lines changed

keps/sig-cli/2299-kustomize-plugin-composition/README.md

+563
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Composition
3+
4+
modules:
5+
- apiVersion: kustomize.config.k8s.io/v1alpha1
6+
kind: StaticResources
7+
metadata:
8+
name: local-resources
9+
spec:
10+
paths:
11+
- resources
12+
- apiVersion: team.example.com/v1alpha1
13+
kind: WebServer
14+
metadata:
15+
name: web-server
16+
provider:
17+
container:
18+
image: docker.example.com/kustomize-modules/web-server:v0.1.0
19+
spec:
20+
appName: nginx-example
21+
image: nginx:1.18
22+
replicas: 2
23+
expose:
24+
http: yes
25+
- apiVersion: team.example.com/v1alpha1
26+
kind: Logger
27+
metadata:
28+
name: logging
29+
provider:
30+
container:
31+
image: docker.example.com/kustomize-modules/logger:v0.1.0
32+
spec:
33+
selector:
34+
matchLabels:
35+
app: nginx-example
36+
source:
37+
paths:
38+
- /var/log/nginx/error.log
39+
- /var/log/nginx/access.log
40+
- apiVersion: team.example.com/v1alpha1
41+
kind: HTTPLoadBalancer
42+
metadata:
43+
name: lb
44+
provider:
45+
container:
46+
image: docker.example.com/kustomize-modules/lb:v0.1.1
47+
spec:
48+
selector:
49+
matchLabels:
50+
app: nginx-example
51+
loadBalancer:
52+
domain: nginx-example.myco-dev.io
53+
expose:
54+
serviceName: nginx
55+
port: 80
56+
- apiVersion: kustomize.config.k8s.io/v1alpha1
57+
kind: Kustomize
58+
metadata:
59+
name: my-kustomize
60+
spec:
61+
commonLabels:
62+
foo: bar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: game-demo
5+
data:
6+
player_initial_lives: "3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Composition
3+
4+
modulesFrom:
5+
- path: base/composition.yaml
6+
7+
moduleOverrides:
8+
- apiVersion: team.example.com/v1alpha1
9+
kind: HTTPLoadBalancer
10+
metadata:
11+
name: lb
12+
spec:
13+
loadBalancer:
14+
domain: foo.app.example.com
15+
16+
modules:
17+
- apiVersion: kustomize.config.k8s.io/v1alpha1
18+
kind: Kustomize
19+
metadata:
20+
name: productionizer
21+
spec:
22+
commonLabels:
23+
env: production
24+
namespace: nginx-example-prod
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- prod-integration-base
6+
7+
# This layer is needed because the plugins are transformers, and the transformers field is executed after the built-in like the label transformer. So most of the resources wouldn't be labelled if we included this in prod-integration-base instead.
8+
commonLabels:
9+
env: production
10+
foo: bar # Ideally this label would be at a lower layer, but that won't work.
11+
12+
namespace: nginx-example-prod
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- resources/configmap.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: game-demo
5+
data:
6+
player_initial_lives: "3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- builtins-base
6+
7+
# This layer changes the transformer configs from being treated as resources to being executed. Transformer config must be fully resolved by this point. It is not possible to create a true "base" Kustomization that incorporates resources/built-ins with generic transformer configs. Instead, transformer config must be finalized (e.g. with production values) below this layer, and built-ins (e.g. label transformer config) must be specified above it (to apply to the results of the transformers).
8+
transformers:
9+
- prod-plugin-transformation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- plugins-base
6+
7+
patchesStrategicMerge:
8+
- |-
9+
apiVersion: team.example.com/v1alpha1
10+
kind: HTTPLoadBalancer
11+
metadata:
12+
name: lb
13+
spec:
14+
loadBalancer:
15+
domain: foo.app.example.com
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
# The ordering here becomes super important once they're transformers, and in practice it is preserved. But it's not obvious at the point where they become transformers.
5+
# It isn't possible to mix base resources that should remain resources with ones that need to become transformers. This makes sense in the Kustomization paradigm, but forces splitting apart the pieces of a given logical layer.
6+
resources:
7+
- web-server.yaml
8+
- logger.yaml
9+
- lb.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: team.example.com/v1alpha1
2+
kind: HTTPLoadBalancer
3+
metadata:
4+
name: lb
5+
annotations:
6+
config.kubernetes.io/function: |
7+
container:
8+
image: docker.example.com/kustomize-modules/lb:v0.1.1
9+
spec:
10+
selector:
11+
matchLabels:
12+
app: nginx-example
13+
expose:
14+
serviceName: nginx
15+
port: 80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: team.example.com/v1alpha1
2+
kind: Logger
3+
metadata:
4+
name: logging
5+
annotations:
6+
config.kubernetes.io/function: |
7+
container:
8+
image: docker.example.com/kustomize-modules/logger:v0.1.0
9+
spec:
10+
selector:
11+
matchLabels:
12+
app: nginx-example
13+
source:
14+
paths:
15+
- /var/log/nginx/error.log
16+
- /var/log/nginx/access.log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: team.example.com/v1alpha1
2+
kind: WebServer
3+
metadata:
4+
name: web-server
5+
annotations:
6+
config.kubernetes.io/function: |
7+
container:
8+
image: docker.example.com/kustomize-modules/web-server:v0.1.0
9+
spec:
10+
appName: nginx-example
11+
image: nginx:1.18
12+
replicas: 2
13+
expose:
14+
http: yes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
title: Kustomize Plugin Composition API
2+
kep-number: 2299
3+
authors:
4+
- "@knverey"
5+
- "@campoy"
6+
owning-sig: sig-cli
7+
participating-sigs:
8+
- sig-cli
9+
status: provisional
10+
creation-date: 2021-01-20
11+
reviewers:
12+
- "@monopole"
13+
- "@pwittrock"
14+
approvers:
15+
- "@monopole"
16+
- "@pwittrock"
17+
stage: alpha
18+
latest-milestone: "v1.22"

0 commit comments

Comments
 (0)