Skip to content

Commit b4b3b22

Browse files
committed
Add docu for certificate regeneration job
* and rename Terragrunt file so that the module is not part of the default stack
1 parent 3f0b753 commit b4b3b22

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

docs/concourse/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,6 @@ Please see [DR scenario](disaster_recovery.md) for a fully automated recovery pr
252252

253253
## Automated secrets rotation for CloudSQL
254254
Please see [Secrets Rotation](secrets_rotation.md)
255+
256+
## Automated regeneration for certificates stored in CredHub
257+
Please see [Certificate Regeneration](certificate_regeneration.md)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Automated certificate regeneration
2+
3+
You can deploy a K8s CronJob to automatically regenerate certificates which are stored in CredHub. A typical example are load balancer certificates used in a bosh-bootloader environment. The CronJob calls `credhub regenerate <certificate name>`. This will extend the certificate's validity while all other properties remain unchanged.
4+
5+
The automated regeneration is provided as separate Terragrunt module which must be deployed separately to enable the feature.
6+
7+
## Prerequisites
8+
9+
The certificate's CA must be stored in CredHub, and they must be correctly linked.
10+
11+
## Configuration and deployment
12+
13+
First, configure the list of certificates in your local `config.yaml`. Define one string with comma-separated certificate names, e.g.:
14+
```
15+
certificates_to_regenerate: "/concourse/main/cert_1,/concourse/main/cert_2"
16+
```
17+
18+
Next, change to the directory `terragrunt/<concourse-instance>/automatic_certificate_regeneration` and call
19+
```
20+
terragrunt apply --terragrunt-config cert_regen.hcl
21+
```
22+
You should see that Terraform creates a new resource:
23+
```
24+
resource "kubernetes_cron_job_v1" "automatic_certificate_regeneration"
25+
(...)
26+
```
27+
Confirm with `yes`. Afterward, you can see a new CronJob in your K8s deployment:
28+
```
29+
$ kubectl -n concourse get cronjobs
30+
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
31+
certificate-regeneration @monthly False 0 <none> 50m
32+
```
33+
To test the CronJob, you can invoke it explicitly and check the logs:
34+
```
35+
kubectl -n concourse create job --from=cronjob/certificate-regeneration cert-regen-job
36+
# wait a few seconds
37+
kubectl -n concourse get pods # search pod "cert-regen-job-<xyz>"
38+
kubectl -n concourse logs cert-regen-job-<xyz>
39+
```
40+
You should see the output from CredHub:
41+
```
42+
id: 68875a90-c1b7-4391-a2af-bd3a8f33ce47
43+
name: /concourse/main/cert_1
44+
type: certificate
45+
value: <redacted>
46+
version_created_at: "2024-05-07T12:23:43Z"
47+
(...)
48+
```
49+
50+
## Deletion
51+
52+
To delete the CronJob, change to the directory `terragrunt/<concourse-instance>/automatic_certificate_regeneration` and call
53+
```
54+
terragrunt destroy --terragrunt-config cert_regen.hcl
55+
```

0 commit comments

Comments
 (0)