-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[WIP] Initial change to add more KCP roles. #18495
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -585,10 +585,10 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr | |
| var controlPlanes []*api.InstanceGroup | ||
| var nodes []*api.InstanceGroup | ||
| for _, ig := range instanceGroups { | ||
| switch ig.Spec.Role { | ||
| case api.InstanceGroupRoleControlPlane: | ||
| switch { | ||
| case ig.Spec.Role.HasControlPlane(): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would ContainsControlPlane() be a better name method name than HasControlPlane()?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might end up getting more specific e.g. RunsKubeApiserver, RunsKubeScheduler, RunsEtcd. For now, I think it's fine, because it's internal (i.e. not part of our API) |
||
| controlPlanes = append(controlPlanes, ig) | ||
| case api.InstanceGroupRoleNode: | ||
| case ig.Spec.Role.HasNode(): | ||
| nodes = append(nodes, ig) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,7 @@ var ( | |
| // NewCmdCreateInstanceGroup create a new cobra command object for creating a instancegroup. | ||
| func NewCmdCreateInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command { | ||
| options := &CreateInstanceGroupOptions{ | ||
| Role: kopsapi.InstanceGroupRoleNode.ToLowerString(), | ||
| Role: kopsapi.InstanceGroupSubRoleNode.Role().ToLowerString(), | ||
| Edit: true, | ||
| } | ||
|
|
||
|
|
@@ -124,12 +124,15 @@ func NewCmdCreateInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command { | |
| }, | ||
| } | ||
|
|
||
| allRoles := make([]string, 0, len(kopsapi.AllInstanceGroupRoles)) | ||
| for _, r := range kopsapi.AllInstanceGroupRoles { | ||
| if r == kopsapi.InstanceGroupRoleAPIServer && !featureflag.APIServerNodes.Enabled() { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need a similar feature flag for multiple/new control plane roles. |
||
| allRoles := make([]string, 0, len(kopsapi.AllInstanceGroupSubRoles)) | ||
| for _, subrole := range kopsapi.AllInstanceGroupSubRoles { | ||
| role := subrole.Role() | ||
| if role.HasAPIServer() && !featureflag.APIServerNodes.Enabled() { | ||
| continue | ||
| } | ||
| allRoles = append(allRoles, r.ToLowerString()) | ||
| // TODO: Can we GA the APIServerNodes feature flag? | ||
| // TODO: Do we need feature flag for the new roles and multi role support? | ||
| allRoles = append(allRoles, role.ToLowerString()) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With canonicalization else where, do we still need ToLowerString() ? |
||
| } | ||
|
|
||
| cmd.Flags().StringVar(&options.Role, "role", options.Role, "Type of instance group to create ("+strings.Join(allRoles, ",")+")") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,11 +100,11 @@ func (c *NodeupModelContext) Init() error { | |
|
|
||
| role := c.BootConfig.InstanceGroupRole | ||
|
|
||
| if role == kops.InstanceGroupRoleControlPlane { | ||
| if role.HasControlPlane() { | ||
| c.IsMaster = true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need to deprecate c.IsMaster, but agree that we should not do it in this PR |
||
| } | ||
|
|
||
| if role == kops.InstanceGroupRoleControlPlane || role == kops.InstanceGroupRoleAPIServer { | ||
| if role.HasControlPlane() || role.HasAPIServer() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where it would be nice if this was just |
||
| c.HasAPIServer = true | ||
| } | ||
|
|
||
|
|
@@ -566,7 +566,7 @@ func (c *NodeupModelContext) InstallNvidiaRuntime() bool { | |
| // InstallGVisorRuntime returns true if the gVisor (runsc) runtime should be installed. | ||
| func (c *NodeupModelContext) InstallGVisorRuntime() bool { | ||
| return c.BootConfig != nil && | ||
| c.BootConfig.InstanceGroupRole == kops.InstanceGroupRoleNode && | ||
| c.BootConfig.InstanceGroupRole.HasNode() && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should start to transition away from |
||
| c.NodeupConfig.GVisor != nil && | ||
| fi.ValueOf(c.NodeupConfig.GVisor.Enabled) | ||
| } | ||
|
|
||
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.
Would it be better to make Role() more of a constructor which took 1 or more subroles?
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 like the type safety we have here. I wish we didn't have to pass .Role(), but I like this (so far, but I'm only one line in!)