-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated cherry pick of #308: Add tagging controller configuration#3…
…34: Stop retrying failed workitem after a certain amount of (#358) * Add tagging controller * Stop retrying failed workitem after a certain amount of retries Added metrics * Changes to make tagging controller compatible with K8s 1.21 Co-authored-by: Nguyen Dinh <[email protected]> Co-authored-by: Nicholas Turner <[email protected]>
- Loading branch information
1 parent
315d55a
commit 8b6a466
Showing
16 changed files
with
847 additions
and
39 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
/ecr-credential-provider.exe | ||
/cloudconfig | ||
|
||
.vscode/ | ||
|
||
docs/book/_book/ | ||
site/ | ||
.vscode/ | ||
e2e.test | ||
.idea/ |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The Tagging Controller | ||
|
||
The tagging controller is responsible for tagging and untagging node resources when they join and leave the cluster, respectively. It can add and remove tags based on user input. Additionally, if a tag is updated, it would leave the updated tag and reapply the user-provided tag. Unlike the existing controllers, the tagging controller works exclusively with AWS. The AWS APIs it uses are `ec2:CreateTags` and `ec2:DeleteTags`. | ||
|
||
| Flag | Valid Values | Default | Description | | ||
|------| --- | --- | --- | | ||
| tags | Comma-separated list of key=value | - | A comma-separated list of key-value pairs which will be recorded as nodes' additional tags. For example: "Key1=Val1,Key2=Val2,KeyNoVal1=,KeyNoVal2" | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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 | ||
|
||
const ( | ||
// Instance presenting the string literal "instance" | ||
Instance string = "instance" | ||
) | ||
|
||
// SupportedResources contains the resources that can be tagged by the controller at the moment | ||
var SupportedResources = []string{ | ||
Instance, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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/spf13/pflag" | ||
) | ||
|
||
// TaggingControllerOptions contains the inputs that can | ||
// be used in the tagging controller | ||
type TaggingControllerOptions struct { | ||
Tags map[string]string | ||
Resources []string | ||
} | ||
|
||
// AddFlags add the additional flags for the controller | ||
func (o *TaggingControllerOptions) AddFlags(fs *pflag.FlagSet) { | ||
fs.StringToStringVar(&o.Tags, "tags", o.Tags, "Tags to apply to AWS resources in the tagging controller, in a form of key=value.") | ||
fs.StringArrayVar(&o.Resources, "resources", o.Resources, "AWS resources name to add/remove tags in the tagging controller.") | ||
} | ||
|
||
// Validate checks for errors from user input | ||
func (o *TaggingControllerOptions) Validate() error { | ||
if len(o.Tags) == 0 { | ||
return fmt.Errorf("--tags must not be empty and must be a form of key=value") | ||
} | ||
|
||
if len(o.Resources) == 0 { | ||
return fmt.Errorf("--resources must not be empty") | ||
} | ||
|
||
for _, r := range o.Resources { | ||
for _, resource := range SupportedResources { | ||
if r != resource { | ||
return fmt.Errorf("%s is not a supported resource. Current supported resources %v", r, SupportedResources) | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.