Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.25'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -30,4 +30,4 @@ jobs:
uses: fnkr/github-action-ghr@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHR_PATH: bin/manager
GHR_PATH: bin/manager
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.25'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: make all
- name: Test
run: make test
run: make test
29 changes: 24 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
version: "2"
linters:
enable:
- revive
linters-settings:
revive:
rules:
- name: dot-imports
disabled: true
settings:
revive:
rules:
- name: dot-imports
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
126 changes: 58 additions & 68 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.27.1
ENVTEST_K8S_VERSION = 1.31.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -29,7 +29,7 @@ all: build

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
Expand All @@ -56,22 +56,26 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: lint
lint: golangci ## Run golangci
$(LOCALBIN)/golangci-lint run

.PHONY: gen-doc
gen-doc: crdoc ## Run golangci
$(LOCALBIN)/crdoc --resources config/crd/bases/ --output DOC.md

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: setup-kubebuilder-assets
setup-kubebuilder-assets:
$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path

.PHONY: test
test: manifests generate fmt vet envtest lint ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --fix

##@ Build

.PHONY: build
Expand All @@ -82,8 +86,8 @@ build: manifests generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
Expand All @@ -93,12 +97,12 @@ docker-build: test ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
Expand All @@ -110,15 +114,11 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

HELMIFY ?= $(LOCALBIN)/helmify

.PHONY: helmify
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest

helm: manifests kustomize helmify
$(KUSTOMIZE) build config/default | $(HELMIFY)
.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml

##@ Deployment

Expand Down Expand Up @@ -155,56 +155,46 @@ KUBECTL ?= kubectl
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
KIND ?= $(LOCALBIN)/kind
KINDCLUSTER ?= ndb
KINDCONFIG ?= $(shell pwd)/.kubecfg
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint

## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.1
CONTROLLER_TOOLS_VERSION ?= v0.14.0
KIND_VERSION ?= v0.20.0
KUSTOMIZE_VERSION ?= v5.7.1
CONTROLLER_TOOLS_VERSION ?= v0.19.0
ENVTEST_VERSION ?= release-0.22
GOLANGCI_LINT_VERSION ?= v2.6.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/kustomize; \
fi
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: golangci
golangci: ## Run golangci
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

.PHONY: crdoc
crdoc: ## Run crdoc
test -s $(LOCALBIN)/crdoc|| GOBIN=$(LOCALBIN) go install fybrik.io/crdoc@v0.6.3

$(KIND): $(LOCALBIN)
test -s $(LOCALBIN)/kind || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kind@$(KIND_VERSION)

.PHONY: kind-init
kind-init: $(KINDCONFIG)
$(KINDCONFIG): $(KIND)
$(KIND) create cluster --name $(KINDCLUSTER) --config hack/cluster.yml --kubeconfig $(KINDCONFIG)

.PHONY: kind-load
kind-load: $(KINDCONFIG) docker-build
$(KIND) load docker-image $(IMG) --name $(KINDCLUSTER)

.PHONY: kind-cleanup
kind-cleanup: $(KIND)
$(KIND) delete cluster --name $(KINDCLUSTER)
rm -f $(KINDCONFIG)
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
# $3 - specific version of package
define go-install-tool
@[ -f "$(1)-$(3)" ] || { \
set -e; \
package=$(2)@$(3) ;\
echo "Downloading $${package}" ;\
rm -f $(1) || true ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv $(1) $(1)-$(3) ;\
} ;\
ln -sf $(1)-$(3) $(1)
endef
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,22 @@ UnDeploy the controller from the cluster:
make undeploy
```

## Application manager client


Install the swagger code generator

```sh
CGO_ENABLED=0 go install github.com/go-swagger/go-swagger/cmd/swagger@latest
```

Regenerate the client code

```sh
cd ./internal
swagger generate client --spec ../app_manager_openapi.yml -m appmgr -c appmgrcli
```

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Expand Down
10 changes: 8 additions & 2 deletions api/v1alpha1/applicationdisruptionbudget_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ type ApplicationDisruptionBudgetSpec struct {
// It perform a POST http request containing the NodeDisruption that is being validated.
// Maintenance will proceed only if the endpoint responds 2XX.
// +kubebuilder:validation:Optional
HealthHook HealthHookSpec `json:"healthHook,omitempty"`
HealthHook HookSpec `json:"healthHook,omitempty"`

// HookV2BasePath holds the base path for the prepare, ready, cancel hooks that will be
// called at different stages of the NodeDisruption lifecycle.
// A POST http request containing a Disruption that is being reconciled is sent ot each of the hooks.
// +kubebuilder:validation:Optional
HookV2BasePath HookSpec `json:"hookV2BasePath,omitempty"`
}

type HealthHookSpec struct {
type HookSpec struct {
// a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used.
CaBundle string `json:"caBundle,omitempty"`
// URL that will be called by the hook, in standard URL form (`scheme://host:port/path`).
Expand Down
12 changes: 11 additions & 1 deletion api/v1alpha1/nodedisruption_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ type NodeDisruptionSpec struct {

// Label query over nodes that will be impacted by the disruption
NodeSelector metav1.LabelSelector `json:"nodeSelector,omitempty"`
Retry RetrySpec `json:"retry,omitempty"`

// StartDate when the disruption should start
StartDate metav1.Time `json:"startDate,omitempty"`

// Duration of the disruption once granted
Duration metav1.Duration `json:"duration,omitempty"`

// Retry configuration allows to retry a disruption after rejection until the given deadline
Retry RetrySpec `json:"retry,omitempty"`

// Type of the node disruption
Type string `json:"type,omitempty"`
}
Expand Down Expand Up @@ -92,6 +101,7 @@ type NodeDisruptionStatus struct {
type DisruptedBudgetStatus struct {
Reference NamespacedName `json:"reference,omitempty"`
Reason string `json:"reason"`
Preparing bool `json:"preparing"`
Ok bool `json:"ok"`
}

Expand Down
11 changes: 7 additions & 4 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
Loading