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

v1: Reimplement reconciliation with server-side apply #17

Merged
merged 40 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
862a3b5
Add server-side apply utilities (pkg/resmgr)
stefanprodan Aug 30, 2021
5ce258f
Refactor CI
stefanprodan Aug 30, 2021
73cd092
Add filename validation
stefanprodan Aug 30, 2021
3713811
Refactor ResourceManager
stefanprodan Aug 31, 2021
4d6a313
Add inventory package
stefanprodan Aug 31, 2021
bcc76fd
Implement garbage collection
stefanprodan Aug 31, 2021
107f1ab
Add garbage collection e2e tests
stefanprodan Aug 31, 2021
8566740
Implement deletion based on inventory
stefanprodan Aug 31, 2021
b031784
Add metadata to the inventory configmap
stefanprodan Aug 31, 2021
de9193b
Global inventory manager
stefanprodan Aug 31, 2021
cda56e7
Implement build command
stefanprodan Aug 31, 2021
1e970e6
Add e2e test for kustomize overlays pruning
stefanprodan Aug 31, 2021
67c386d
Apply mutating and validating webhooks last
stefanprodan Sep 1, 2021
97bcdc3
Update controller-runtime to v0.10.0
stefanprodan Sep 1, 2021
104e922
Add load test to CI
stefanprodan Sep 1, 2021
10c6940
Implement staged apply for CRDs+CRs
stefanprodan Sep 1, 2021
8bc5df4
Add staged apply e2e test (cert-manager)
stefanprodan Sep 1, 2021
b0755c2
Implement diff command
stefanprodan Sep 1, 2021
80d675d
Remove managed fields from diff output
stefanprodan Sep 2, 2021
73ce16c
Mask secrets in diff output
stefanprodan Sep 2, 2021
01094d2
Refactor resource manager
stefanprodan Sep 2, 2021
cdf7e25
Remove sensitive data from secrets validation errors
stefanprodan Sep 2, 2021
636be1b
Improve delete cmd output
stefanprodan Sep 2, 2021
7d6d2eb
Detect immutable secrets
stefanprodan Sep 2, 2021
f3dee1c
Setup controller-runtime envtest
stefanprodan Sep 2, 2021
612fadd
Add resource manager apply tests
stefanprodan Sep 2, 2021
faf3464
Refactor resource manager apply tests
stefanprodan Sep 3, 2021
0951544
Add diff tests
stefanprodan Sep 3, 2021
e5583cf
Add delete tests
stefanprodan Sep 3, 2021
cbfd86c
Run tests with race detection
stefanprodan Sep 3, 2021
9d50a5c
Refactor package structure
stefanprodan Sep 3, 2021
2ce8667
Add owner labels before apply
stefanprodan Sep 3, 2021
d2edcb0
Refactor inventory manager
stefanprodan Sep 3, 2021
225df6e
Add benchmark for apply
stefanprodan Sep 3, 2021
b7067df
Use cli-utils/pkg/ordering
stefanprodan Sep 5, 2021
ec3485e
Do apply in stages and fix replicas conflicts
stefanprodan Sep 6, 2021
ddd10a7
Update readme to v1
stefanprodan Sep 6, 2021
e44c210
Update install instructions
stefanprodan Sep 6, 2021
a9348df
Implement get inventory command
stefanprodan Sep 6, 2021
47a81fd
List inventories in tabular view
stefanprodan Sep 7, 2021
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
6 changes: 0 additions & 6 deletions .github/actions/kustomize/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions .github/actions/kustomize/action.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/actions/kustomize/entrypoint.sh

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/action-test.yaml

This file was deleted.

56 changes: 42 additions & 14 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: e2e

on:
pull_request:
branches: [main]
push:
branches:
- master
branches: [main]

