-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add self-signed certificate init container #108
Conversation
This would be great! After this branch has been rebased and possibly reviewed/merged, then we could use this feature in the zitadel:
configmapConfig:
TLS:
Enabled: true
selfSignedCert:
enabled: true
additionalDnsName: zitadel.example.com My only question is how can we rotate this cert periodically? And is there a way to use cert-manager to do this? Also, if this gets run on every init, and you have multiple pods, wouldn't this overwrite the existing cert, or would it error if there's already a cert there? |
You are partly correct. Setting selfSignedCert.enabled: true will only enable the init container to generate the cert and store it at /etc/tls/tls.crt along with the key file at /etc/tls/tls.key. If you want to use them, then you also need to set your TLS config to use them. E.G.
The cert is valid in the pod for as long as the pod is alive. Once the pod is restarted or deleted and recreated, then the init container runs again and regenerates the certificate. That effectively rotates the certificate and key.
The pods each use their own volume mounts and certificates. They are not shared across pods. There would be no "overwriting", just unique certificate and key for each running pod. |
@PurseChicken you closed the PR. Is it not relevant for you anymore or was there not enough response? Sorry for the delay. |
I inadvertently closed this. Its still relevant and should be re-opened. |
@eliobischof Can you reopen? |
I can't because GitHub says that the fork was deleted (even though I can see the fork exists 🧐). |
Sounds good. Thanks! |
Any update on this? |
@eliobischof bump. Should I just create a new PR? |
If you have the time, I'appreciate it 🙏 |
This has been resubmitted in #140 |
Definition of Ready
This PR adds the ability to enable an init container which will generate and store a self signed certificate for each pod that runs in the replica set.
The certificate is signed with the CN of "zitadel" and contains the following SAN's: localhost, Pod IP Address and Pod Name. Additionally, it can contain one more DNS name, specified in values, which will be added to the SAN.
By default, this is disabled in the values file, but if required can be enabled by setting selfSignedCert.enabled to true. You can add the DNS name you want to add the certificate in selfSignedCert.additionalDnsName. Omit this value if this is not required.
The init container uses a small alpine/openssl image to generate the certificate using the following command:
Enabling selfSignedCert also adds the correct volume and volumeMount for the /etc/tls directory. This is where the tls.crt and tls.key files will be stored. They can then be referenced in zitadel config directly. E.G. KeyPath: /etc/tls/tls.key CertPath: /etc/tls/tls.crt