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

Refactor for v2 #103

Merged
merged 51 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2269bff
Refactor controller code
slok Mar 18, 2020
fc08518
Fix examples
slok Mar 18, 2020
07cb9fe
Clean and fix integration tests after refactor
slok Mar 18, 2020
025c80a
Update dependencies
slok Mar 18, 2020
00f8861
Decouple controller handler metrics into a decorator
slok Mar 19, 2020
9a71cc2
Fix Kind image version
slok Mar 19, 2020
b97ec3f
Merge pull request #83 from slok/refactor
slok Mar 19, 2020
7a7212c
Merge pull request #84 from slok/refactor-metrics
slok Mar 19, 2020
7e210f7
Split controller processor logic into an internal type
slok Mar 20, 2020
79cb6d5
Merge pull request #85 from slok/refactor-processor
slok Mar 20, 2020
8ae0ce5
Refactor log package
slok Mar 21, 2020
26cc598
Minor changes
slok Mar 21, 2020
8fd47c6
Merge pull request #86 from slok/refactor-logs
slok Mar 22, 2020
2c7965c
Refactor retriever
slok Mar 22, 2020
53f9470
Merge pull request #87 from slok/refactor-retriever
slok Mar 25, 2020
2908896
Refactor metrics
slok Mar 27, 2020
5209dc9
Merge pull request #88 from slok/slok/metrics-refactor
slok Mar 28, 2020
1d5f648
Refactor metrics and the internal queue
slok Apr 1, 2020
7e0ce7f
Update changelog
slok Apr 2, 2020
292e9f5
Merge pull request #89 from slok/slok/metrics-refactor
slok Apr 3, 2020
47d77a3
Remove Delete from handler
slok Apr 7, 2020
dc1d470
Merge pull request #90 from slok/slok/gc
slok Apr 8, 2020
0317100
Don't measure queue events on queue shutdown
slok Apr 8, 2020
99b9ba3
Merge pull request #91 from slok/slok/gc
slok Apr 8, 2020
3abdd6b
Refactor docs
slok Apr 12, 2020
3d81fa1
Merge pull request #92 from slok/slok/docs
slok Apr 12, 2020
2539de4
Update non K8s deps
slok Apr 12, 2020
efd5301
Merge pull request #93 from slok/slok/update-deps
slok Apr 12, 2020
3779c9b
Add multiple Kubernetes versions on integration tests
slok Apr 12, 2020
7005c5b
Merge pull request #94 from slok/slok/integration-k8s-vers
slok Apr 12, 2020
cc7b727
Update Kooper for Kubernetes v1.17
slok Apr 13, 2020
e5b31df
Merge pull request #95 from slok/slok/k8s-1.17
slok Apr 13, 2020
5d9a12e
Remove multiretriever and update the example to have the same functio…
slok May 3, 2020
4bf03ec
Fix metrics
slok May 3, 2020
fa85290
Improve docs
slok May 3, 2020
9a5c290
Merge pull request #96 from slok/refactor
slok May 3, 2020
bc19092
Add disabling resync on controllers
slok May 3, 2020
0c437d8
Merge pull request #97 from slok/refactor
slok May 3, 2020
b81ba14
Clean format and old code
slok May 6, 2020
f3dfc95
Update readme
slok May 6, 2020
cd306a3
Add code checks, improve test execution with race detection and clean…
slok May 6, 2020
c6bb466
Merge pull request #98 from slok/slok/checks
slok May 6, 2020
f9797ce
Migrate from Travis to Github actions
slok May 6, 2020
48f68a6
Merge pull request #100 from spotahome/slok/migrate-gh-actions
slok May 6, 2020
91d3c21
Remove compatibility matrix from readme
slok May 6, 2020
c58f100
Merge pull request #101 from slok/slok/readme
slok May 6, 2020
3ceda9e
Get ready for Kooper v2
slok Jul 9, 2020
b686659
Update Readme for v2
slok Jul 10, 2020
1ac02f5
Update README.md
slok Jul 10, 2020
bf29ac8
Improved readme major changes for v2
slok Jul 10, 2020
5c3bdc7
Merge pull request #102 from spotahome/slok/readme
slok Jul 10, 2020
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on: [push, pull_request]

