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

v1beta2 API support and replicating resources across Tenant namespaces #644

Merged
merged 26 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8899c03
perf(dockerfile): using go modules caching
prometherion Sep 21, 2022
940a109
chore(makefile): downloading locally golangci-lint
prometherion Sep 22, 2022
191e13a
chore(controller-gen): upgrading to 0.10.0
prometherion Oct 28, 2022
bdac162
feat: introducing v1beta2 api group
prometherion Sep 20, 2022
884016c
chore(kustomize): introducing v1beta2 api group
prometherion Sep 20, 2022
0e4c747
chore(helm)!: introducing v1beta2 api group
prometherion Sep 20, 2022
f3f9f01
feat: support for ca update on crds objects
prometherion Sep 20, 2022
f6e6918
docs: introducing v1beta2 api group
prometherion Sep 20, 2022
aca062f
refactor: abstracting types used by several api versions
prometherion Sep 27, 2022
f4ae20a
chore(lint): adding goheader rule and removing unused ones
prometherion Oct 13, 2022
92a1b09
style: conforming go files headers
prometherion Oct 13, 2022
81206c1
refactor: using interfaces for accessing tenant namespaces
prometherion Oct 13, 2022
d11910b
feat(api): globaltenantresource and tenantresource support
prometherion Oct 13, 2022
6a0de88
chore(kustomize): globaltenantresource and tenantresource support
prometherion Oct 28, 2022
0fb2df9
chore(helm)!: globaltenantresource and tenantresource support
prometherion Oct 13, 2022
8cbdecf
feat: globaltenantresource and tenantresource reconciliation
prometherion Oct 13, 2022
5076393
test: globaltenantresource and tenantresource support
prometherion Oct 13, 2022
f3d3160
docs: globaltenantresource and tenantresource support
prometherion Oct 13, 2022
ac073f5
refactor(test): generating namespace names avoiding collision
prometherion Oct 28, 2022
682862b
feat: refactor resources controller
MaxFedotov Oct 27, 2022
a2f1dc7
refactor: deprecating tenant v1alpha1 version
prometherion Oct 28, 2022
c7b6636
style: kubebuilder annotations start with empty space
prometherion Oct 28, 2022
4f71650
chore(helm)!: release of v0.2.0
prometherion Oct 13, 2022
f0032e4
feat: support for kubernetes 1.25
prometherion Nov 19, 2022
a1910fa
test: support for endpointslice/v1 for k8s v1.25
prometherion Nov 19, 2022
f2319c0
fix(makefile): avoid race condition for local kind cluster
prometherion Nov 19, 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
11 changes: 6 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ linters-settings:
- standard
- default
- prefix(github.com/clastix/capsule)
goheader:
template: |-
Copyright 2020-2021 Clastix Labs
SPDX-License-Identifier: Apache-2.0

linters:
enable-all: true
disable:
Expand All @@ -35,12 +40,8 @@ linters:
- varnamelen
- wrapcheck

issues:
exclude:
- Using the variable on range scope .* in function literal

service:
golangci-lint-version: 1.33.x
golangci-lint-version: 1.45.2

run:
skip-files:
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Build the manager binary
FROM golang:1.18 as builder

ARG TARGETARCH
ARG GIT_HEAD_COMMIT
ARG GIT_TAG_COMMIT
ARG GIT_LAST_TAG
ARG GIT_MODIFIED
ARG GIT_REPO
ARG BUILD_DATE

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -17,6 +9,14 @@ COPY go.sum go.sum
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

ARG TARGETARCH
ARG GIT_HEAD_COMMIT
ARG GIT_TAG_COMMIT
ARG GIT_LAST_TAG
ARG GIT_MODIFIED
ARG GIT_REPO
ARG BUILD_DATE

# Copy the go source
COPY main.go main.go
COPY version.go version.go
Expand Down
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# Image URL to use all building/pushing image targets
IMG ?= clastix/capsule:$(VERSION)
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:preserveUnknownFields=false"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -72,14 +70,14 @@ remove: installer

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

