-
Notifications
You must be signed in to change notification settings - Fork 406
Add KCP CLI arguments to enable home workspaces as well as specific options, especially the groups bound to the get/create ~ permissions #1539
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
openshift-ci
merged 2 commits into
kcp-dev:main
from
davidfestal:home-workspaces-cli-options
Jul 15, 2022
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...errole-clusterworkspace-users-access.yaml → ...-clusterworkspace-home-prefix-access.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: system:kcp:users-clusterworkspace-access | ||
name: system:kcp:home-prefix-clusterworkspace-access | ||
rules: | ||
- apiGroups: ["tenancy.kcp.dev"] | ||
resources: ["clusterworkspaces/content"] | ||
resourceNames: ["users"] | ||
resourceNames: ["HOMEPREFIX"] | ||
verbs: ["access"] |
9 changes: 0 additions & 9 deletions
9
config/root/clusterrolebinding-clusterworkspace-home-get.yaml
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...inding-clusterworkspace-users-access.yaml → ...-clusterworkspace-home-prefix-access.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
2 changes: 1 addition & 1 deletion
2
...root/clusterworkspace-homeroot-users.yaml → ...lusterworkspace-homeroot-home-prefix.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
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
Copyright 2022 The KCP Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package options | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kcp-dev/logicalcluster" | ||
"github.com/spf13/pflag" | ||
|
||
"k8s.io/apiserver/pkg/authentication/user" | ||
|
||
tenancyv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/tenancy/v1alpha1" | ||
) | ||
|
||
type HomeWorkspaces struct { | ||
Enabled bool | ||
|
||
CreationDelaySeconds int | ||
BucketLevels int | ||
BucketSize int | ||
|
||
HomeCreatorGroups []string | ||
HomeRootPrefix string | ||
} | ||
|
||
func NewHomeWorkspaces() *HomeWorkspaces { | ||
return &HomeWorkspaces{ | ||
Enabled: true, | ||
CreationDelaySeconds: 2, | ||
BucketLevels: 2, | ||
BucketSize: 2, | ||
HomeCreatorGroups: []string{user.AllAuthenticated}, | ||
HomeRootPrefix: "root:users", | ||
} | ||
} | ||
|
||
func (hw *HomeWorkspaces) AddFlags(fs *pflag.FlagSet) { | ||
fs.BoolVar(&hw.Enabled, "enable-home-workspaces", hw.Enabled, "Enable the Home Workspaces feature. Home workspaces allow a personal home workspace to provisioned on first access per-user. A user is cluster-admin inside his personal Home workspace.") | ||
fs.IntVar(&hw.CreationDelaySeconds, "home-workspaces-creation-delay-seconds", hw.CreationDelaySeconds, "Delay, in seconds, before retrying accessing the Home workspace after its automatic creation. This value is used when sending 'retry-after' responses to the Kubernetes client.") | ||
fs.IntVar(&hw.BucketLevels, "home-workspaces-bucket-levels", hw.BucketLevels, "Number of levels of bucket workspaces when bucketing home workspaces") | ||
fs.IntVar(&hw.BucketLevels, "home-workspaces-bucket-size", hw.BucketSize, "Number of characters of bucket workspace names used when bucketing home workspaces") | ||
fs.StringSliceVar(&hw.HomeCreatorGroups, "home-workspaces-home-creator-groups", hw.HomeCreatorGroups, "Groups of users who can have their home workspace created automatically create when first accessing it.") | ||
fs.StringVar(&hw.HomeRootPrefix, "home-workspaces-root-prefix", hw.HomeRootPrefix, "Logical cluster name of the workspace that will contains home workspaces for all workspaces.") | ||
} | ||
|
||
func (e *HomeWorkspaces) Validate() []error { | ||
var errs []error | ||
|
||
if e.Enabled { | ||
if e.BucketLevels < 1 || e.BucketLevels > 5 { | ||
errs = append(errs, fmt.Errorf("--home-workspaces-bucket-levels should be between 1 and 5")) | ||
} | ||
if e.BucketSize < 1 || e.BucketLevels > 4 { | ||
errs = append(errs, fmt.Errorf("--home-workspaces-bucket-size should be between 1 and 4")) | ||
} | ||
if e.CreationDelaySeconds < 1 { | ||
errs = append(errs, fmt.Errorf("--home-workspaces-creation-delay-seconds should be between 1")) | ||
} | ||
if homePrefix := logicalcluster.New(e.HomeRootPrefix); !homePrefix.IsValid() || | ||
homePrefix == logicalcluster.Wildcard || | ||
!homePrefix.HasPrefix(tenancyv1alpha1.RootCluster) { | ||
errs = append(errs, fmt.Errorf("--home-workspaces-root-prefix should be a valid logical cluster name")) | ||
} else if parent, ok := homePrefix.Parent(); !ok || parent != tenancyv1alpha1.RootCluster { | ||
errs = append(errs, fmt.Errorf("--home-workspaces-root-prefix should be a direct child of the root logical cluster")) | ||
} | ||
} | ||
|
||
return errs | ||
} |
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
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.
better 👍