jobs:
check:
name: Check
runs-on: ubuntu-latest
# Execute the checks inside the container instead the VM.
container: golangci/golangci-lint:v1.24.0-alpine
steps:
- uses: actions/checkout@v1
- run: ./hack/scripts/check.sh

unit-test:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v2-beta
with:
go-version: 1.14
- run: make ci-unit-test

integration-test:
name: Integration test
runs-on: ubuntu-latest
needs: [check, unit-test]
strategy:
matrix:
kubernetes: [1.15.7, 1.16.4, 1.17.0, 1.18.0]
env:
KIND_VERSION: v0.7.0
steps:
- uses: actions/checkout@v1
- run: curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- run: curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${{ matrix.kubernetes }}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- run: KUBERNETES_VERSION=${{ matrix.kubernetes }} make ci-integration-test



17 changes: 10 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Binaries for programs and plugins
# Binaries for programs and plugins.
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
# Test binary, build with `go test -c`.
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
# Output of the go coverage tool, specifically when used with LiteIDE.
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736.
.glide/

# binary
# Binary.
bin/

# vendor
vendor/
# Vendor.
vendor/

# Test coverage.
.test_coverage.txt
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

32 changes: 30 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
## [unreleased]

- Support for Kubernetes 1.13.
NOTE: Breaking release in controllers.

- Refactor controller package.
- Refactor metrics package.
- Refactor log package.
- Remove operator concept and remove CRD initialization in favor of using only
controllers and let the CRD initialization outside Kooper (e.g CRD yaml).
- Default resync time to 3 minutes.
- Default workers to 3.
- Disable retry handling on controllers in case of error by default.
- Remove tracing.
- Minimum Go version v1.13 (error wrapping required).
- Refactor Logger with structured logging.
- Add Logrus helper wrapper.
- Refactor to simplify the retrievers.
- Refactor metrics recorder implementation including the prometheus backend.
- Refactor internal controller queue into a decorator implementation approach.
- Remove `Delete` method from `controller.Handler` and simplify to only `Handle` method
- Add `DisableResync` flag on controller configuration to disable the resync of all resources.

## [0.8.0] - 2019-12-11

- Support for Kubernetes 1.15.

## [0.7.0] - 2019-11-26

- Support for Kubernetes 1.14.

## [0.6.0] - 2019-06-01

Expand Down Expand Up @@ -83,7 +109,9 @@ This release breaks controllers constructors to allow passing a metrics recorder
- sequential controller implementation.
- Dependencies managed by dep and vendored.

[unreleased]: https://github.com/spotahome/kooper/compare/v0.6.0...HEAD
[unreleased]: https://github.com/spotahome/kooper/compare/v0.8.0...HEAD
[0.8.0]: https://github.com/spotahome/kooper/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/spotahome/kooper/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/spotahome/kooper/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/spotahome/kooper/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/spotahome/kooper/compare/v0.4.1...v0.5.0
Expand Down
93 changes: 25 additions & 68 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,103 +1,60 @@

# Name of this service/application
SERVICE_NAME := kooper

# Path of the go service inside docker
DOCKER_GO_SERVICE_PATH := /src

# Shell to use for running scripts
SHELL := $(shell which bash)

# Get docker path or an empty string
DOCKER := $(shell command -v docker)

# Get the main unix group for the user running make (to be used by docker-compose later)
OSTYPE := $(shell uname)
GID := $(shell id -g)

# Get the unix user id for the user running make (to be used by docker-compose later)
UID := $(shell id -u)

