Skip to content

Commit

Permalink
Merge branch 'master' into fix/InstanceProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tekenstam committed Apr 21, 2024
2 parents 8f2e0a3 + c7b755c commit 1eefe38
Show file tree
Hide file tree
Showing 27 changed files with 536 additions and 779 deletions.
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# review when someone opens a pull request.
* @keikoproj/authorized-approvers @keikoproj/instance-manager-approvers
* @keikoproj/authorized-approvers @keikoproj/instance-manager-approvers

# Admins own root and CI.
.github/** @keikoproj/keiko-admins @keikoproj/keiko-maintainers
/* @keikoproj/keiko-admins @keikoproj/keiko-maintainers
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
ignore:
- dependency-name: "k8s.io*" ## K8s module version updates should be done explicitly
update-types: ["version-update:semver-major", "version-update:semver-minor"]
- dependency-name: "sigs.k8s.io*" ## K8s module version updates should be done explicitly
update-types: ["version-update:semver-major", "version-update:semver-minor"]
- dependency-name: "*" ## Major version updates should be done explicitly
update-types: ["version-update:semver-major"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "monthly"
ignore:
- dependency-name: "golang" ## Golang version should be done explicitly
13 changes: 7 additions & 6 deletions .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: functional-test

on:
workflow_dispatch:
schedule:
# run at 23:05 PM PST (cron uses UTC)
- cron: '5 15 * * *'
Expand All @@ -10,20 +11,20 @@ jobs:
functional-test:
name: functional-test
if: github.repository_owner == 'keikoproj'
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:

- name: python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.6'
python-version: 'pypy3.9'
architecture: 'x64'

- name: setup
run: |
sudo apt update
sudo apt install python-pip
sudo apt install python3-pip
pip install --user awscli
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
Expand All @@ -35,7 +36,7 @@ jobs:
aws --version
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: master

Expand All @@ -57,4 +58,4 @@ jobs:
aws eks update-kubeconfig --name $EKS_CLUSTER
make install
kubectl set image -n instance-manager deployment/instance-manager instance-manager=keikoproj/instance-manager:master
make bdd
make bdd
20 changes: 10 additions & 10 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@ jobs:
push:
name: push
if: github.repository_owner == 'keikoproj'
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
install: true
version: latest

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.CR_USERNAME }}
password: ${{ secrets.CR_PAT }}
username: ${{ secrets.GHA_USERNAME }}
password: ${{ secrets.GHA_TOKEN }}

-
name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/instance-manager,ghcr.io/${{ github.repository_owner }}/instance-manager
-
name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
unit-test:
if: github.repository_owner == 'keikoproj'
name: unit-test
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.17
go-version: 1.21

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

Expand All @@ -30,12 +30,14 @@ jobs:
make manager
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3

- name: Test
run: |
make test
- name: Upload to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.txt
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,52 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v0.17.0-alpha2] - 2023-10-30
* Fix incorrect counter name (#409)
* Bump sigs.k8s.io/controller-runtime from 0.12.1 to 0.12.3 (#400)
* Bump github.com/prometheus/client_golang (#403)
* Bump github.com/onsi/gomega from 1.27.10 to 1.28.0 (#404)
* Bump crazy-max/ghaction-docker-meta from 1 to 5 (#407)
* Bump golang.org/x/net from 0.12.0 to 0.17.0 (#408)
* Bump docker/build-push-action from 2 to 5 (#406)
* Bump docker/login-action from 1 to 3 (#405)
* Bump github.com/aws/aws-sdk-go from 1.45.14 to 1.45.19 (#402)
* Bump codecov/codecov-action from 1 to 3 (#395)
* Bump docker/setup-qemu-action from 1 to 3 (#397)
* Bump docker/setup-buildx-action from 1 to 3 (#394)
* Bump actions/setup-go from 2 to 4 (#393)
* Bump actions/checkout from 2 to 4 (#396)
* Add dependabot configuration (#392)
* Update aws-auth and aws-sdk-go-cache (#391)
* Update go to 1.19, client-go to v0.24.14, and controller-runtime to v0.12.1 (#389)
* Set LaunchTemplate as default value for default-scaling-configuration (#387)
* Bump gopkg.in/yaml.v3 (#386)
* Feat: support overriding default scaling configuration (#385)

## [v0.16.0-alpha2] - 2023-09-01
* Make launchtemplates as a default scaling group configuration, instead of launchconfigurations. by @shreyas-badiger in https://github.com/keikoproj/instance-manager/pull/385


## [v0.15.0-alpha2] - 2023-4-17

* fix: functional test by @vgunapati and @garomonegro in (#383) (#382)
* chore: Update functional-test.yaml ubuntu-20.04 by @garomonegro in (#381)
* fix: Not honoring gp3 volume iops and throughput values by @vgunapati in (#380)
* chore(deps): Bump golang.org/x/net (#377)
* chore(deps): Bump github.com/prometheus/client_golang (#375)
* fix: Replace ARN format validation procedure by @srosenberg-apptio in (#374)
* fix: remove spot dependency from functional test by @eytan-avisror in (#360)
* feat: add support for container runtime on windows AMIs by @backjo in (#359)
* chore: Add CodeQL analysis by @backjo in (#358)
* feat: use IMDS for autoscaling information by @backjo in (#357)

## [v0.14.1-alpha2] - 2022-4-6
* fix: use non-deprecated CRD api by @backjo in https://github.com/keikoproj/instance-manager/pull/355
* chore: upgrade dependencies by @eytan-avisror in https://github.com/keikoproj/instance-manager/pull/353
* feat: allow resolving EKS AMIs by version/slug for better readability by @backjo in https://github.com/keikoproj/instance-manager/pull/351
* fix: Add override instance type for running instances in MixedInstancePolicy by @eytan-avisror in https://github.com/keikoproj/instance-manager/pull/350

## [v0.14.0-alpha2] - 2022-2-14
* feat: add support for calculating max pods when prefix assignment is … by @backjo in https://github.com/keikoproj/instance-manager/pull/326
* fix: check architecture when considering similar instance types in the same family by @backjo in https://github.com/keikoproj/instance-manager/pull/332
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.17 as builder
FROM --platform=$BUILDPLATFORM golang:1.21 as builder
ARG TARGETOS TARGETARCH
WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export GO111MODULE=on

CONTROLLER_GEN_VERSION := v0.4.1
GO_MIN_VERSION := 11500 # go1.15
GO_MIN_VERSION := 12000 # go1.20

define generate_int_from_semver
echo $(1) |cut -dv -f2 |awk '{split($$0,a,"."); print a[3]+(100*a[2])+(10000* a[1])}'
Expand Down Expand Up @@ -29,16 +29,13 @@ GO_LDFLAGS ?= -ldflags="-s -w"
IMG ?= instance-manager:latest
INSTANCEMGR_TAG ?= latest

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

.PHONY: all
all: check-go test clean manager

# Run tests
.PHONY: test
test: generate fmt vet manifests
go test -v ./controllers/... ./api/... -coverprofile coverage.txt
go test ./controllers/... ./api/... -coverprofile coverage.txt

.PHONY: bdd
bdd:
Expand Down Expand Up @@ -82,7 +79,7 @@ deploy: manifests
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=instance-manager webhook paths="./api/...;./controllers/..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=instance-manager crd webhook paths="./api/...;./controllers/..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
.PHONY: fmt
Expand Down Expand Up @@ -124,7 +121,7 @@ controller-gen: controller-gen-find check-controller-gen
.PHONY: controller-gen-real
controller-gen-find:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand All @@ -133,7 +130,7 @@ endif
.PHONY: check-go
check-go:
ifeq ($(GO_VERSION_CHECK),0)
$(error go1.11 or higher is required)
$(error go 1.20 or higher is required)
endif

.PHONY: lint
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![codecov](https://codecov.io/gh/keikoproj/instance-manager/branch/master/graph/badge.svg?token=IJbjmSBliL)](https://codecov.io/gh/keikoproj/instance-manager)
[![Go Report Card](https://goreportcard.com/badge/github.com/keikoproj/instance-manager)](https://goreportcard.com/report/github.com/keikoproj/instance-manager)
[![slack](https://img.shields.io/badge/slack-join%20the%20conversation-ff69b4.svg)][SlackUrl]
![version](https://img.shields.io/badge/version-0.14.1-blue.svg?cacheSeconds=2592000)
![version](https://img.shields.io/badge/version-0.17.0-blue.svg?cacheSeconds=2592000)
> Create and manage instance groups with Kubernetes.
**instance-manager** simplifies the creation of worker nodes from within a Kubernetes cluster and creates `InstanceGroup` objects in your cluster. Additionally, **instance-manager** will provision the actual machines and bootstrap them to the cluster.
Expand Down
23 changes: 19 additions & 4 deletions api/v1alpha1/instancegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ type InstanceGroupStatus struct {

type InstanceGroupConditionType string

type ValidationOverrides struct {
scalingConfigurationOverride *ScalingConfigurationType
}

func NewValidationOverrides(defaultScalingConfiguration *ScalingConfigurationType) *ValidationOverrides {
return &ValidationOverrides{
scalingConfigurationOverride: defaultScalingConfiguration,
}
}
func NewInstanceGroupCondition(cType InstanceGroupConditionType, status corev1.ConditionStatus) InstanceGroupCondition {
return InstanceGroupCondition{
Type: cType,
Expand Down Expand Up @@ -409,7 +418,7 @@ func (ig *InstanceGroup) Locked() bool {
return false
}

func (s *EKSSpec) Validate() error {
func (s *EKSSpec) Validate(overrides *ValidationOverrides) error {
var (
configuration = s.EKSConfiguration
configType = s.Type
Expand All @@ -419,7 +428,13 @@ func (s *EKSSpec) Validate() error {
}

if s.Type != LaunchConfiguration && s.Type != LaunchTemplate {
s.Type = LaunchConfiguration
s.Type = LaunchTemplate
if overrides.scalingConfigurationOverride != nil {
if *overrides.scalingConfigurationOverride != LaunchTemplate && *overrides.scalingConfigurationOverride != LaunchConfiguration {
return errors.Errorf("validation failed, 'scaling-configuration-override' has invalid value: %v ", *overrides.scalingConfigurationOverride)
}
s.Type = *overrides.scalingConfigurationOverride
}
}

if s.Type == LaunchConfiguration {
Expand Down Expand Up @@ -700,7 +715,7 @@ func (m *MixedInstancesPolicySpec) Validate() error {
return nil
}

func (ig *InstanceGroup) Validate() error {
func (ig *InstanceGroup) Validate(overrides *ValidationOverrides) error {
s := ig.Spec

if !common.ContainsEqualFold(Provisioners, s.Provisioner) {
Expand Down Expand Up @@ -735,7 +750,7 @@ func (ig *InstanceGroup) Validate() error {
config := ig.GetEKSConfiguration()
spec := ig.GetEKSSpec()

if err := spec.Validate(); err != nil {
if err := spec.Validate(overrides); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 1eefe38

Please sign in to comment.