apidoc: apidocs-gen
$(APIDOCS_GEN) crdoc --resources config/crd/bases --output docs/content/general/tenant-crd.md --template docs/template/reference-cr.tmpl
$(APIDOCS_GEN) crdoc --resources config/crd/bases --output docs/content/general/crds-apis.md --template docs/template/reference-cr.tmpl

# Helm
SRC_ROOT = $(shell git rev-parse --show-toplevel)
Expand Down Expand Up @@ -164,7 +162,7 @@ docker-push:

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.5.0)
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0)

APIDOCS_GEN = $(shell pwd)/bin/crdoc
apidocs-gen: ## Download crdoc locally if necessary.
Expand Down Expand Up @@ -213,18 +211,22 @@ bundle-build:
goimports:
goimports -w -l -local "github.com/clastix/capsule" .

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected])

# Linting code as PR is expecting
.PHONY: golint
golint:
golangci-lint run -c .golangci.yml
golint: golangci-lint
$(GOLANGCI_LINT) run -c .golangci.yml

# Running e2e tests in a KinD instance
.PHONY: e2e
e2e/%: ginkgo
$(MAKE) e2e-build/$* && $(MAKE) e2e-exec || $(MAKE) e2e-destroy

e2e-build/%:
kind create cluster --name capsule --image=kindest/node:$*
kind create cluster --wait=60s --name capsule --image=kindest/node:$*
make docker-build
kind load docker-image --nodes capsule-control-plane --name capsule $(IMG)
helm upgrade \
Expand All @@ -245,4 +247,3 @@ e2e-exec:

e2e-destroy:
kind delete cluster --name capsule

33 changes: 30 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repo: github.com/clastix/capsule
resources:
- api:
crdVersion: v1
namespaced: false
controller: true
domain: clastix.io
group: capsule
Expand All @@ -21,7 +20,6 @@ resources:
webhookVersion: v1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: clastix.io
group: capsule
Expand All @@ -30,10 +28,39 @@ resources:
version: v1alpha1
- api:
crdVersion: v1
namespaced: false
domain: clastix.io
group: capsule
kind: Tenant
path: github.com/clastix/capsule/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
domain: clastix.io
group: capsule
kind: Tenant
path: github.com/clastix/capsule/api/v1beta2
version: v1beta2
- api:
crdVersion: v1
controller: true
domain: clastix.io
group: capsule
kind: CapsuleConfiguration
path: github.com/clastix/capsule/api/v1beta2
version: v1beta2
- api:
crdVersion: v1
namespaced: true
domain: clastix.io
group: capsule
kind: TenantResource
path: github.com/clastix/capsule/api/v1beta2
version: v1beta2
- api:
crdVersion: v1
domain: clastix.io
group: capsule
kind: GlobalTenantResource
path: github.com/clastix/capsule/api/v1beta2
version: v1beta2
version: "3"
6 changes: 3 additions & 3 deletions api/v1alpha1/additional_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package v1alpha1

type AdditionalMetadataSpec struct {
AdditionalLabels map[string]string `json:"additionalLabels,omitempty"`
AdditionalAnnotations map[string]string `json:"additionalAnnotations,omitempty"`
type AdditionalMetadata struct {
Labels map[string]string `json:"additionalLabels,omitempty"`
Annotations map[string]string `json:"additionalAnnotations,omitempty"`
}
73 changes: 0 additions & 73 deletions api/v1alpha1/allowed_list_test.go

This file was deleted.

3 changes: 3 additions & 0 deletions api/v1alpha1/capsuleconfiguration_annotations.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020-2021 Clastix Labs
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

const (
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/capsuleconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type CapsuleConfigurationSpec struct {
ProtectedNamespaceRegexpString string `json:"protectedNamespaceRegex,omitempty"`
}

// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster

Expand All @@ -31,6 +32,8 @@ type CapsuleConfiguration struct {
Spec CapsuleConfigurationSpec `json:"spec,omitempty"`
}

func (in *CapsuleConfiguration) Hub() {}

// +kubebuilder:object:root=true

// CapsuleConfigurationList contains a list of CapsuleConfiguration.
Expand Down
Loading