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

Automated cherry pick of #205: Bump dependencies to v1.21.0 #308: Add tagging controller configuration #317: Fix version #334: Stop retrying failed workitem after a certain amount of #359

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
449aa0f
Bump dependencies to v1.21.0
nckturner Apr 20, 2021
4bce33b
Add tagging controller configuration
nguyenkndinh Feb 23, 2022
5160383
add log
nguyenkndinh Feb 23, 2022
fc62809
rearrange the controllers
nguyenkndinh Feb 23, 2022
78ae250
remove debugging log
nguyenkndinh Feb 24, 2022
eaa794b
removed route controller
nguyenkndinh Feb 24, 2022
e665663
added a blank test file for the tagging controller
nguyenkndinh Feb 24, 2022
d320233
remove predefined tag
nguyenkndinh Feb 24, 2022
d12df0a
Refactoring based on recommendations
nguyenkndinh Mar 1, 2022
39bd0e0
Sticking to the naming convention
nguyenkndinh Mar 1, 2022
e38e366
address more comments on naming
nguyenkndinh Mar 8, 2022
208f52e
Using ListNode to get nodes entering and leaving the cluster.
nguyenkndinh Mar 15, 2022
9118ec0
refactor
nguyenkndinh Mar 15, 2022
af94276
Add testing and controller config skeletons
nguyenkndinh Mar 19, 2022
5450949
Added tagging and flags mechanisms
nguyenkndinh Mar 22, 2022
93df23e
Disabled the tagging controller by default
nguyenkndinh Mar 22, 2022
4e273a7
Updated test structure
nguyenkndinh Mar 23, 2022
5540042
Making the tests more robust
nguyenkndinh Mar 23, 2022
bd3c5b3
Renaming the maps in tagging controller
nguyenkndinh Mar 23, 2022
2501748
Refactoring names and remove debugging logs
nguyenkndinh Mar 23, 2022
0f5a59b
Add failure test cases for when EC2 return error
nguyenkndinh Mar 23, 2022
1d0c737
adding details for --resources
nguyenkndinh Mar 24, 2022
9be3f28
add in Copyright message
nguyenkndinh Mar 24, 2022
d48b900
Using NodeInformer and Workqueue for tagging resources
nguyenkndinh Mar 25, 2022
3b81d12
Used workqueue for both tag and untag actions
nguyenkndinh Mar 25, 2022
c009efd
Update docs/tagging_controller.md
nguyenkndinh Mar 25, 2022
9bb60e8
Renamed fields in the tagging controller to be more user friendly
nguyenkndinh Mar 26, 2022
9a1de57
Added in a loop to make sure all messages are processed before shutti…
nguyenkndinh Mar 26, 2022
f5bb113
Added more logging
nguyenkndinh Mar 26, 2022
54e1329
Added more testing
nguyenkndinh Mar 26, 2022
d322867
cosmetic change
nguyenkndinh Mar 28, 2022
ea21b46
use array instead of map for supported resources
nguyenkndinh Mar 28, 2022
7a8f517
Reworked the workqueue with workitem
nguyenkndinh Mar 28, 2022
2351808
Addressed comments
nguyenkndinh Mar 29, 2022
e32c325
addressed verify-lint errors
nguyenkndinh Mar 29, 2022
a9d8d75
addressed comments and verify-lint
nguyenkndinh Mar 29, 2022
d433e24
address validate-lint error
nguyenkndinh Mar 29, 2022
46167e1
missed a couple more lint errors
nguyenkndinh Mar 29, 2022
8410726
Updated doc to be clearer
nguyenkndinh Mar 29, 2022
6109333
Add TODOs for e2e testing and non-retryable workitem
nguyenkndinh Mar 30, 2022
2b37e3c
Fix version
nckturner Mar 7, 2022
72fbe7c
Stop retrying failed workitem after a certain amount of retries Added…
nguyenkndinh Apr 5, 2022
1ad79e9
Sync Docker and Make files from master
saurav-agarwalla May 11, 2022
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/ecr-credential-provider
/cloudconfig

.vscode/

docs/book/_book/
site/
.vscode/
e2e.test
.idea/
26 changes: 14 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,43 @@
## BUILD ARGS ##
################################################################################
# This build arg allows the specification of a custom Golang image.
ARG GOLANG_IMAGE=golang:1.15.3
ARG GOLANG_IMAGE=golang:1.18.1

# The distroless image on which the CPI manager image is built.
#
# Please do not use "latest". Explicit tags should be used to provide
# deterministic builds. This image doesn't have semantic version tags, but
# the fully-qualified image can be obtained by entering
# "gcr.io/distroless/static:latest" in a browser and then copying the
# fully-qualified image from the web page.
ARG DISTROLESS_IMAGE=gcr.io/distroless/static@sha256:c6d5981545ce1406d33e61434c61e9452dad93ecd8397c41e89036ef977a88f4
# deterministic builds. Follow what kubernetes uses to build
# kube-controller-manager, for example for 1.23.x:
# https://github.com/kubernetes/kubernetes/blob/release-1.24/build/common.sh#L94
ARG DISTROLESS_IMAGE=k8s.gcr.io/build-image/go-runner:v2.3.1-go1.18.1-bullseye.0

