-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomposition.yaml
More file actions
71 lines (71 loc) · 2.45 KB
/
Copy pathcomposition.yaml
File metadata and controls
71 lines (71 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Composition: XApp -> Deployment + Service (Kubernetes application)
# v2: compose any resource; Crossplane needs RBAC for deployments and services
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xapp-application
spec:
compositeTypeRef:
apiVersion: example.org/v1alpha1
kind: XApp
mode: Pipeline
pipeline:
- step: create-application
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: deployment
base:
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 1
selector:
matchLabels: {}
template:
metadata:
labels: {}
spec:
containers:
- name: app
image: nginx
ports:
- containerPort: 80
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.replicas
toFieldPath: spec.replicas
- type: FromCompositeFieldPath
fromFieldPath: spec.image
toFieldPath: spec.template.spec.containers[0].image
- type: FromCompositeFieldPath
fromFieldPath: spec.port
toFieldPath: spec.template.spec.containers[0].ports[0].containerPort
- type: FromCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: spec.selector.matchLabels[app]
- type: FromCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: spec.template.metadata.labels[app]
- name: service
base:
apiVersion: v1
kind: Service
spec:
ports:
- port: 80
targetPort: 80
selector: {}
patches:
- type: FromCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: spec.selector[app]
- type: FromCompositeFieldPath
fromFieldPath: spec.port
toFieldPath: spec.ports[0].port
- type: FromCompositeFieldPath
fromFieldPath: spec.port
toFieldPath: spec.ports[0].targetPort