-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrenderMutatingWebhook.dhall
177 lines (166 loc) · 6.23 KB
/
renderMutatingWebhook.dhall
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
let k8s =
../k8s/1.15.dhall sha256:9ed8981915875f3bbe08ad7047d92cd181b6ece140af876beecadb8ed079e10a
? ../k8s/1.15.dhall
let cert-manager =
../cert-manager/package.dhall sha256:1640fd5080778e8e9f565cf5790efe18ba9aa57599248b3c75425825be4ef739
? ../cert-manager/package.dhall
let certsPath = "/certs"
let Webhook =
./Type.dhall sha256:a71ac5b5469ecd2b6823ef59404fdf2878a24138028baa1697a3deadc8e9be73
? ./Type.dhall
let labels =
./labels.dhall sha256:1cf6971c63fef213125cc10c5ecf5c32df954da0e186943693994121485f67e1
? ./labels.dhall
let deployment =
\(webhook : Webhook)
-> k8s.Deployment::{
, metadata = k8s.ObjectMeta::{ name = Some webhook.name }
, spec = Some k8s.DeploymentSpec::{
, selector = k8s.LabelSelector::{
, matchLabels = Some (labels webhook)
}
, template = k8s.PodTemplateSpec::{
, metadata = Some k8s.ObjectMeta::{
, name = Some webhook.name
, labels = Some (labels webhook)
}
, spec = Some k8s.PodSpec::{
, containers =
[ k8s.Container::{
, name = webhook.name
, image = Some webhook.imageName
, ports = Some
[ k8s.ContainerPort::{
, containerPort = Natural/toInteger webhook.port
}
]
, env = Some
[ k8s.EnvVar::{
, name = "CERTIFICATE_FILE"
, value = Some "${certsPath}/tls.crt"
}
, k8s.EnvVar::{
, name = "KEY_FILE"
, value = Some "${certsPath}/tls.key"
}
, k8s.EnvVar::{
, name = "PORT"
, value = Some (Natural/show webhook.port)
}
]
, volumeMounts = Some
[ k8s.VolumeMount::{
, name = "certs"
, mountPath = certsPath
, readOnly = Some True
}
]
}
]
, volumes = Some
[ k8s.Volume::{
, name = "certs"
, secret = Some k8s.SecretVolumeSource::{
, secretName = Some webhook.name
}
}
]
}
}
}
}
let service =
\(webhook : Webhook)
-> k8s.Service::{
, metadata = k8s.ObjectMeta::{ name = Some webhook.name }
, spec = Some k8s.ServiceSpec::{
, selector = Some (labels webhook)
, ports = Some
[ k8s.ServicePort::{
, targetPort = Some
(k8s.IntOrString.Int (Natural/toInteger webhook.port))
, port = Natural/toInteger 443
}
]
}
}
let issuer =
\(webhook : Webhook)
-> cert-manager.Issuer::{
, metadata = k8s.ObjectMeta::{ name = Some webhook.name }
, spec =
cert-manager.IssuerSpec.SelfSigned
cert-manager.SelfSignedIssuerSpec::{=}
}
let certificate =
\(webhook : Webhook)
-> cert-manager.Certificate::{
, metadata = k8s.ObjectMeta::{ name = Some webhook.name }
, spec = cert-manager.CertificateSpec::{
, secretName = webhook.name
, issuerRef = { name = webhook.name, kind = (issuer webhook).kind }
, commonName = Some "${webhook.name}.${webhook.namespace}.svc"
, dnsNames = Some
[ webhook.name
, "${webhook.name}.${webhook.namespace}"
, "${webhook.name}.${webhook.namespace}.svc"
, "${webhook.name}.${webhook.namespace}.svc.cluster.local"
, "${webhook.name}:443"
, "${webhook.name}.${webhook.namespace}:443"
, "${webhook.name}.${webhook.namespace}.svc:443"
, "${webhook.name}.${webhook.namespace}.svc.cluster.local:443"
, "localhost:8080"
]
, usages = Some [ "any" ]
, isCA = Some False
}
}
let mutatingWebhookConfiguration =
\(webhook : Webhook)
-> k8s.MutatingWebhookConfiguration::{
, metadata = k8s.ObjectMeta::{
, name = Some webhook.name
, labels = Some (labels webhook)
, annotations = Some
( toMap
{ `cert-manager.io/inject-ca-from` =
"${webhook.namespace}/${webhook.name}"
}
)
}
, webhooks = Some
[ k8s.MutatingWebhook::{
, name = "${webhook.name}.${webhook.namespace}.svc"
, clientConfig = k8s.WebhookClientConfig::{
, service = Some
{ name = webhook.name
, namespace = webhook.namespace
, path = Some webhook.path
, port = Some (Natural/toInteger 443)
}
}
, failurePolicy = webhook.failurePolicy
, admissionReviewVersions = Some [ "v1beta1" ]
, rules = Some webhook.rules
, namespaceSelector = webhook.namespaceSelector
}
]
}
let union =
< Deployment : k8s.Deployment.Type
| Service : k8s.Service.Type
| MWH : k8s.MutatingWebhookConfiguration.Type
| Certificate : cert-manager.Certificate.Type
| ClusterIssuer : cert-manager.ClusterIssuer.Type
>
in \(webhook : Webhook)
-> { apiVersion = "v1"
, kind = "List"
, items =
[ union.Deployment (deployment webhook)
, union.Service (service webhook)
, union.MWH (mutatingWebhookConfiguration webhook)
, union.Certificate (certificate webhook)
, union.ClusterIssuer (issuer webhook)
]
}