-
Notifications
You must be signed in to change notification settings - Fork 64
✨ Check known required permissions for install before installing with the helm applier #1858
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
Merged
joelanford
merged 71 commits into
operator-framework:main
from
bentito:rbac-auth-k8s-replacer
Apr 15, 2025
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
8f2f0fd
permissions preflight: copy necessary kubernetes libs
joelanford b49c171
permissions preflight: kubernetes rbac code modifications
joelanford 2ddc0d1
permissions preflight: add preauth implementation
joelanford 5ca669f
permissions preflight: enable implementation behind feature gate
joelanford c84e876
Rm k8s.io/kubernetes copypasta & import/replace
bentito d9f39af
Adds k8s.io/ lib maintainer tool
bentito 58e3950
Make debug a flag
bentito 291e161
Small fix, fixes err on kubernetes replace itself
bentito 29ea3e1
Changes to allow calling as make target
bentito be29c88
Run go mod tidy post rebase
bentito c8cf805
From rebase - add PreAuthorizer to Helm struct
bentito 124ed76
Fixes to pass linter
bentito 2bacf29
Add needed setups to preflightPerm unit tests
bentito c982cac
Address review comments on rbac.go
bentito cff38de
Add tests for authorization/rbac.go
trgeiger 923affb
Move k8sMaintainer code to its own dir
bentito c368e4b
Run k8smaintainer code post rebase
bentito 956ed86
Lint acceptable format for rbac_test.go
bentito fc34755
Add tests for authorization/rbac.go
trgeiger dfcd04b
Refactor inline feature gate check
bentito 9461ba1
Change PreAuthorize() return value to []ScopedPolicyRules
trgeiger a6e1203
Lint acceptable format for rbac_test.go (take 2)
bentito a5a1c98
Add fakeStorage dry run for escalationCheck
bentito f75f5e0
Revert "Add fakeStorage dry run for escalationCheck"
bentito 836810b
Rename template func to renderClientOnlyRelease
bentito 12b3884
Updated comment on returns of PreAuthorize
bentito c4e51b5
Remove repetition in rbac_test.go
trgeiger dc2d319
k8smaintainer stage repo version pin logic upgrade
bentito ead6f09
Simplify PreAuthorizer handling via feature gate
bentito 2adb828
Split pre-auth checks cluster-scoped & ns-scoped
bentito 4d615a7
Handle missing rules from escalation errors
trgeiger 9961730
Clean up escalation error parsing and fix tests
trgeiger 41b15ad
Make tidy after rebase
bentito 5848d1b
GCI the files so lint passes
bentito 7188997
Use slices.SortFunc instead of sort.Slice
trgeiger d7bf186
Lift running pre-auth checks out of Helm Apply
bentito 4873445
Add centralized logging for feature gate status
bentito aeee3ef
Err msg reads better
bentito d45b666
Run make tidy after rebase
bentito c0b1dda
No more magic numbers
bentito ab8cfbc
Sort components of missing rules lists
bentito dc6691d
Streamline var usage
bentito 0cf3e75
Lift to escalationCheckerFor method
bentito db7e740
Fix lint prealloc err on allMissingPolicyRules
bentito bd57a65
Prealloc missingRulesWithDeduplicatedVerbs
bentito fb5fa52
Tidy verb vars together with comment & issue link
bentito a1904d8
Add comments and protections on parsing err msg
bentito b5094f5
Improvements to k8smaintainer code
bentito 6348b60
Linter fix for unused byte slice
bentito b6d6b07
New target now 'k8s-pin', take ENVVAR for k8s ver
bentito 51b6b89
Replace x/mod/semver w/ blang - more legible parse
bentito 0195c72
Move EXHELP for k8s-pin target
bentito b19add3
Update README.md to account for changes
bentito 364bfb9
Split permission & resolution error captures
bentito 47fcb60
Improve permission regexp matching
trgeiger 4656456
Run make k8s-pin post-rebase
bentito bab5b21
Add tests to verify kubernetes API errors vs regex
bentito a167ef4
permissions preflight: refactoring escalation error parser
joelanford 014d7a4
permission preflight: emit error when encountering unknown policy rul…
joelanford c06d4f2
permissions preflight: fixup escalation error parser and tests
joelanford 2de215e
permissions preflight: add kubernetes compatibility tests, other smal…
joelanford 7369824
preflight permissions: removing clusterextensions/finalizer patch req…
joelanford 44f58a0
Merge branch 'main' into rbac-auth-k8s-replacer
bentito ac29e09
Addressing latest round of PR feedback
trgeiger c40b814
Merge branch 'main' into rbac-auth-k8s-replacer
bentito 9ab708e
Fix linting errors
bentito 9414dce
SingleOwnNSInstallSupport feature gate reset
bentito 61b574d
Merge branch 'main' into rbac-auth-k8s-replacer
bentito 588ab97
Merge branch 'main' into rbac-auth-k8s-replacer
bentito c2d1a7e
Fix feature gate logging unhashable hash problem
trgeiger 8200b97
Remove duplicate test case
trgeiger 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
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
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ coverage: | |
paths: | ||
- "api/" | ||
- "cmd/" | ||
- "internal/" | ||
- "internal/" | ||
|
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
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
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
bentito marked this conversation as resolved.
Show resolved
Hide resolved
|
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,43 @@ | ||
# Kubernetes Staging Module Version Synchronization Tool | ||
|
||
## Purpose | ||
This tool ensures that if `k8s.io/kubernetes` changes version in your `go.mod`, all related staging modules (e.g., `k8s.io/api`, `k8s.io/apimachinery`) are automatically pinned to the corresponding published version. Recent improvements include an environment variable override and refined logic for version resolution. | ||
|
||
## How It Works | ||
|
||
1. **Parsing and Filtering:** | ||
- Reads and parses your `go.mod` file. | ||
- Removes existing `replace` directives for `k8s.io/` modules to avoid stale mappings. | ||
|
||
2. **Determine Kubernetes Version:** | ||
- **Environment Variable Override:** | ||
If the environment variable `K8S_IO_K8S_VERSION` is set, its value is validated (using semver standards) and used as the target version for `k8s.io/kubernetes`. The tool then runs `go get k8s.io/kubernetes@<version>` to update the dependency. | ||
- **Default Behavior:** | ||
If `K8S_IO_K8S_VERSION` is not set, the tool reads the version of `k8s.io/kubernetes` from the `go.mod` file. | ||
|
||
3. **Compute the Target Staging Version:** | ||
- Converts a Kubernetes version in the form `v1.xx.yy` into the staging version format `v0.xx.yy`. | ||
- If the target staging version is unavailable, the tool attempts to fall back to the previous patch version. | ||
|
||
4. **Updating Module Replace Directives:** | ||
- Retrieves the full dependency graph using `go list -m -json all`. | ||
- Identifies relevant `k8s.io/*` modules (skipping the main module and version-suffixed modules). | ||
- Removes outdated `replace` directives (ignoring local path replacements). | ||
- Adds new `replace` directives to pin modules—including `k8s.io/kubernetes`—to the computed staging version. | ||
|
||
5. **Finalizing Changes:** | ||
- Writes the updated `go.mod` file. | ||
- Runs `go mod tidy` to clean up dependencies. | ||
- Executes `go mod download k8s.io/kubernetes` to update `go.sum`. | ||
- Logs any issues, such as modules remaining at an untagged version (`v0.0.0`), which may indicate upstream tagging problems. | ||
|
||
## Environment Variables | ||
|
||
- **K8S_IO_K8S_VERSION (optional):** | ||
When set, this environment variable overrides the Kubernetes version found in `go.mod`. The tool validates this semver string, updates the dependency using `go get`, and processes modules accordingly. | ||
|
||
## Additional Notes | ||
|
||
- The tool ensures consistency across all `k8s.io/*` modules, even if they are not explicitly listed in `go.mod`. | ||
- If a suitable staging version is not found, a warning is logged and the closest valid version is used. | ||
- All operations are logged, which helps in troubleshooting and verifying the process. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.