# cmds
UNIT_TEST_CMD := ./hack/scripts/unit-test.sh
INTEGRATION_TEST_CMD := ./hack/scripts/integration-test.sh
CI_INTEGRATION_TEST_CMD := ./hack/scripts/integration-test-kind.sh
MOCKS_CMD := ./hack/scripts/mockgen.sh
DOCKER_RUN_CMD := docker run -v ${PWD}:$(DOCKER_GO_SERVICE_PATH) --rm -it $(SERVICE_NAME)
RUN_EXAMPLE_POD_ECHO := go run ./examples/echo-pod-controller/cmd/* --development
RUN_EXAMPLE_POD_ECHO_ONEFILE := go run ./examples/onefile-echo-pod-controller/main.go --development
RUN_EXAMPLE_POD_TERM := go run ./examples/pod-terminator-operator/cmd/* --development
DEPS_CMD := GO111MODULE=on go mod tidy && GO111MODULE=on go mod vendor
K8S_VERSION := "1.15.6"
SET_K8S_DEPS_CMD := GO111MODULE=on go mod edit \
-require=k8s.io/apiextensions-apiserver@kubernetes-${K8S_VERSION} \
-require=k8s.io/client-go@kubernetes-${K8S_VERSION} \
-require=k8s.io/apimachinery@kubernetes-${K8S_VERSION} \
-require=k8s.io/api@kubernetes-${K8S_VERSION} \
-require=k8s.io/kubernetes@v${K8S_VERSION} && \
$(DEPS_CMD)
DOCKER_RUN_CMD := docker run --env ostype=$(OSTYPE) -v ${PWD}:/src --rm -it ${SERVICE_NAME}
DEPS_CMD := go mod tidy
CHECK_CMD := ./hack/scripts/check.sh


# environment dirs
DEV_DIR := docker/dev
help: ## Show this help
@echo "Help"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[93m %s\n", $$1, $$2}'

# The default action of this Makefile is to build the development docker image
.PHONY: default
default: build
default: help

# Test if the dependencies we need to run this Makefile are installed
.PHONY: deps-development
deps-development:
ifndef DOCKER
@echo "Docker is not available. Please install docker"
@exit 1
endif

# Build the development docker image
.PHONY: build
build:
build: ## Build the development docker image.
docker build -t $(SERVICE_NAME) --build-arg uid=$(UID) --build-arg gid=$(GID) -f ./docker/dev/Dockerfile .

# Dependency stuff.
.PHONY: set-k8s-deps
set-k8s-deps:
$(SET_K8S_DEPS_CMD)

.PHONY: deps
deps:
deps: ## Updates the required dependencies.
$(DEPS_CMD)

# Test stuff in dev
.PHONY: unit-test
unit-test: build
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)'
.PHONY: integration-test
integration-test: build
integration-test: build ## Runs integration tests out of CI.
echo "[WARNING] Requires a kubernetes cluster configured (and running) on your kubeconfig!!"
$(INTEGRATION_TEST_CMD)

.PHONY: test
test: unit-test
test: build ## Runs unit tests out of CI.
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)'

.PHONY: check
check: build ## Runs checks.
@$(DOCKER_RUN_CMD) /bin/sh -c '$(CHECK_CMD)'

# Test stuff in ci
.PHONY: ci-unit-test
ci-unit-test:
ci-unit-test: ## Runs unit tests in CI.
$(UNIT_TEST_CMD)

.PHONY: ci-integration-test
ci-integration-test:
ci-integration-test: ## Runs integration tests in CI.
$(CI_INTEGRATION_TEST_CMD)
.PHONY: ci

.PHONY: ci ## Runs all tests in CI.
ci: ci-unit-test ci-integration-test

# Mocks stuff in dev
.PHONY: mocks
mocks: build
mocks: build ## Generates mocks.
$(DOCKER_RUN_CMD) /bin/sh -c '$(MOCKS_CMD)'

# Run examples.
.PHONY: controller-example
controller-example:
$(RUN_EXAMPLE_POD_ECHO)
.PHONY: controller-example-onefile
controller-example-onefile:
$(RUN_EXAMPLE_POD_ECHO_ONEFILE)
.PHONY: operator-example
operator-example:
$(RUN_EXAMPLE_POD_TERM)
Loading