Skip to content

✨ Addons: Add functionality for resolveConflicts: PRESERVE #5330

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2212,10 +2212,11 @@ spec:
default: overwrite
description: |-
ConflictResolution is used to declare what should happen if there
are parameter conflicts. Defaults to none
are parameter conflicts. Defaults to overwrite
enum:
- overwrite
- none
- preserve
type: string
name:
description: Name is the name of the addon
Expand Down
8 changes: 6 additions & 2 deletions controlplane/eks/api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ type Addon struct {
// +optional
Configuration string `json:"configuration,omitempty"`
// ConflictResolution is used to declare what should happen if there
// are parameter conflicts. Defaults to none
// are parameter conflicts. Defaults to overwrite
// +kubebuilder:default=overwrite
// +kubebuilder:validation:Enum=overwrite;none
// +kubebuilder:validation:Enum=overwrite;none;preserve
ConflictResolution *AddonResolution `json:"conflictResolution,omitempty"`
// ServiceAccountRoleArn is the ARN of an IAM role to bind to the addons service account
// +optional
Expand All @@ -154,6 +154,10 @@ var (
// AddonResolutionNone indicates that if there are parameter conflicts then
// resolution will not be done and an error will be reported.
AddonResolutionNone = AddonResolution("none")

// AddonResolutionPreserve indicates that if there are parameter conflicts then
// resolution will result in preserving the existing value
AddonResolutionPreserve = AddonResolution("preserve")
)

// AddonStatus defines the status for an addon.
Expand Down
13 changes: 11 additions & 2 deletions docs/book/src/topics/eks/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ spec:
conflictResolution: "overwrite"
```

_Note_: For `conflictResolution` `overwrite` is the **default** behaviour. That means, if not otherwise specified, it's
set to `overwrite`.
Valid values are:
```
none
overwrite
preserve
```

_Note_: For `conflictResolution` `none` is the **default** behaviour. That means, if not otherwise specified, it's
set to `none`. Review [API Documentation](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateAddon.html#AmazonEKS-CreateAddon-request-resolveConflicts) for detailed behavior.

Additionally, there is a cluster [flavor](https://cluster-api.sigs.k8s.io/clusterctl/commands/generate-cluster.html#flavors)
called [eks-managedmachinepool-vpccni](https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/main/templates/cluster-template-eks-managedmachinepool-vpccni.yaml) that you can use with **clusterctl**:
Expand All @@ -46,6 +53,8 @@ To update the version of an addon you need to edit the `AWSManagedControlPlane`
...
```

_Note_: For `conflictResolution` `none`, updating may fail if a change was made to the addon that is unexpected by EKS. Review [API Documentation](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateAddon.html#AmazonEKS-UpdateAddon-request-resolveConflicts) for detailed behavior on conflict resolution.

## Deleting Addons

To delete an addon from a cluster you need to edit the `AWSManagedControlPlane` instance and remove the entry for the addon you want to delete.
Expand Down
23 changes: 18 additions & 5 deletions pkg/cloud/services/eks/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,16 @@ func (s *Service) translateAPIToAddon(addons []ekscontrolplanev1.Addon) []*eksad

for i := range addons {
addon := addons[i]
conflict, err := convertConflictResolution(*addon.ConflictResolution)
if err != nil {
s.scope.Error(err, err.Error())
}
convertedAddon := &eksaddons.EKSAddon{
Name: &addon.Name,
Version: &addon.Version,
Configuration: &addon.Configuration,
Tags: ngTags(s.scope.Cluster.Name, s.scope.AdditionalTags()),
ResolveConflict: convertConflictResolution(*addon.ConflictResolution),
ResolveConflict: conflict,
ServiceAccountRoleARN: addon.ServiceAccountRoleArn,
}

Expand All @@ -209,9 +213,18 @@ func (s *Service) translateAPIToAddon(addons []ekscontrolplanev1.Addon) []*eksad
return converted
}

func convertConflictResolution(conflict ekscontrolplanev1.AddonResolution) *string {
if conflict == ekscontrolplanev1.AddonResolutionNone {
return aws.String(eks.ResolveConflictsNone)
func convertConflictResolution(conflict ekscontrolplanev1.AddonResolution) (*string, error) {
switch conflict {
case ekscontrolplanev1.AddonResolutionNone:
return aws.String(eks.ResolveConflictsNone), nil

case ekscontrolplanev1.AddonResolutionOverwrite:
return aws.String(eks.ResolveConflictsOverwrite), nil

case ekscontrolplanev1.AddonResolutionPreserve:
return aws.String(eks.ResolveConflictsPreserve), nil

default:
return aws.String(eks.ResolveConflictsNone), fmt.Errorf("failed to determine adddonResolution; defaulting to None")
}
return aws.String(eks.ResolveConflictsOverwrite)
}
Loading