|
17 | 17 | * limitations under the License.
|
18 | 18 | */
|
19 | 19 |
|
20 |
| -local kube = import '../lib/kube.libsonnet'; |
21 |
| -local cert_manager_manifests = import './cert-manager/cert-manager.json'; |
| 20 | +local kube = import "../lib/kube.libsonnet"; |
| 21 | +local CERT_MANAGER_IMAGE = (import "images.json")["cert-manager"]; |
22 | 22 |
|
23 | 23 | {
|
24 |
| - p:: '', |
| 24 | + p:: "", |
25 | 25 | metadata:: {
|
26 | 26 | metadata+: {
|
27 |
| - namespace: 'kubeprod', |
| 27 | + namespace: "kubeprod", |
28 | 28 | },
|
29 | 29 | },
|
30 |
| - letsencrypt_contact_email:: error 'Letsencrypt contact e-mail is undefined', |
| 30 | + letsencrypt_contact_email:: error "Letsencrypt contact e-mail is undefined", |
31 | 31 |
|
32 | 32 | // Letsencrypt environments
|
33 | 33 | letsencrypt_environments:: {
|
34 |
| - prod: $.letsencryptProd.metadata.name, |
35 |
| - staging: $.letsencryptStaging.metadata.name, |
| 34 | + "prod": $.letsencryptProd.metadata.name, |
| 35 | + "staging": $.letsencryptStaging.metadata.name, |
36 | 36 | },
|
37 | 37 | // Letsencrypt environment (defaults to the production one)
|
38 |
| - letsencrypt_environment:: 'prod', |
| 38 | + letsencrypt_environment:: "prod", |
39 | 39 |
|
40 |
| - Issuer(name):: kube._Object('certmanager.k8s.io/v1alpha1', 'Issuer', name) { |
| 40 | + Issuer(name):: kube._Object("certmanager.k8s.io/v1alpha1", "Issuer", name) { |
41 | 41 | },
|
42 | 42 |
|
43 |
| - ClusterIssuer(name):: kube._Object('certmanager.k8s.io/v1alpha1', 'ClusterIssuer', name) { |
| 43 | + ClusterIssuer(name):: kube._Object("certmanager.k8s.io/v1alpha1", "ClusterIssuer", name) { |
44 | 44 | },
|
45 | 45 |
|
46 |
| - certCRD: kube.CustomResourceDefinition('certmanager.k8s.io', 'v1alpha1', 'Certificate') { |
47 |
| - spec+: { names+: { shortNames+: ['cert', 'certs'] } }, |
| 46 | + certCRD: kube.CustomResourceDefinition("certmanager.k8s.io", "v1alpha1", "Certificate") { |
| 47 | + spec+: { names+: { shortNames+: ["cert", "certs"] } }, |
| 48 | + |
48 | 49 | },
|
49 | 50 |
|
50 |
| - deploy: cert_manager_manifests, |
| 51 | + issuerCRD: kube.CustomResourceDefinition("certmanager.k8s.io", "v1alpha1", "Issuer"), |
| 52 | + |
| 53 | + clusterissuerCRD: kube.CustomResourceDefinition("certmanager.k8s.io", "v1alpha1", "ClusterIssuer") { |
| 54 | + spec+: { |
| 55 | + scope: "Cluster", |
| 56 | + }, |
| 57 | + }, |
51 | 58 |
|
52 |
| - letsencryptStaging: $.ClusterIssuer($.p + 'letsencrypt-staging') { |
| 59 | + sa: kube.ServiceAccount($.p + "cert-manager") + $.metadata { |
| 60 | + }, |
| 61 | + |
| 62 | + clusterRole: kube.ClusterRole($.p + "cert-manager") { |
| 63 | + rules: [ |
| 64 | + { |
| 65 | + apiGroups: ["certmanager.k8s.io"], |
| 66 | + resources: ["certificates", "issuers", "clusterissuers"], |
| 67 | + // FIXME: audit - the helm chart just has "*" |
| 68 | + verbs: ["get", "list", "watch", "create", "patch", "update", "delete"], |
| 69 | + }, |
| 70 | + { |
| 71 | + apiGroups: [""], |
| 72 | + resources: ["secrets", "configmaps", "services", "pods"], |
| 73 | + // FIXME: audit - the helm chart just has "*" |
| 74 | + verbs: ["get", "list", "watch", "create", "patch", "update", "delete"], |
| 75 | + }, |
| 76 | + { |
| 77 | + apiGroups: ["extensions"], |
| 78 | + resources: ["ingresses"], |
| 79 | + // FIXME: audit - the helm chart just has "*" |
| 80 | + verbs: ["get", "list", "watch", "create", "patch", "update", "delete"], |
| 81 | + }, |
| 82 | + { |
| 83 | + apiGroups: [""], |
| 84 | + resources: ["events"], |
| 85 | + verbs: ["create", "patch", "update"], |
| 86 | + }, |
| 87 | + ], |
| 88 | + }, |
| 89 | + |
| 90 | + clusterRoleBinding: kube.ClusterRoleBinding($.p+"cert-manager") { |
| 91 | + roleRef_: $.clusterRole, |
| 92 | + subjects_+: [$.sa], |
| 93 | + }, |
| 94 | + |
| 95 | + deploy: kube.Deployment($.p+"cert-manager") + $.metadata { |
| 96 | + spec+: { |
| 97 | + template+: { |
| 98 | + metadata+: { |
| 99 | + annotations+: { |
| 100 | + "prometheus.io/scrape": "true", |
| 101 | + "prometheus.io/port": "9402", |
| 102 | + "prometheus.io/path": "/metrics", |
| 103 | + }, |
| 104 | + }, |
| 105 | + spec+: { |
| 106 | + serviceAccountName: $.sa.metadata.name, |
| 107 | + containers_+: { |
| 108 | + default: kube.Container("cert-manager") { |
| 109 | + image: CERT_MANAGER_IMAGE, |
| 110 | + args_+: { |
| 111 | + "cluster-resource-namespace": "$(POD_NAMESPACE)", |
| 112 | + "leader-election-namespace": "$(POD_NAMESPACE)", |
| 113 | + "default-issuer-name": $.letsencrypt_environments[$.letsencrypt_environment], |
| 114 | + "default-issuer-kind": "ClusterIssuer", |
| 115 | + }, |
| 116 | + env_+: { |
| 117 | + POD_NAMESPACE: kube.FieldRef("metadata.namespace"), |
| 118 | + }, |
| 119 | + ports_+: { |
| 120 | + prometheus: {containerPort: 9402}, |
| 121 | + }, |
| 122 | + resources: { |
| 123 | + requests: {cpu: "10m", memory: "32Mi"}, |
| 124 | + }, |
| 125 | + }, |
| 126 | + }, |
| 127 | + }, |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | + |
| 132 | + letsencryptStaging: $.ClusterIssuer($.p+"letsencrypt-staging") { |
53 | 133 | local this = self,
|
54 | 134 | spec+: {
|
55 | 135 | acme+: {
|
56 |
| - server: 'https://acme-staging-v02.api.letsencrypt.org/directory', |
| 136 | + server: "https://acme-staging-v02.api.letsencrypt.org/directory", |
57 | 137 | email: $.letsencrypt_contact_email,
|
58 |
| - privateKeySecretRef: { name: this.metadata.name }, |
| 138 | + privateKeySecretRef: {name: this.metadata.name}, |
59 | 139 | http01: {},
|
60 | 140 | },
|
61 | 141 | },
|
62 | 142 | },
|
63 | 143 |
|
64 | 144 | letsencryptProd: $.letsencryptStaging {
|
65 |
| - metadata+: { name: $.p + 'letsencrypt-prod' }, |
| 145 | + metadata+: {name: $.p+"letsencrypt-prod"}, |
66 | 146 | spec+: {
|
67 | 147 | acme+: {
|
68 |
| - server: 'https://acme-v02.api.letsencrypt.org/directory', |
| 148 | + server: "https://acme-v02.api.letsencrypt.org/directory", |
69 | 149 | },
|
70 | 150 | },
|
71 | 151 | },
|
72 |
| - |
73 |
| - solvers+:: [], |
74 | 152 | }
|
0 commit comments