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

feat: expose additional eks bootstrap options #2965

Merged
merged 1 commit into from
Dec 10, 2021
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
42 changes: 39 additions & 3 deletions bootstrap/eks/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,52 @@ limitations under the License.
package v1alpha3

import (
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
apiconversion "k8s.io/apimachinery/pkg/conversion"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"

"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
)

// ConvertTo converts the v1alpha3 EKSConfig receiver to a v1beta1 EKSConfig.
func (r *EKSConfig) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1beta1.EKSConfig)

return Convert_v1alpha3_EKSConfig_To_v1beta1_EKSConfig(r, dst, nil)
if err := Convert_v1alpha3_EKSConfig_To_v1beta1_EKSConfig(r, dst, nil); err != nil {
return err
}

restored := &v1beta1.EKSConfig{}
if ok, err := utilconversion.UnmarshalData(r, restored); err != nil || !ok {
return err
}

dst.Spec.ContainerRuntime = restored.Spec.ContainerRuntime
dst.Spec.DNSClusterIP = restored.Spec.DNSClusterIP
dst.Spec.DockerConfigJSON = restored.Spec.DockerConfigJSON
dst.Spec.APIRetryAttempts = restored.Spec.APIRetryAttempts
if restored.Spec.PauseContainer != nil {
dst.Spec.PauseContainer.AccountNumber = restored.Spec.PauseContainer.AccountNumber
dst.Spec.PauseContainer.Version = restored.Spec.PauseContainer.Version
}
dst.Spec.UseMaxPods = restored.Spec.UseMaxPods

return nil
}

// ConvertFrom converts the v1beta1 EKSConfig receiver to a v1alpha3 EKSConfig.
func (r *EKSConfig) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1beta1.EKSConfig)

return Convert_v1beta1_EKSConfig_To_v1alpha3_EKSConfig(src, r, nil)
if err := Convert_v1beta1_EKSConfig_To_v1alpha3_EKSConfig(src, r, nil); err != nil {
return err
}

if err := utilconversion.MarshalData(src, r); err != nil {
return err
}

return nil
}

// ConvertTo converts the v1alpha3 EKSConfigList receiver to a v1beta1 EKSConfigList.
Expand Down Expand Up @@ -76,3 +106,9 @@ func (r *EKSConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error {

return Convert_v1beta1_EKSConfigTemplateList_To_v1alpha3_EKSConfigTemplateList(src, r, nil)
}

func Convert_v1beta1_EKSConfigSpec_To_v1alpha3_EKSConfigSpec(in *v1beta1.EKSConfigSpec, out *EKSConfigSpec, s apiconversion.Scope) error {
out.KubeletExtraArgs = in.KubeletExtraArgs

return nil
}
45 changes: 33 additions & 12 deletions bootstrap/eks/api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 39 additions & 4 deletions bootstrap/eks/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,51 @@ limitations under the License.
package v1alpha4

import (
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
apiconversion "k8s.io/apimachinery/pkg/conversion"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"

"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
)

// ConvertTo converts the v1alpha4 EKSConfig receiver to a v1beta1 EKSConfig.
func (r *EKSConfig) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1beta1.EKSConfig)

return Convert_v1alpha4_EKSConfig_To_v1beta1_EKSConfig(r, dst, nil)
if err := Convert_v1alpha4_EKSConfig_To_v1beta1_EKSConfig(r, dst, nil); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do the same for v1alpha3?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, added.

return err
}

restored := &v1beta1.EKSConfig{}
if ok, err := utilconversion.UnmarshalData(r, restored); err != nil || !ok {
return err
}

dst.Spec.ContainerRuntime = restored.Spec.ContainerRuntime
dst.Spec.DNSClusterIP = restored.Spec.DNSClusterIP
dst.Spec.DockerConfigJSON = restored.Spec.DockerConfigJSON
dst.Spec.APIRetryAttempts = restored.Spec.APIRetryAttempts
if restored.Spec.PauseContainer != nil {
dst.Spec.PauseContainer.AccountNumber = restored.Spec.PauseContainer.AccountNumber
dst.Spec.PauseContainer.Version = restored.Spec.PauseContainer.Version
}
dst.Spec.UseMaxPods = restored.Spec.UseMaxPods

return nil
}

// ConvertFrom converts the v1beta1 EKSConfig receiver to a v1alpha4 EKSConfig.
func (r *EKSConfig) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1beta1.EKSConfig)

return Convert_v1beta1_EKSConfig_To_v1alpha4_EKSConfig(src, r, nil)
if err := Convert_v1beta1_EKSConfig_To_v1alpha4_EKSConfig(src, r, nil); err != nil {
return err
}

if err := utilconversion.MarshalData(src, r); err != nil {
return err
}

return nil
}

// ConvertTo converts the v1alpha4 EKSConfigList receiver to a v1beta1 EKSConfigList.
Expand Down Expand Up @@ -76,3 +105,9 @@ func (r *EKSConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error {

return Convert_v1beta1_EKSConfigTemplateList_To_v1alpha4_EKSConfigTemplateList(src, r, nil)
}

func Convert_v1beta1_EKSConfigSpec_To_v1alpha4_EKSConfigSpec(in *v1beta1.EKSConfigSpec, out *EKSConfigSpec, s apiconversion.Scope) error {
out.KubeletExtraArgs = in.KubeletExtraArgs

return nil
}
45 changes: 33 additions & 12 deletions bootstrap/eks/api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions bootstrap/eks/api/v1beta1/eksconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ type EKSConfigSpec struct {
// KubeletExtraArgs passes the specified kubelet args into the Amazon EKS machine bootstrap script
// +optional
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
// ContainerRuntime specify the container runtime to use when bootstrapping EKS.
// +optional
ContainerRuntime *string `json:"containerRuntime,omitempty"`
// DNSClusterIP overrides the IP address to use for DNS queries within the cluster.
// +optional
DNSClusterIP *string `json:"dnsClusterIP,omitempty"`
// DockerConfigJson is used for the contents of the /etc/docker/daemon.json file. Useful if you want a custom config differing from the default one in the AMI.
// This is expected to be a json string.
// +optional
DockerConfigJSON *string `json:"dockerConfigJson,omitempty"`
// APIRetryAttempts is the number of retry attempts for AWS API call.
// +optional
APIRetryAttempts *int `json:"apiRetryAttempts,omitempty"`
// PauseContainer allows customization of the pause container to use.
// +optional
PauseContainer *PauseContainer `json:"pauseContainer,omitempty"`
// UseMaxPods sets --max-pods for the kubelet when true.
// +optional
UseMaxPods *bool `json:"useMaxPods,omitempty"`

// TODO(richardcase): this can be uncommented when we get to the ipv6/dual-stack implementation
// ServiceIPV6Cidr is the ipv6 cidr range of the cluster. If this is specified then
// the ip family will be set to ipv6.
// +optional
// ServiceIPV6Cidr *string `json:"serviceIPV6Cidr,omitempty"`
}

// PauseContainer contains details of pause container.
type PauseContainer struct {
// AccountNumber is the AWS account number to pull the pause container from.
AccountNumber string `json:"accountNumber"`
// Version is the tag of the pause container to use.
Version string `json:"version"`
}

// EKSConfigStatus defines the observed state of the Amazon EKS Bootstrap Configuration.
Expand Down
45 changes: 45 additions & 0 deletions bootstrap/eks/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading