-
Notifications
You must be signed in to change notification settings - Fork 97
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
THREESCALE-11156 add tls env var to zync and system deployments #1026
base: master
Are you sure you want to change the base?
Conversation
5417862
to
906d087
Compare
58f5423
to
cec4cf1
Compare
694a709
to
7646db2
Compare
/test test-e2e |
52d6f47
to
de4820b
Compare
/test test-e2e |
8c46579
to
f626b13
Compare
f626b13
to
812d331
Compare
bc1e44b
to
a5fd165
Compare
a5fd165
to
f0af6cb
Compare
f0af6cb
to
d7eecd7
Compare
THREESCALE-11156 add volume mounts for secrets THREESCALE-11156 fix default internal to work without tls THREESCALE-11156 set cert permissions THREESCALE-11156 add apimanger flags for TLS THREESCALE-11156 fix e2e THREESCALE-11156 add Database TLS doc THREESCALE-11156 add watchby logic THREESCALE-11156 removed internal database changes
d7eecd7
to
247a2e0
Compare
helper.EnvVarFromSecretOptional("DB_SSL_CERT", SystemSecretSystemDatabaseSecretName, SystemSecretSslCert), | ||
helper.EnvVarFromSecretOptional("DB_SSL_KEY", SystemSecretSystemDatabaseSecretName, SystemSecretSslKey), | ||
helper.EnvVarFromSecretOptional("DATABASE_SSL_MODE", SystemSecretSystemDatabaseSecretName, SystemSecretDatabaseSslMode), | ||
helper.EnvVarFromValue("DATABASE_SSL_CA", helper.TlsCertPresent("DATABASE_SSL_CA", SystemSecretSystemDatabaseSecretName, system.Options.SystemDbTLSEnabled)), |
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.
as discussed, let's move the creation of empty keys + validation of keys + validation of values here: https://github.com/3scale/3scale-operator/blob/master/pkg/3scale/amp/operator/highavailability_options_provider.go#L29
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.
Agree its better if the reconciler catches this.
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 the secret validation should check if the secret values are populated in the highavailability reconcile and populate with an empty string if not set and return an error.
Two things here
- It doesn't look like highavailability_options_provider GetHighAvailabilityOptions() handles zync database at the moment (maybe because spec.highavaibility is deprecated). Can add the functionally but am now doubting this is the correct place to do so.
- And may still leave the helper to populate the env vars that are not available in the secret .
i.e. the env vars in the secret have actual certs where as the env var that are used have paths to certs
MountPath: "/var/lib/searchd", | ||
}, | ||
}, | ||
//Env: s.commonSearchdEnvVars(), |
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.
is this required
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.
Think it was commented during some debugging . So I would say its required.
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.
having reviewed its not required.
doc/apimanager-reference.md
Outdated
@@ -338,6 +338,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | |||
| MemcachedPriorityClassName | `memcachedPriorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | |||
| MemcachedTopologySpreadConstraints | `memcachedTopologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | |||
| MemcachedLabels | `memcachedLabels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | | |||
| SystemDatabaseTLSEnabled | `systemDatabaseTLSEnabled`| bool | No | false | Use external databases only | |
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.
Use external databases only - is that correct?
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.
fair point we are only using external from now on.
@@ -528,6 +529,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | |||
| DatabaseTopologySpreadConstraints | `databaseTopologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | |||
| DatabaseLabels | `databaseLabels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | | |||
| DatabaseAnnotations | `databaseAnnotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | | |||
| ZyncDatabaseTLSEnabled | `zyncDatabaseTLSEnabled`| bool | No | false | Use external databases only | |
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.
Use external databases only - is that correct? Should we mention here what the TLSEnabled is doing rather than what it should be used with?
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.
agree
doc/apimanager-reference.md
Outdated
| DATABASE_SSL_MODE | [Database SSL Mode](https://github.com/brianmario/mysql2?tab=readme-ov-file#ssltls-options) | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CA | SSL CA certificate | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CERT | SSL CERT certificate | Required to set TLS Database connection. Only for TLS | | ||
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
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.
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | | |
| DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
doc/apimanager-reference.md
Outdated
| DATABASE_SSL_MODE | [Database SSL Mode](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CA | SSL CA certificate | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CERT | SSL CERT certificate | Required to set TLS Database connection. Only for TLS | | ||
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
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.
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | | |
| DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
doc/apimanager-reference.md
Outdated
| DATABASE_SSL_MODE | [Database SSL Mode](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CA | SSL CA certificate | Required to set TLS Database connection. Only for TLS | | ||
| DB_SSL_CERT | SSL CERT certificate | Required to set TLS Database connection. Only for TLS | | ||
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
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.
DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | | |
| DB_SSL_KEY | SSL Key | Required to set TLS Database connection. Only for TLS | |
doc/operator-user-guide.md
Outdated
|
||
It is possible to connect to both the system-database and zync database via TLS provided these databases have TLS enabled. To enable TLS communication to these databases you will need to configure the ApiManager and the database secret. | ||
|
||
In ApiManager CR we set the boolean to enable TLS configuration for the respictive databases |
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.
In ApiManager CR we set the boolean to enable TLS configuration for the respictive databases | |
In ApiManager CR set the boolean to enable TLS configuration for the respective databases |
doc/operator-user-guide.md
Outdated
- `spec.zync.zyncDatabaseTLSEnabled: true` | ||
- `spec.system.systemDatabaseTLSEnabled: true` | ||
|
||
We pass the cert files in via the respective secret i.e. system-database & zync |
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.
We pass the cert files in via the respective secret i.e. system-database & zync | |
Pass the cert files in via the respective secret i.e. system-database & zync |
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.
Or, the operator passes the cert files to the respective deployments via the database secrets i.e. system-database & zync
--from-literal=DATABASE_URL=postgresql://postgres:[email protected]/zync_production \ | ||
--from-literal=ZYNC_DATABASE_PASSWORD=password \ | ||
--from-file=DB_SSL_CA=rootCA.crt \ | ||
--from-file=DB_SSL_CERT=client.crt \ |
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 was getting the following error in the operator:
Secret field 'DATABASE_SSL_CERT' is required in secret 'system-database'
I think the ha filter needs some tidying up. 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.
Yea probably using the wrong variable in the error.
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.
yep https://github.com/3scale/3scale-operator/pull/1026/files#diff-e194f3db6df5c75dc590ada2df59ed3728f3a3bd3af55478cee45bd02d28d573R240-R242
they are pointing at the wrong variable .
@@ -768,6 +768,22 @@ func (r *ApicastReconciler) getSecretUIDs(ctx context.Context) (map[string]strin | |||
} | |||
} | |||
|
|||
// system-database | |||
|
|||
if r.apiManager.IsSystemDatabaseTLSEnabled() { |
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.
All of the above seems apicast related only, why have the system/zync db TLS stuff in this file?
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.
Just following the add watch secret user guide https://github.com/3scale/3scale-operator/blob/master/doc/development.md#adding-new-watched-secrets . Mentioned it to Carl at the time. Seemed happy for it to live here.
|
||
// Check if SSL_KEY, SSL_CERT, and SSL_CA are empty | ||
// checks the cert is populated in the secret, if so populates the path in the volume mount | ||
if sslCert, ok := secret.Data[sslEnvVar]; ok && len(sslCert) > 0 && databaseTLSEnabled { |
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.
so we are only setting paths if the value is non-empty - and when it is empty, we are returning "".
In case of having 2/3 created successfully (with values) - am I understanding it correctly that we are still going to just mount them, with 2/3 having the right values and 1/3 having empty string as value?
If so, the TLS validation will fail on the component level anyway so I'm trying to understand what is the benefit of doing this check and if it would be better to do it earlier (at ha level), keys exist + values are non-empty = add to volume for component validation of TLS, if keys exist + values are empty - do not even attempt to mount since we know this is going to be incorrect?
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.
No Mounts will have been created already with the cert values from the secret.
This called when we are creating the env var , so believe it is the correct place to set them as they don't exist prior to this. System and Zync can only consume the path to the cert and not the cert itself.
The flow secret has the cert, those certs gets mounted , we then create env var that have the path to the mounted cert. These env var are what is used by system and zync to connect to the db with TLS.
As for the empty value check this will be caught In the HA reconciller so may be redundant to have the check here. But it causes no harm
2888a5b
to
efc2e6f
Compare
…and add reconciler check for empty values
efc2e6f
to
584847e
Compare
Looks good but just few more concerns:
Point 3/4 might be evaluated by preflights for fresh installs but for on-going, I think we need the follow ups created. |
Command: []string{ | ||
"bash", | ||
"-c", | ||
"bundle exec sh -c \"until rake boot:redis && curl --insecure --output /dev/null --silent --fail --head http://system-master:3000/status; do sleep $SLEEP_SECONDS; done\"", |
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.
why are we adding the --insecure here? It seems to be working fine without it...but maybe I'm doing something wrong,.
Command: []string{ | ||
"bash", | ||
"-c", | ||
"bundle exec sh -c \"until rake boot:redis && curl --insecure --output /dev/null --silent --fail --head http://system-master:3000/status; do sleep $SLEEP_SECONDS; done\"", |
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.
same as above
Issue
THREESCALE-11156
What
Add database client side tls to 3scale
Verification
DATABASE_SSL_MODE=disable