-
Notifications
You must be signed in to change notification settings - Fork 107
CA Paths Fixes #1570
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
CA Paths Fixes #1570
Conversation
Additional Testing Instructions:The tests were done on the code changes in version 5.17. 1) Code change - path of certIn Explanation:
noobaa-operator/pkg/system/phase2_creating.go Lines 467 to 468 in 3f43b19
(in the endpoint pod) noobaa-operator/pkg/system/phase4_configuring.go Lines 407 to 408 in 3f43b19
and r.ApplyCAsToPods is assigned after:noobaa-operator/pkg/system/reconciler.go Lines 407 to 414 in 3f43b19
but in the function AddToRootCAs the hard-coded path does not exist in the operator pod:noobaa-operator/pkg/util/util.go Lines 151 to 154 in 3f43b19
Before code changes:In version 4.17 I run:
total 904
drwxr-xr-x. 3 root root 123 Sep 18 2024 .
drwxr-xr-x. 6 root root 70 Sep 18 2024 ..
-rw-r--r--. 1 root root 898 Aug 19 2024 README
dr-xr-xr-x. 2 root root 16384 Sep 18 2024 directory-hash
-r--r--r--. 1 root root 165521 Sep 18 2024 email-ca-bundle.pem
-r--r--r--. 1 root root 502506 Sep 18 2024 objsign-ca-bundle.pem
-r--r--r--. 1 root root 226489 Sep 18 2024 tls-ca-bundle.pem
ls: cannot access '/etc/ocp-injected-ca-bundle.crt': No such file or directory
total 0
drwxrwsrwx. 3 root 1000710000 81 Mar 24 10:06 .
drwxr-xr-x. 1 root root 36 Mar 24 10:06 ..
drwxr-sr-x. 2 root 1000710000 27 Mar 24 10:06 ..2025_03_24_10_06_38.1871780206
lrwxrwxrwx. 1 root 1000710000 32 Mar 24 10:06 ..data -> ..2025_03_24_10_06_38.1871780206
lrwxrwxrwx. 1 root 1000710000 20 Mar 24 10:06 ca-bundle.crt -> ..data/ca-bundle.crt
lrwxrwxrwx. 1 root 1000710000 20 Mar 24 10:06 /etc/ocp-injected-ca-bundle/ca-bundle.crt -> ..data/ca-bundle.crt After code changes:We can see the printing in the operator logs: time="2025-03-31T07:35:22Z" level=info msg="Successfuly appended \"/etc/ocp-injected-ca-bundle/ca-bundle.crt\" to RootCAs"
time="2025-03-31T07:35:22Z" level=info msg="Successfuly appended \"/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt\" to RootCAs" 2) Code change - rename the r.CaBundleConf.NameIn since noobaa-operator/pkg/system/reconciler.go Line 190 in 3f43b19
and the name is: "ocp-injected-ca-bundle" noobaa-operator/pkg/bundle/deploy.go Lines 3918 to 3925 in 3f43b19
and it doesn't match: noobaa-operator/pkg/system/reconciler.go Line 285 in 3f43b19
Therefore, whenever we check the name (for example): noobaa-operator/pkg/system/phase2_creating.go Line 544 in 3f43b19
it will not find it. After code changes:I added printing to validate that the value is true, for example (in r.Logger.Info("SDSD in SetDesiredCoreApp - case core")
r.Logger.Info("SDSD r.CaBundleConf.Name ", r.CaBundleConf.Name)
myCheck := util.KubeCheckQuiet(r.CaBundleConf)
r.Logger.Info("SDSD myCheck in SetDesiredCoreApp - case core util.KubeCheckQuiet(r.CaBundleConf) ", myCheck) We can see the printing in the operator logs:
Note: all cases were 3) Code change - mount path of directory (don't show file extension)In pkg/system/phase2_creating.go and pkg/system/phase4_configuring.go - the core and the endpoint change the mount path from /etc/ocp-injected-ca-bundle.crt (with file extension) to a directory (remove the extension). seems like a file (extension): noobaa-operator/pkg/system/phase2_creating.go Line 547 in 3f43b19
It was (directory level - no extension): noobaa-operator/pkg/system/phase2_creating.go Line 493 in 2c86789
Therefore, it is suggested to remove the file extension. Before code changes:
total 904
drwxrwxr-x. 1 root root 123 Oct 24 12:50 .
drwxrwxr-x. 1 root root 70 Oct 24 12:50 ..
-rw-rw-r--. 1 root root 898 Aug 19 2024 README
dr-xr-xr-x. 1 root root 16384 Oct 24 12:50 directory-hash
-r--r--r--. 1 root root 165521 Oct 24 12:50 email-ca-bundle.pem
-r--r--r--. 1 root root 502506 Oct 24 12:50 objsign-ca-bundle.pem
-r--r--r--. 1 root root 226489 Oct 24 12:50 tls-ca-bundle.pem
sh-5.1# ls -al /etc/ocp-injected-ca-bundle
ls: cannot access '/etc/ocp-injected-ca-bundle': No such file or directory In the operator yaml we have the configmap property: noobaa-operator/deploy/operator.yaml Lines 34 to 40 in 3f43b19
but we don't have this either in the endpoint deployment or the core statefulset: After code changes:
total 0
drwxrwsrwx. 3 root 1000710000 80 Mar 31 07:25 .
drwxrwxr-x. 1 root root 136 Mar 31 07:25 ..
drwxr-sr-x. 2 root 1000710000 27 Mar 31 07:25 ..2025_03_31_07_25_58.320495734
lrwxrwxrwx. 1 root 1000710000 31 Mar 31 07:25 ..data -> ..2025_03_31_07_25_58.320495734
lrwxrwxrwx. 1 root 1000710000 20 Mar 31 07:25 ca-bundle.crt -> ..data/ca-bundle.crt
4) Code change - path of certRename Explanation:
noobaa-operator/pkg/system/phase2_creating.go Lines 467 to 468 in 3f43b19
(in the endpoint pod) noobaa-operator/pkg/system/phase4_configuring.go Lines 407 to 408 in 3f43b19
and r.ApplyCAsToPods is assigned after:noobaa-operator/pkg/system/reconciler.go Lines 408 to 414 in 3f43b19
now we added the constant, and the env Before code changes:
After code changes:
Defaulted container "core" out of: core, noobaa-log-processor
NODE_EXTRA_CA_CERTS=/etc/ocp-injected-ca-bundle/ca-bundle.crt
NODE_EXTRA_CA_CERTS=/etc/ocp-injected-ca-bundle/ca-bundle.crt 5) Code change - Change the condition existence of the config map of the CA (
|
47a7b8c
to
1ccce7a
Compare
6af0112
to
c671827
Compare
…ndle/ca-bundle.crt (tested on operator pod) Signed-off-by: shirady <[email protected]>
…-injected-ca-bundle" to align with the rename of configmap-ca-inject.yaml from noobaa-ca-inject to ocp-injected-ca-bundle in PR 1328 Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
…CertCAFile which is /etc/ocp-injected-ca-bundle/ca-bundle.crt + assign r.ApplyCAsToPods to be the new constant (will be NODE_EXTRA_CA_CERTS eventually) Signed-off-by: shirady <[email protected]> (cherry picked from commit 41215ae64ada1a5c7cd5a85322201e64a2945fda)
…t the data in the core and endpoint pods Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
(to avoid circular dependency had to move the consts from options to util) Signed-off-by: shirady <[email protected]>
…jectedBundleCertCAFile in comment) Signed-off-by: shirady <[email protected]>
UpdatesThis PR moved to draft (might be closed and a new PR / revert PR will be open):
The Recommendation of what the testing end-to-end can include:
|
I'm closing this PR as it continues in PR #1587 |
Explain the changes
pkg/utilutil.go
- Change the/etc/ocp-injected-ca-bundle.crt
to/etc/ocp-injected-ca-bundle/ca-bundle.crt
.pkg/system/reconciler.go
- Renamer.CaBundleConf.Name
fromr.Request.Name + "-ca-inject"
to"ocp-injected-ca-bundle"
to align with the rename ofconfigmap-ca-inject.yaml
fromnoobaa-ca-inject
toocp-injected-ca-bundle
in PR Modify the handling of injected OCP CA bundles #1328.pkg/system/phase2_creating.go
andpkg/system/phase4_configuring.go
- the core and the endpoint change the mount path from/etc/ocp-injected-ca-bundle.crt
(with file extension) to a directory (remove the extension).AddToRootCAs
toCombineCaBundle
, add the constInjectedBundleCertCAFile
which is/etc/ocp-injected-ca-bundle/ca-bundle.crt
, and assignr.ApplyCAsToPods
to be the new constant (will beNODE_EXTRA_CA_CERTS
eventually).configmap-ca-inject
) to check this and also that we have data in it.The reason is that when we test the OLM (in the CI), we have the OLM and then we have the operator so the config map as it is created by the OLM, but in the first step it is empty.
When manually looking at the config map in a real cluster there is data, that probably comes from additional needed configuration in the cluster (which is not in the scope of the test).
ApplyCAsToPods
so it would be clear that it is relevant to the endpoint and core pods.CombineCaBundle
use const instead of hard-coded string (to avoid circular dependency had to move the consts fromoptions
toutil
file).ApplyCAsToPods
toServiceServingCertCAFile
(previousInjectedBundleCertCAFile
in comment).Issues:
NODE_EXTRA_CA_CERTS
is empty, while it used to beNODE_EXTRA_CA_CERTS=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
.GAPs:
Testing Instructions:
Basic Manual Tests (more details in the comment below)
Check the value of
NODE_EXTRA_CA_CERTS
:launch 4.17 aws
NODE_EXTRA_CA_CERTS
:oc exec statefulset/noobaa-core -c core -n openshift-storage -- printenv | grep NODE_EXTRA_CA_CERTS
(was empty)oc exec noobaa-endpoint-<characters> -n openshift-storage -- env | grep NODE_EXTRA_CA_CERTS
(was empty)launch 4.14 aws
in the cluster-bot (the version was chosen as a version before the changes of PR Modify the handling of injected OCP CA bundles #1328) we could seeNODE_EXTRA_CA_CERTS=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
(both on core and endpoint).NODE_EXTRA_CA_CERTS=/etc/ocp-injected-ca-bundle/ca-bundle.crt
NODE_EXTRA_CA_CERTS=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
(with the commit mentioned in change number 8).Doc added/updated
Tests added