Skip to content

Commit

Permalink
Managed node groups (#76)
Browse files Browse the repository at this point in the history
* update sdk

* initial impl

* allow for role creation

* Update go.sum

* fix types & tests

* fix types

* handle label removal

* add tests
  • Loading branch information
eytan-avisror authored Mar 3, 2020
1 parent 0c9a5d2 commit 5a6f76d
Show file tree
Hide file tree
Showing 123 changed files with 18,570 additions and 16,172 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ docker-push:
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.2
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.4
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ _For more examples and usage, please refer to the [Installation Reference Walkth
| Provisioner | Description | Supported?
| :--- | :--- | :---: |
| eks-cf | provision nodes on EKS using cloudformation ||
| eks-managed | provision managed node groups for EKS ||
| eks-tf | provision nodes on EKS using terraform | ⚠️🔜 |
| ec2-kops | provision nodes on AWS using Kops | ⚠️🔜 |

Expand Down
79 changes: 65 additions & 14 deletions api/v1alpha1/instancegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
log "github.com/sirupsen/logrus"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

type ReconcileState string
Expand All @@ -42,6 +43,14 @@ const (
ReconcileErr ReconcileState = "Error"
)

var (
GroupVersionResource = schema.GroupVersionResource{
Group: "instancemgr.keikoproj.io",
Version: "v1alpha1",
Resource: "instancegroups",
}
)

// InstanceGroup is the Schema for the instancegroups API
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=instancegroups,scope=Namespaced,shortName=ig
Expand Down Expand Up @@ -71,9 +80,9 @@ type InstanceGroupList struct {

// AwsUpgradeStrategy defines the upgrade strategy of an AWS Instance Group
type AwsUpgradeStrategy struct {
Type string `json:"type"`
CRDType CRDUpgradeStrategy `json:"crd,omitempty"`
RollingUpgradeType RollingUpgradeStrategy `json:"rollingUpdate,omitempty"`
Type string `json:"type"`
CRDType *CRDUpgradeStrategy `json:"crd,omitempty"`
RollingUpgradeType *RollingUpgradeStrategy `json:"rollingUpdate,omitempty"`
}

type RollingUpgradeStrategy struct {
Expand Down Expand Up @@ -151,23 +160,45 @@ type CRDUpgradeStrategy struct {
// InstanceGroupSpec defines the schema of resource Spec
type InstanceGroupSpec struct {
Provisioner string `json:"provisioner"`
EKSCFSpec EKSCFSpec `json:"eks-cf"`
EKSCFSpec *EKSCFSpec `json:"eks-cf,omitempty"`
EKSManagedSpec *EKSManagedSpec `json:"eks-managed,omitempty"`
AwsUpgradeStrategy AwsUpgradeStrategy `json:"strategy"`
}

type EKSManagedSpec struct {
MaxSize int64 `json:"maxSize"`
MinSize int64 `json:"minSize"`
EKSManagedConfiguration *EKSManagedConfiguration `json:"configuration"`
}

type EKSCFSpec struct {
MaxSize int32 `json:"maxSize"`
MinSize int32 `json:"minSize"`
EKSCFConfiguration EKSCFConfiguration `json:"configuration"`
MaxSize int32 `json:"maxSize,omitempty"`
MinSize int32 `json:"minSize,omitempty"`
EKSCFConfiguration *EKSCFConfiguration `json:"configuration,omitempty"`
}

type EKSManagedConfiguration struct {
EksClusterName string `json:"clusterName,omitempty"`
VolSize int64 `json:"volSize,omitempty"`
InstanceType string `json:"instanceType,omitempty"`
NodeLabels map[string]string `json:"nodeLabels,omitempty"`
NodeRole string `json:"nodeRole,omitempty"`
NodeSecurityGroups []string `json:"securityGroups,omitempty"`
KeyPairName string `json:"keyPairName,omitempty"`
Tags []map[string]string `json:"tags,omitempty"`
Subnets []string `json:"subnets,omitempty"`
AmiType string `json:"amiType,omitempty"`
ReleaseVersion string `json:"releaseVersion,omitempty"`
Version string `json:"version,omitempty"`
}

// EKSCFConfiguration defines the context of an AWS Instance Group using EKSCF
type EKSCFConfiguration struct {
EksClusterName string `json:"clusterName,omitempty"`
KeyPairName string `json:"keyPairName"`
Image string `json:"image"`
InstanceType string `json:"instanceType"`
NodeSecurityGroups []string `json:"securityGroups"`
KeyPairName string `json:"keyPairName,omitempty"`
Image string `json:"image,omitempty"`
InstanceType string `json:"instanceType,omitempty"`
NodeSecurityGroups []string `json:"securityGroups,omitempty"`
VolSize int32 `json:"volSize,omitempty"`
Subnets []string `json:"subnets,omitempty"`
BootstrapArguments string `json:"bootstrapArguments,omitempty"`
Expand All @@ -193,15 +224,35 @@ type InstanceGroupStatus struct {
Lifecycle string `json:"lifecycle,omitempty"`
}

func (s *AwsUpgradeStrategy) GetRollingUpgradeStrategy() RollingUpgradeStrategy {
func (conf *EKSManagedConfiguration) SetSubnets(subnets []string) { conf.Subnets = subnets }
func (conf *EKSManagedConfiguration) SetClusterName(name string) { conf.EksClusterName = name }
func (conf *EKSManagedConfiguration) GetLabels() map[string]string { return conf.NodeLabels }

func (ig *InstanceGroup) GetEKSManagedConfiguration() *EKSManagedConfiguration {
return ig.Spec.EKSManagedSpec.EKSManagedConfiguration
}

func (ig *InstanceGroup) GetEKSManagedSpec() *EKSManagedSpec {
return ig.Spec.EKSManagedSpec
}

func (spec *EKSManagedSpec) GetMaxSize() int64 {
return spec.MaxSize
}

func (spec *EKSManagedSpec) GetMinSize() int64 {
return spec.MinSize
}

func (s *AwsUpgradeStrategy) GetRollingUpgradeStrategy() *RollingUpgradeStrategy {
return s.RollingUpgradeType
}

func (s *AwsUpgradeStrategy) GetCRDType() CRDUpgradeStrategy {
func (s *AwsUpgradeStrategy) GetCRDType() *CRDUpgradeStrategy {
return s.CRDType
}

func (s *AwsUpgradeStrategy) SetCRDType(crd CRDUpgradeStrategy) {
func (s *AwsUpgradeStrategy) SetCRDType(crd *CRDUpgradeStrategy) {
s.CRDType = crd
}

Expand Down
96 changes: 91 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 5a6f76d

Please sign in to comment.