-
Notifications
You must be signed in to change notification settings - Fork 1
Add TLS support to the Scalar Manager Helm chart #303
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
Open
thongdk8
wants to merge
7
commits into
main
Choose a base branch
from
feat/sm-tls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
28a94de
Add TLS support for scalar manager
thongdk8 cbcbce7
apply suggestion
thongdk8 4eee391
WIP
thongdk8 447071b
Improve chart to support namespace aware config
thongdk8 3398c43
remove trailing space
thongdk8 ea6023b
simplify config
thongdk8 6b27307
formating
thongdk8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
charts/scalar-manager/templates/scalar-manager/certmanager.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| {{- if and .Values.scalarManager.tls.downstream.enabled .Values.scalarManager.tls.certManager.enabled }} | ||
| {{- if .Values.scalarManager.tls.certManager.selfSigned.enabled }} | ||
| --- | ||
| # This issuer is for creating the self-signed CA certificate. | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: {{ include "scalar-manager.fullname" . }}-bootstrap-selfsigned-issuer | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| selfSigned: {} | ||
| --- | ||
| # This is the CA certificate. | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ include "scalar-manager.fullname" . }}-ca-cert | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| isCA: true | ||
| commonName: {{ include "scalar-manager.fullname" . }}-ca | ||
| secretName: {{ include "scalar-manager.fullname" . }}-ca-cert | ||
| duration: {{ .Values.scalarManager.tls.certManager.duration }} | ||
| renewBefore: {{ .Values.scalarManager.tls.certManager.renewBefore }} | ||
| privateKey: | ||
| algorithm: {{ .Values.scalarManager.tls.certManager.privateKey.algorithm }} | ||
| encoding: {{ .Values.scalarManager.tls.certManager.privateKey.encoding }} | ||
| size: {{ .Values.scalarManager.tls.certManager.privateKey.size }} | ||
| issuerRef: | ||
| name: {{ include "scalar-manager.fullname" . }}-bootstrap-selfsigned-issuer | ||
| kind: Issuer | ||
| --- | ||
| # This issuer uses the CA certificate to sign other certificates. | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: {{ include "scalar-manager.fullname" . }}-ca-issuer | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| ca: | ||
| secretName: {{ include "scalar-manager.fullname" . }}-ca-cert | ||
| {{- end }} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ include "scalar-manager.fullname" . }}-tls-cert | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| secretName: {{ include "scalar-manager.fullname" . }}-tls-cert | ||
| commonName: {{ include "scalar-manager.fullname" . }} | ||
| {{- with .Values.scalarManager.tls.certManager.dnsNames }} | ||
| dnsNames: | ||
| {{- range . }} | ||
| - {{ . | quote }} | ||
| {{- end }} | ||
| {{- end }} | ||
| duration: {{ .Values.scalarManager.tls.certManager.duration }} | ||
| renewBefore: {{ .Values.scalarManager.tls.certManager.renewBefore }} | ||
| {{- with .Values.scalarManager.tls.certManager.usages }} | ||
| usages: | ||
| {{- range . }} | ||
| - {{ . | quote }} | ||
| {{- end }} | ||
| {{- end }} | ||
| privateKey: | ||
| algorithm: {{ .Values.scalarManager.tls.certManager.privateKey.algorithm }} | ||
| encoding: {{ .Values.scalarManager.tls.certManager.privateKey.encoding }} | ||
| size: {{ .Values.scalarManager.tls.certManager.privateKey.size }} | ||
| issuerRef: | ||
| {{- if .Values.scalarManager.tls.certManager.selfSigned.enabled }} | ||
| name: {{ include "scalar-manager.fullname" . }}-ca-issuer | ||
| kind: Issuer | ||
| {{- else }} | ||
| {{- if not (len .Values.scalarManager.tls.certManager.issuerRef) }} | ||
| {{- fail "When using cert-manager with an external issuer, scalarManager.tls.certManager.issuerRef must be configured." -}} | ||
| {{- end }} | ||
| {{- toYaml .Values.scalarManager.tls.certManager.issuerRef | nindent 4 }} | ||
| {{- end }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to configure Scalar Manager Web via environment variables because there is no configuration files like
application.properties.However, I think we can configure Scalar Manager API by using
application.properties. And, it seems that there are two ways to configure Scalar Manager API in this update. One is using theapplication.propertiesfile. Another is via environment variables.My concern is that mixing two configuration ways might cause confusion for users. Is it possible to use only one of
application.propertiesor environment variables?Also, we already provide the way to configure Scalar Manager API by using
application.properties. Therefore, to keep backward compatibility and consistency ofHow to configure Scalar Manager API, I think it would be better to use onlyapplication.propertiesinstead of mixing bothapplication.propertiesand environment variables.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the main config for the API is still
application.properties. For the API we add several properties for the TLS in theapplication.properties, and those configs will get the TLS configs from the env by default. If user overrides these configs, then the API will accept the values user enters.This
envpart of the API is for the TLS only as I aimed for one TLS config block in thevaluesfile, and the certs is the same for Scalar Manager API and Web. If we dont do the env mapping here, then users have to configure the TLS separately in theapplication.properties. Also, we still dont expose any env config for the API in values. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one question.
If we don't set
app.tls.inbound.enabled=${APP_TLS_INBOUND_ENABLED}in theapplication.propertiesfile explicitly as follows, and we setscalarManager.tls.downstream.enabled=true, does Scalar Manager API start with TLS enabled configuration?In this case, I think some default configurations like
app.tls.inbound.enabled=${APP_TLS_INBOUND_ENABLED}are not applied because the defaultapplication.propertiesis overwritten by the above user-specifiedapplication.properties. Is my understanding correct?If my understanding is correct, Scalar Manager API does not start with TLS configuration even if we set
scalarManager.tls.downstream.enabled=truebecause there is no configuration about TLS on the overwritten (user-specified)application.propertiesside.That's why I want to ask this question. I'd like to know the behavior of the Scalar Manager API in the above configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is expected behavior.
But based on this situation, I made some updates to simplify the default config. With these updates, the TLS config will automatically be bound to the API via environment variables directly from the TLS config block in the values.yml. So users dont have to set the values in the properties for TLS, except custom values if they want to.
PTAL again when have time and let me know your thoughts