################################################################################
## BUILD STAGE ##
################################################################################
# Build the manager as a statically compiled binary so it has no dependencies
# libc, muscl, etc.
FROM ${GOLANG_IMAGE} as builder
FROM --platform=linux/amd64 ${GOLANG_IMAGE} as builder

ARG VERSION
ARG GOPROXY=https://goproxy.io,direct
ARG GOOS=linux
ARG TARGETOS
ARG TARGETARCH
ARG VERSION

WORKDIR /build
COPY go.mod go.sum ./
COPY cmd/ cmd/
COPY pkg/ pkg/
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=${GOOS} GOPROXY=${GOPROXY} go build \
-ldflags="-w -s -X 'main.version=${VERSION}'" \
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOPROXY=${GOPROXY} \
go build \
-trimpath \
-ldflags="-w -s -X k8s.io/component-base/version.gitVersion=${VERSION}" \
-o=aws-cloud-controller-manager \
cmd/aws-cloud-controller-manager/main.go

################################################################################
## MAIN STAGE ##
################################################################################
# Copy the manager into the distroless image.
FROM ${DISTROLESS_IMAGE}
FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}
COPY --from=builder /build/aws-cloud-controller-manager /bin/aws-cloud-controller-manager
ENTRYPOINT [ "/bin/aws-cloud-controller-manager" ]
86 changes: 75 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,70 @@
# limitations under the License.
#

.EXPORT_ALL_VARIABLES:

SHELL := /bin/bash
SOURCES := $(shell find . -name '*.go')
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPROXY ?= $(shell go env GOPROXY)
GIT_VERSION := $(shell git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
GIT_VERSION := $(shell git describe --dirty --tags --match='v*')
VERSION ?= $(GIT_VERSION)
IMAGE := amazon/cloud-controller-manager:$(VERSION)
IMAGE ?= amazon/cloud-controller-manager:$(VERSION)
OUTPUT ?= $(shell pwd)/_output
INSTALL_PATH ?= $(OUTPUT)/bin
LDFLAGS ?= -w -s -X k8s.io/component-base/version.gitVersion=$(VERSION)

aws-cloud-controller-manager: $(SOURCES)
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOPROXY=$(GOPROXY) go build \
-ldflags="-w -s -X 'main.version=$(VERSION)'" \
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=aws-cloud-controller-manager \
cmd/aws-cloud-controller-manager/main.go

ecr-credential-provider: $(shell find ./cmd/ecr-credential-provider -name '*.go')
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOPROXY=$(GOPROXY) go build \
-ldflags="-w -s -X 'main.version=$(VERSION)'" \
ecr-credential-provider: $(shell find ./cmd/ecr-credential-provider -name '*.go')
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=ecr-credential-provider \
cmd/ecr-credential-provider/*.go

ecr-credential-provider.exe: $(wildcard ./cmd/ecr-credential-provider/*.go)
GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=ecr-credential-provider.exe \
cmd/ecr-credential-provider/*.go

.PHONY: docker-build-amd64
docker-build-amd64:
docker buildx build --output=type=docker \
--build-arg VERSION=$(VERSION) \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/amd64 \
--tag $(IMAGE) .

.PHONY: docker-build-arm64
docker-build-arm64:
docker buildx build --output=type=docker \
--build-arg VERSION=$(VERSION) \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/arm64 \
--tag $(IMAGE) .

.PHONY: docker-build
docker-build:
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg GOOS=$(GOOS) \
docker buildx build --output=type=registry \
--build-arg LDFLAGS=$(LDFLAGS) \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/amd64,linux/arm64 \
--tag $(IMAGE) .

e2e.test:
pushd tests/e2e > /dev/null && \
go test -c && popd
mv tests/e2e/e2e.test e2e.test

.PHONY: check
check: verify-fmt verify-lint vet

Expand All @@ -53,7 +90,7 @@ verify-fmt:

.PHONY: verify-lint
verify-lint:
which golint 2>&1 >/dev/null || go get golang.org/x/lint/golint
which golint 2>&1 >/dev/null || go install golang.org/x/lint/golint@latest
golint -set_exit_status $(shell go list ./...)

.PHONY: verify-codegen
Expand All @@ -75,3 +112,30 @@ docs:
.PHONY: publish-docs
publish-docs:
./hack/publish-docs.sh

.PHONY: kops-example
kops-example:
./hack/kops-example.sh

.PHONY: test-e2e
test-e2e: e2e.test docker-build-amd64 install-e2e-tools
AWS_REGION=us-west-2 \
TEST_PATH=./tests/e2e/... \
BUILD_IMAGE=$(IMAGE) \
BUILD_VERSION=$(VERSION) \
INSTALL_PATH=$(INSTALL_PATH) \
GINKGO_FOCUS="\[cloud-provider-aws-e2e\]" \
./hack/e2e/run.sh

# Use `make install-e2e-tools KOPS_ROOT=<local-kops-installation>`
# to skip the kops download, test local changes to the kubetest2-kops
# deployer, etc.
.PHONY: install-e2e-tools
install-e2e-tools:
mkdir -p $(INSTALL_PATH)
INSTALL_PATH=$(INSTALL_PATH) \
./hack/install-e2e-tools.sh

.PHONY: print-image-tag
print-image-tag:
@echo $(IMAGE)
Loading