jobs:
kind:
Expand All @@ -22,32 +22,60 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
go-version: 1.16.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.5.0
- name: Setup Kustomize
uses: ./.github/actions/kustomize
with:
version: v0.11.1
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
- name: Run test
run: make test
run: make test-race
- name: Check if working tree is dirty
run: |
if [[ $(git diff --stat) != '' ]]; then
echo 'run make test and commit changes'
exit 1
fi
- name: Build
run: sudo go build -o ./bin/kustomizer ./cmd/kustomizer
- name: Smoke tests
run: make build
- name: Test apply --kustomize
run: |
./bin/kustomizer apply -i kustomizer-test -k testdata/kustomize/ --wait --prune
kubectl -n kustomizer-test get tests 2>&1 | grep custom-resource-test1
- name: Test diff --kustomize
run: |
echo "diff=test" >> testdata/kustomize/test.conf
./bin/kustomizer diff -i kustomizer-test -k testdata/kustomize/ --prune 2>&1 | grep drifted
- name: Test diff secret marks
run: |
echo "diff=test" >> testdata/kustomize/secret.conf
./bin/kustomizer diff -i kustomizer-test -k testdata/kustomize/ 2>&1 | grep -F "secret.conf: '******'"
- name: Test apply --filename
run: |
./bin/kustomizer apply -i kustomizer-demo -f testdata/plain/ --wait --prune
kubectl -n kustomizer-test get svc frontend 2>&1 | grep frontend
- name: Test apply --prune
run: |
./bin/kustomizer apply testdata/plain/ --name=test --revision=1.0.0
kubectl -n kustomizer-demo get svc frontend 2>&1 | grep frontend
rm -rf testdata/plain/frontend
./bin/kustomizer apply testdata/plain/ --name=test --revision=1.1.0
./bin/kustomizer apply -i kustomizer-demo -f testdata/plain/ --wait --prune
kubectl -n kustomizer-demo get svc frontend 2>&1 | grep NotFound
./bin/kustomizer delete --name=test
- name: Test delete --wait
run: |
./bin/kustomizer delete -i kustomizer-demo --wait
kubectl get ns kustomizer-demo 2>&1 | grep NotFound
./bin/kustomizer delete -i kustomizer-test --wait
kubectl get crd tests.testing.kustomizer.dev 2>&1 | grep NotFound
- name: Load test apply (110 objects)
run: |
./bin/kustomizer apply -i load-test -k ./testdata/loadtest/
- name: Load test delete (110 objects)
run: |
./bin/kustomizer delete -i load-test
- name: Test staged apply
run: |
./bin/kustomizer apply -i cert-test -k ./testdata/certs/ --prune --wait
kubectl -n kustomizer-cert-test wait issuers/my-ca-issuer --for=condition=ready --timeout=1m
- name: Debug failure
if: failure()
run: |
kubectl version --client --short
kubectl -n default get configmaps -oyaml
kubectl -n kustomizer-demo get all
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
# Dependency directories (remove the comment below to include it)
# vendor/

bin/
bin/
testbin/
15 changes: 0 additions & 15 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,3 @@ archives:
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- LICENSE
brews:
- tap:
owner: stefanprodan
name: kustomizer

folder: Formula
homepage: "https://kustomizer.dev/"
description: "Kustomize build, apply, prune command-line utility."

dependencies:
- name: kubectl
type: optional

test: |
system "#{bin}/kustomizer --version"
34 changes: 0 additions & 34 deletions Formula/kustomizer.rb

This file was deleted.

52 changes: 40 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION?=$(shell grep 'VERSION' cmd/kustomizer/main.go | awk '{ print $$4 }' | tr -d '"')
# Kustomizer test, build, install makefile

all: test build

Expand All @@ -11,33 +11,61 @@ fmt:
vet:
go vet ./...

test: tidy fmt vet
go test ./... -coverprofile cover.out

build:
CGO_ENABLED=0 go build -o ./bin/kustomizer ./cmd/kustomizer

install:
go install cmd/kustomizer
go install ./cmd/kustomizer

install-dev:
CGO_ENABLED=0 go build -o /usr/local/bin ./cmd/kustomizer

install-plugin:
CGO_ENABLED=0 go build -o /usr/local/bin/kubectl-kustomizer ./cmd/kustomizer

release:
git tag "v$(VERSION)"
git push origin "v$(VERSION)"
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
ENVTEST_AKUBERNETES_VERSION=latest
install-envtest: setup-envtest
$(SETUP_ENVTEST) use $(ENVTEST_AKUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR)

KUBEBUILDER_ASSETS?="$(shell $(SETUP_ENVTEST) use -i $(ENVTEST_AKUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
test: tidy fmt vet install-envtest
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... -v -parallel 4 -coverprofile cover.out

test-race: tidy fmt vet install-envtest
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... -v -race -parallel 4 -coverprofile cover.out

test-bench:
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... -v -bench=. -run=none

ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

setup-envtest:
ifeq (, $(shell which setup-envtest))
@{ \
set -e ;\
SETUP_ENVTEST_TMP_DIR=$$(mktemp -d) ;\
cd $$SETUP_ENVTEST_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-runtime/tools/setup-envtest@latest ;\
rm -rf $$SETUP_ENVTEST_TMP_DIR ;\
}
SETUP_ENVTEST=$(GOBIN)/setup-envtest
else
SETUP_ENVTEST=$(shell which setup-envtest)
endif

.PHONY: release-docs
release-docs:
git checkout master && git pull; \
git checkout main && git pull; \
README=$$(cat README.md); \
git checkout gh-pages && git pull; \
echo "$$README" > README.md; \
git add -A; \
git add README.md; \
git commit -m "update docs"; \
git push origin gh-pages; \
git checkout master

git checkout main
Loading