-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: Ensure that insecureSkipTLSVerify is false before setting caBundle on APIService #160
Open
JorTurFer
wants to merge
6
commits into
open-policy-agent:master
Choose a base branch
from
JorTurFer:set-insecure
base: master
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 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
711ab42
feat: Ensure that insecureSkipTLSVerify is false before setting caBun…
JorTurFer b6658e1
add a comment for the test case
JorTurFer ab23e8f
Merge branch 'master' into set-insecure
ritazh 944182b
make replace optional
JorTurFer 64b274a
add a test
JorTurFer b6466d0
Merge branch 'master' into set-insecure
JorTurFer 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 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
This file contains 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'm curious to get some of the maintainers thoughts on whether this actually has to happen here, in cert-controller. If
cert-controller
is going to be used with APIService, presumably we are going to inject acaBundle
so why not set this field outside ofcert-controller
to begin 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.
The problem we have faced with is that when you set
insecureSkipTLSVerify: true
, you have to set explicitlyinsecureSkipTLSVerify: false
to remove the value.As
insecureSkipTLSVerify: false
is the default value, k8s api removes it automatically and CD tools like ArgoCD/Flux enter on permanent out-of-sync status.kedacore/charts#550
In this scenario, we have some options:
insecureSkipTLSVerify
before settingcaBundle
Maybe I've missed something and there is any other option
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'm a bit confused here. You're saying that having
insecureSkipTLSVerify: false
in the Helm chart causes CI/CD pipelines to detect drift because the API server strips default values, correct?I'm curious what makes cert-controller different in this regard, since it's merely another thing essentially running kubectl apply. Would cert-controller also be subject to the same default-stripping issue, leaving you right back where you began?
Or is the objective to remove the state from the Helm chart such that there is no longer any check for drift for this value?
Modifying controller code to meet the needs of CI/CD code does seem a bit backwards. I am also wary of potentially manually overriding user intent on what could be a very salient field (is there some reason why insecureSkipTLSVerify is set? Will un-setting it cause an outage? Can we be sure the answer will be identical for all projects that consume cert-controller?)
As for other options, maybe a post-install hook on the Helm chart to modify the value?
Here is an example of a post-install hook G8r uses:
https://github.com/open-policy-agent/gatekeeper/blob/master/charts/gatekeeper/templates/namespace-post-install.yaml
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, as it's the default value, it is removed automatically. If you deploy an apiservice with explicitly set
insecureSkipTLSVerify: false
and then you get it from the cluster, you will see that your set valueinsecureSkipTLSVerify: false
has been chopped from the manifest. This triggers out-of-sync on CD systems like ArgoCD.You can just try with this:
Yes, it's removed exactly in the same way, but if it's cert-controller, we don't need to set it in the helm chart, so external tools aren't affected.
The objective is to not have to explicitly set the value to default value in general. (not only from helm but from raw manifests)
Actually, if cert-controller tries to patch the
apiservice
to add thecaBundle
but theapiservice
has setinsecureSkipTLSVerify: true
, cert-controller will fail becauseinsecureSkipTLSVerify: true
andcaBundle
are mutually exclusive. If the value has been set totrue
and then cert-controller has been enabled, cert-controller won't work at all, printing errors all the time due to this mutual exclusivity.We don't need this feature anymore (nor for helm nor for raw yamls) as we just needed it during some releases after the migration from random certs generated by the pods to real certs, stored in Kubernetes and managed by cert-controller/cert-manager. I mean, we don't need this feature anymore for KEDA xD
I've just pushed it instead of just closing the PR because this project is awesome and has helped us a lot and I assume that we aren't the only one who faces with this and the code was already done.
I can extend any other doubt that you have, said that, if you think that this doesn't make sense, we can close the PR
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.
This makes sense, but if a user has intentionally skipped TLS verification, will cert-controller overriding it break their use case? If so, consumers would be unable to use that version of cert-controller due to the mandatory override. It comes down to whether its better for cert-controller to return errors or for it to override user intent without context as to why it was set.
I very much appreciate the consideration and am glad the project has helped you!
I think if the override was optional, such that projects could opt-in, I would be less concerned. This would probably boil down to adding a new option to the rotator:
cert-controller/pkg/rotator/rotator.go
Lines 219 to 259 in b1a35eb
Which defaults to off so that behavior would be backwards compatible for users on upgrade.
Definitely up to you if the extra work is worth your time. I apologize for the slow review cycle.
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.
Kindly reminder @maxsmythe 😄
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 probably want to test both cases, but I hear you about not wanting to propagate the expected assertion everywhere.
Maybe we can use functional options to make this a backwards-compatible change to
testWebhook()
.Functional options blog: https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html
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.
f**k! I missed your comment 🤦
I'll review the PR this week 😄
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've added another split test for this specific feature. PTAL when you have some time @maxsmythe
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.
Kindly reminder @maxsmythe 😄