|
| 1 | +# Kube Cert ACM |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +Automatically synchronize [cert-manager](https://github.com/cert-manager/cert-manager) generated Certificates to [AWS Certificate Manager](https://aws.amazon.com/certificate-manager/) from your Kubernetes cluster. |
| 6 | + |
| 7 | + |
| 8 | +## How does it work |
| 9 | + |
| 10 | +kube-cert-acm is a chart that creates a Deployment in your Kubernetes cluster. |
| 11 | + |
| 12 | +It reads its configuration from a config file that is mounted from a ConfigMap. The ConfigMap lists the certificates to be imported from the cluster to ACM. |
| 13 | + |
| 14 | +It gets these Certificates on a regular basis, and if different from the ones on ACM, updates them on AWS. The check interval is configured on the Helm chart. |
| 15 | + |
| 16 | +These certificates are supposed to be generated by cert-manager and are defined in a Certificate CRD. |
| 17 | + |
| 18 | + |
| 19 | +This chart has been tested on an EKS cluster for the following Kubernetes versions: |
| 20 | + |
| 21 | +- Kubernetes 1.21 ✅ |
| 22 | +- Kubernetes 1.22 ✅ |
| 23 | +- Kubernetes 1.23 ✅ |
| 24 | +- Kubernetes 1.24 ✅ |
| 25 | +- Kubernetes 1.25 ✅ |
| 26 | + |
| 27 | +It has also been tested with certificates generated with the following versions of cert-manager charts: |
| 28 | + |
| 29 | +- cert-manager 1.9.1 ✅ |
| 30 | +- cert-manager 1.9.2 ✅ |
| 31 | +- cert-manager 1.10.0 ✅ |
| 32 | +- cert-manager 1.11.0 ✅ |
| 33 | + |
| 34 | +It has been tested for Let's Encrypt certificates generated using cert-manager. |
| 35 | + |
| 36 | +# Installation |
| 37 | + |
| 38 | +kube-cert-acm can be installed using the official helm chart: |
| 39 | + |
| 40 | +**TODO**: Add helm Repo |
| 41 | + |
| 42 | +```bash |
| 43 | +helm install kube-cert-acm <repo>/kube-cert-acm --set aws.region="<AWS_REGION>" \ |
| 44 | + --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn="arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>" \ |
| 45 | + -f values.yaml |
| 46 | + |
| 47 | +``` |
| 48 | + |
| 49 | +The values will contain for example the list of certificates to by imported to ACM. Details on the next section |
| 50 | + |
| 51 | +# Configuration |
| 52 | + |
| 53 | +### Certificates Configuration |
| 54 | + |
| 55 | +The pod takes its configuration from a ConfigMap that is supposed to list all the certificates to be watched and synced. The ConfigMap is provided to the chart via the key `certificatesConfig` |
| 56 | + |
| 57 | +The list of Certificates to be synchronized is provided via a config file to the Chart. |
| 58 | + |
| 59 | +Example: |
| 60 | + |
| 61 | +```yaml |
| 62 | +certificatesConfig: |
| 63 | + certificates_config.yaml: | |
| 64 | + - cert: podinfo.dev.softcloudhq.io |
| 65 | + namespace: test |
| 66 | + domain_name: "podinfo.dev.softcloudhq.io" |
| 67 | + - cert: podinfo.demo.softcloudhq.io |
| 68 | + namespace: demo |
| 69 | + domain_name: "podinfo.demo.softcloudhq.io" |
| 70 | +
|
| 71 | +``` |
| 72 | +
|
| 73 | +### Other configurations |
| 74 | +
|
| 75 | +The check interval is configured via the key `checkIntervalSeconds` : |
| 76 | + |
| 77 | +```yaml |
| 78 | +
|
| 79 | +checkIntervalSeconds: "30" |
| 80 | +
|
| 81 | +``` |
| 82 | + |
| 83 | +## RBAC Configuration |
| 84 | + |
| 85 | +The helm chart configures a Cluster Role for kube-cert-acm in order to be able to read Certificates and Secrets from different namespaces in the cluster. |
| 86 | + |
| 87 | +The rule to get **Certificates**: |
| 88 | + |
| 89 | +```yaml |
| 90 | +- apiGroups: ["cert-manager.io"] |
| 91 | + resources: ["certificates"] |
| 92 | + verbs: ["get"] |
| 93 | +
|
| 94 | +``` |
| 95 | + |
| 96 | +A rule to get the **Secret** containing the actual certificate and private key: |
| 97 | + |
| 98 | +```yaml |
| 99 | +- apiGroups: [""] |
| 100 | + resources: ["secrets"] |
| 101 | + verbs: ["get"] |
| 102 | +
|
| 103 | +``` |
| 104 | + |
| 105 | +## IAM Role Configuration |
| 106 | + |
| 107 | +kube-cert-acm needs to access AWS ACM to import Certificates. It is recommended to use a dedicated IAM role specifically for this task that only allows the required actions. |
| 108 | + |
| 109 | +kube-cert-acm requires the following actions to synchronise certificates to ACM. The following policy is to be attached to the kube-cert-acm IAM role: |
| 110 | + |
| 111 | +```json |
| 112 | +{ |
| 113 | + "Statement": [ |
| 114 | + { |
| 115 | + "Action": "sts:AssumeRole", |
| 116 | + "Effect": "Allow", |
| 117 | + "Resource": "*", |
| 118 | + "Sid": "" |
| 119 | + }, |
| 120 | + { |
| 121 | + "Action": "acm:ListCertificates", |
| 122 | + "Effect": "Allow", |
| 123 | + "Resource": "*", |
| 124 | + "Sid": "" |
| 125 | + }, |
| 126 | + { |
| 127 | + "Action": [ |
| 128 | + "acm:UpdateCertificateOptions", |
| 129 | + "acm:ListTagsForCertificate", |
| 130 | + "acm:ImportCertificate", |
| 131 | + "acm:GetCertificate", |
| 132 | + "acm:ExportCertificate", |
| 133 | + "acm:DescribeCertificate", |
| 134 | + "acm:AddTagsToCertificate" |
| 135 | + ], |
| 136 | + "Effect": "Allow", |
| 137 | + "Resource": "arn:aws:acm:<AWS_REGION>:<AWS_ACCOUNT_ID>:certificate/*", |
| 138 | + "Sid": "" |
| 139 | + } |
| 140 | + ], |
| 141 | + "Version": "2012-10-17" |
| 142 | +} |
| 143 | +
|
| 144 | +``` |
| 145 | + |
| 146 | +The Helm chart suppose IRSA is used and expects the Service Account to be annotated with the required IAM role. More details on IRSA on the [official documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html). |
| 147 | + |
| 148 | +# Roadmap |
| 149 | + |
| 150 | +- [ ] Do not rely only on Certificates generated by cert-manager. Support importing certificates from Kubernetes Secrets generally |
| 151 | +- [ ] Provide more flexible configuration to import certificates to different AWS regions |
| 152 | +- [ ] Support configuration through annotations on Kubernetes Secrets, without needing a ConfigMap |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | +# Contribution |
| 157 | + |
| 158 | +This project has been built to fit a specific need: import a list of certificates from Kubernetes to ACM. A lot of work is still to be done to make it fit other use cases. |
| 159 | + |
| 160 | +Contributions are highly appreciated. |
| 161 | + |
| 162 | +To contribute: |
| 163 | + |
| 164 | +- Fork the project |
| 165 | +- Create a branch |
| 166 | +- Make your contribution |
| 167 | +- Open a Pull Request |
0 commit comments