Skip to content
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

Add "auth-extra-groups" field to bootstrap token #442

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/machine-controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func StartControllers(s *options.MCMServer,
recorder,
s.SafetyOptions,
s.NodeConditions,
s.BootstrapTokenAuthExtraGroups,
)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions cmd/machine-controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (s *MCMServer) AddFlags(fs *pflag.FlagSet) {
fs.DurationVar(&s.SafetyOptions.MachineSafetyOvershootingPeriod.Duration, "machine-safety-overshooting-period", s.SafetyOptions.MachineSafetyOvershootingPeriod.Duration, "Time period (in durartion) used to poll for overshooting of machine objects backing a machineSet by safety controller.")
fs.DurationVar(&s.SafetyOptions.MachineSafetyAPIServerStatusCheckPeriod.Duration, "machine-safety-apiserver-statuscheck-period", s.SafetyOptions.MachineSafetyAPIServerStatusCheckPeriod.Duration, "Time period (in duration) used to poll for APIServer's health by safety controller")
fs.StringVar(&s.NodeConditions, "node-conditions", s.NodeConditions, "List of comma-separated/case-sensitive node-conditions which when set to True will change machine to a failed state after MachineHealthTimeout duration. It may further be replaced with a new machine if the machine is backed by a machine-set object.")
fs.StringVar(&s.BootstrapTokenAuthExtraGroups, "bootstrap-token-auth-extra-groups", s.BootstrapTokenAuthExtraGroups, "Comma-separated list of groups to set bootstrap token's \"auth-extra-groups\" field to")

leaderelectionconfig.BindFlags(&s.LeaderElection, fs)
// TODO: DefaultFeatureGate is global and it adds all k8s flags
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func NewController(
recorder record.EventRecorder,
safetyOptions options.SafetyOptions,
nodeConditions string,
bootstrapTokenAuthExtraGroups string,
) (Controller, error) {
controller := &controller{
namespace: namespace,
Expand All @@ -106,6 +107,7 @@ func NewController(
machineSafetyAPIServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "machinesafetyapiserver"),
safetyOptions: safetyOptions,
nodeConditions: nodeConditions,
bootstrapTokenAuthExtraGroups: bootstrapTokenAuthExtraGroups,
}

controller.internalExternalScheme = runtime.NewScheme()
Expand Down Expand Up @@ -397,8 +399,9 @@ type Controller interface {

// controller is a concrete Controller.
type controller struct {
namespace string
nodeConditions string
namespace string
nodeConditions string
bootstrapTokenAuthExtraGroups string

controlMachineClient machineapi.MachineV1alpha1Interface
controlCoreClient kubernetes.Interface
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/machine_bootstrap_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (c *controller) getBootstrapTokenOrCreateIfNotExist(machineName string) (se
bootstraptokenapi.BootstrapTokenExpirationKey: []byte(metav1.Now().Add(c.safetyOptions.MachineCreationTimeout.Duration).Format(time.RFC3339)),
bootstraptokenapi.BootstrapTokenUsageAuthentication: []byte("true"),
bootstraptokenapi.BootstrapTokenUsageSigningKey: []byte("true"),
bootstraptokenapi.BootstrapTokenExtraGroupsKey: []byte(c.bootstrapTokenAuthExtraGroups),
}

secret = &v1.Secret{
Expand Down
3 changes: 3 additions & 0 deletions pkg/options/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type MachineControllerManagerConfiguration struct {

//NodeCondition is the string of known NodeConditions. If any of these NodeCondition is set for a timeout period, the machine will be declared failed and will replaced.
NodeConditions string

//BootstrapTokenAuthExtraGroups is a comma-separated string of groups to set bootstrap token's "auth-extra-groups" field to.
BootstrapTokenAuthExtraGroups string
}

// SafetyOptions are used to configure the upper-limit and lower-limit
Expand Down