Skip to content

Commit 79a8900

Browse files
authored
Merge pull request #271 from gianlucam76/main
Merge dev to main
2 parents a5166f9 + 871a35a commit 79a8900

File tree

68 files changed

+2160
-854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2160
-854
lines changed

Makefile

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ help: ## Display this help.
6060
# Directories.
6161
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
6262
TOOLS_DIR := hack/tools
63-
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
6463
BIN_DIR := bin
64+
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/$(BIN_DIR))
6565

6666
GOBUILD=go build
6767

@@ -82,37 +82,41 @@ KUBECTL := $(TOOLS_BIN_DIR)/kubectl
8282
GOLANGCI_LINT_VERSION := "v1.52.2"
8383

8484
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
85-
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst hack/tools/,,$@) sigs.k8s.io/controller-tools/cmd/controller-gen
85+
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) sigs.k8s.io/controller-tools/cmd/controller-gen
8686

8787
$(ENVSUBST): $(TOOLS_DIR)/go.mod # Build envsubst from tools folder.
88-
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst hack/tools/,,$@) github.com/a8m/envsubst/cmd/envsubst
89-
90-
$(KUSTOMIZE): $(TOOLS_DIR)/go.mod # Build kustomize from tools folder.
91-
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(BIN_DIR)/kustomize sigs.k8s.io/kustomize/kustomize/v4
88+
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) github.com/a8m/envsubst/cmd/envsubst
9289

9390
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
9491
cd $(TOOLS_DIR); ./get-golangci-lint.sh $(GOLANGCI_LINT_VERSION)
9592

9693
$(SETUP_ENVTEST): $(TOOLS_DIR)/go.mod # Build setup-envtest from tools folder.
97-
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst hack/tools/,,$@) sigs.k8s.io/controller-runtime/tools/setup-envtest
94+
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) sigs.k8s.io/controller-runtime/tools/setup-envtest
9895

9996
$(GOIMPORTS):
100-
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst hack/tools/,,$@) golang.org/x/tools/cmd/goimports
97+
cd $(TOOLS_DIR); $(GOBUILD) -tags=tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) golang.org/x/tools/cmd/goimports
10198

10299
$(GINKGO): $(TOOLS_DIR)/go.mod
103-
cd $(TOOLS_DIR) && $(GOBUILD) -tags tools -o $(subst hack/tools/,,$@) github.com/onsi/ginkgo/v2/ginkgo
104-
105-
$(CLUSTERCTL): $(TOOLS_DIR)/go.mod ## Build clusterctl binary
106-
cd $(TOOLS_DIR); $(GOBUILD) -ldflags $(CLUSTERAPI_LDFLAGS) -o $(subst hack/tools/,,$@) sigs.k8s.io/cluster-api/cmd/clusterctl
107-
mkdir -p $(HOME)/.cluster-api # create cluster api init directory, if not present
100+
cd $(TOOLS_DIR) && $(GOBUILD) -tags tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) github.com/onsi/ginkgo/v2/ginkgo
108101

109102
$(KIND): $(TOOLS_DIR)/go.mod
110-
cd $(TOOLS_DIR) && $(GOBUILD) -tags tools -o $(subst hack/tools/,,$@) sigs.k8s.io/kind
103+
cd $(TOOLS_DIR) && $(GOBUILD) -tags tools -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) sigs.k8s.io/kind
104+
105+
$(CLUSTERCTL): $(TOOLS_DIR)/go.mod ## Build clusterctl binary
106+
cd $(TOOLS_DIR); $(GOBUILD) -trimpath -ldflags $(CLUSTERAPI_LDFLAGS) -o $(subst $(TOOLS_DIR)/hack/tools/,,$@) sigs.k8s.io/cluster-api/cmd/clusterctl
107+
mkdir -p $(HOME)/.cluster-api # create cluster api init directory, if not present
111108

112109
$(KUBECTL):
113110
curl -L https://storage.googleapis.com/kubernetes-release/release/$(K8S_LATEST_VER)/bin/$(OS)/$(ARCH)/kubectl -o $@
114111
chmod +x $@
115112

113+
KUSTOMIZE_VER := v4.5.2
114+
KUSTOMIZE_BIN := kustomize
115+
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
116+
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4
117+
$(KUSTOMIZE): # Build kustomize from tools folder.
118+
CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)
119+
116120
.PHONY: tools
117121
tools: $(CONTROLLER_GEN) $(ENVSUBST) $(KUSTOMIZE) $(SETUP_ENVTEST) $(GOLANGCI_LINT) $(GOIMPORTS) $(GINKGO) $(CLUSTERCTL) $(KIND) $(KUBECTL) ## build all tools
118122

@@ -182,7 +186,7 @@ kind-test: test create-cluster fv ## Build docker image; start kind cluster; loa
182186

183187
.PHONY: fv
184188
fv: $(GINKGO) ## Run Sveltos Controller tests using existing cluster
185-
cd test/fv; ../../$(GINKGO) -nodes $(NUM_NODES) --label-filter='FV' --v --trace --randomize-all
189+
cd test/fv; $(GINKGO) -nodes $(NUM_NODES) --label-filter='FV' --v --trace --randomize-all
186190

187191
.PHONY: create-cluster
188192
create-cluster: $(KIND) $(CLUSTERCTL) $(KUBECTL) $(ENVSUBST) ## Create a new kind cluster designed for development
@@ -251,18 +255,18 @@ deploy-projectsveltos: $(KUSTOMIZE)
251255
@echo 'Install libsveltos CRDs'
252256
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_debuggingconfigurations.yaml
253257
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_sveltosclusters.yaml
254-
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_addonconstraints.yaml
258+
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_addoncompliances.yaml
255259

256260
# Install projectsveltos addon-controller components
257261
@echo 'Install projectsveltos addon-controller components'
258-
cd config/manager && ../../$(KUSTOMIZE) edit set image controller=${IMG}
262+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
259263
$(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f-
260264

261265
# Install sveltoscluster-manager
262266
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/sveltoscluster-manager/$(TAG)/manifest/manifest.yaml
263267

264-
# Install addon-constraint-controller
265-
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/addon-constraint-controller/$(TAG)/manifest/manifest.yaml
268+
# Install addon-compliance-controller
269+
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/addon-compliance-controller/$(TAG)/manifest/manifest.yaml
266270

267271
@echo "Waiting for projectsveltos addon-controller to be available..."
268272
$(KUBECTL) wait --for=condition=Available deployment/addon-controller -n projectsveltos --timeout=$(TIMEOUT)
@@ -326,7 +330,7 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
326330

327331
.PHONY: deploy
328332
deploy: manifests $(KUSTOMIZE) ## Deploy controller to the K8s cluster specified in ~/.kube/config.
329-
cd config/manager && ../../$(KUSTOMIZE) edit set image controller=${IMG}
333+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
330334
$(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f -
331335

332336
.PHONY: undeploy

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
<img src="https://raw.githubusercontent.com/projectsveltos/sveltos/main/docs/assets/logo.png" width="200">
1010

11-
Please refere to sveltos [documentation](https://projectsveltos.github.io/sveltos/).
11+
# Useful links
12+
13+
- Projectsveltos [documentation](https://projectsveltos.github.io/sveltos/)
14+
- [Quick Start](https://projectsveltos.github.io/sveltos/quick_start/)
15+
16+
# What is the Projectsveltos?
17+
Projectsveltos is mainly a Kubernetes add-on controller that simplifies the deployment and management of add-ons in Kubernetes clusters. With Sveltos controller, you can easily automate the deployment process and ensure consistency across your cluster environment.
1218

1319
## Addon deployment: how it works
1420

@@ -39,12 +45,13 @@ spec:
3945
- repositoryURL: https://kyverno.github.io/kyverno/
4046
repositoryName: kyverno
4147
chartName: kyverno/kyverno
42-
chartVersion: v2.6.0
48+
chartVersion: v3.0.1
4349
releaseName: kyverno-latest
4450
releaseNamespace: kyverno
4551
helmChartAction: Install
4652
values: |
47-
replicaCount: "{{ .Cluster.spec.topology.controlPlane.replicas }}"
53+
admissionController:
54+
replicas: 3
4855
policyRefs:
4956
- name: storage-class
5057
namespace: default

config/crd/bases/config.projectsveltos.io_clusterconfigurations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.4
6+
controller-gen.kubebuilder.io/version: v0.12.0
77
name: clusterconfigurations.config.projectsveltos.io
88
spec:
99
group: config.projectsveltos.io

config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.4
6+
controller-gen.kubebuilder.io/version: v0.12.0
77
name: clusterprofiles.config.projectsveltos.io
88
spec:
99
group: config.projectsveltos.io

config/crd/bases/config.projectsveltos.io_clusterreports.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.4
6+
controller-gen.kubebuilder.io/version: v0.12.0
77
name: clusterreports.config.projectsveltos.io
88
spec:
99
group: config.projectsveltos.io

config/crd/bases/config.projectsveltos.io_clustersummaries.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.4
6+
controller-gen.kubebuilder.io/version: v0.12.0
77
name: clustersummaries.config.projectsveltos.io
88
spec:
99
group: config.projectsveltos.io

config/rbac/role.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ rules:
194194
- apiGroups:
195195
- lib.projectsveltos.io
196196
resources:
197-
- addonconstraints
197+
- addoncompliances
198198
verbs:
199199
- get
200200
- list
201201
- watch
202202
- apiGroups:
203203
- lib.projectsveltos.io
204204
resources:
205-
- addonconstraints/status
205+
- addoncompliances/status
206206
verbs:
207207
- get
208208
- list

config/samples/config_v1alpha1_clusterprofile.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@ spec:
99
- repositoryURL: https://kyverno.github.io/kyverno/
1010
repositoryName: kyverno
1111
chartName: kyverno/kyverno
12-
chartVersion: v2.5.0
12+
chartVersion: v3.0.1
1313
releaseName: kyverno-latest
1414
releaseNamespace: kyverno
15-
values:
16-
replicaCount: 3
17-
podAnnotations:
18-
annotation1: annotation-value-1
15+
values: |
16+
admissionController:
17+
replicas: 3
1918
helmChartAction: Install
2019
- repositoryURL: https://helm.nginx.com/stable
2120
repositoryName: nginx-stable
2221
chartName: nginx-stable/nginx-ingress
23-
chartVersion: 0.14.0
22+
chartVersion: 0.17.1
2423
releaseName: nginx-latest
2524
releaseNamespace: nginx
2625
helmChartAction: Install
2726
- repositoryURL: https://charts.bitnami.com/bitnami
2827
repositoryName: bitnami
2928
chartName: bitnami/contour
30-
chartVersion: 9.1.2
29+
chartVersion: 12.1.0
3130
releaseName: contour
3231
releaseNamespace: projectcontour
3332
helmChartAction: Install

controllers/chartmanager/chartmanager_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var _ = Describe("Chart manager", func() {
6161
RepositoryURL: "https://kyverno.github.io/kyverno/",
6262
RepositoryName: "kyverno",
6363
ChartName: "kyverno/kyverno",
64-
ChartVersion: "v2.5.0",
64+
ChartVersion: "v3.0.1",
6565
ReleaseName: "kyverno-latest",
6666
ReleaseNamespace: "kyverno",
6767
HelmChartAction: configv1alpha1.HelmChartActionInstall,
@@ -70,7 +70,7 @@ var _ = Describe("Chart manager", func() {
7070
RepositoryURL: "https://helm.nginx.com/stable/",
7171
RepositoryName: "nginx-stable",
7272
ChartName: "nginx-stable/nginx-ingress",
73-
ChartVersion: "0.14.0",
73+
ChartVersion: "0.17.1",
7474
ReleaseName: "nginx-latest",
7575
ReleaseNamespace: "nginx",
7676
HelmChartAction: configv1alpha1.HelmChartActionInstall,
@@ -84,8 +84,7 @@ var _ = Describe("Chart manager", func() {
8484
clusterSummary,
8585
}
8686

87-
c = fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build()
88-
87+
c = fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(initObjects...).WithObjects(initObjects...).Build()
8988
})
9089

9190
AfterEach(func() {
@@ -308,7 +307,7 @@ var _ = Describe("Chart manager", func() {
308307
},
309308
},
310309
}
311-
Expect(c.Status().Update(context.TODO(), clusterSummary)).To(Succeed())
310+
Expect(c.Update(context.TODO(), clusterSummary)).To(Succeed())
312311

313312
// Mark tmpClusterSummary as manager for other release
314313
tmpClusterSummary := &configv1alpha1.ClusterSummary{

controllers/clusterprofile_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (r *ClusterProfileReconciler) SetupWithManager(mgr ctrl.Manager) (controlle
277277

278278
// When projectsveltos cluster changes, according to SveltosClusterPredicates,
279279
// one or more ClusterProfiles need to be reconciled.
280-
err = c.Watch(&source.Kind{Type: &libsveltosv1alpha1.SveltosCluster{}},
280+
err = c.Watch(source.Kind(mgr.GetCache(), &libsveltosv1alpha1.SveltosCluster{}),
281281
handler.EnqueueRequestsFromMapFunc(r.requeueClusterProfileForCluster),
282282
SveltosClusterPredicates(mgr.GetLogger().WithValues("predicate", "sveltosclusterpredicate")),
283283
)
@@ -288,15 +288,15 @@ func (r *ClusterProfileReconciler) SetupWithManager(mgr ctrl.Manager) (controlle
288288
func (r *ClusterProfileReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error {
289289
// When cluster-api cluster changes, according to ClusterPredicates,
290290
// one or more ClusterProfiles need to be reconciled.
291-
if err := c.Watch(&source.Kind{Type: &clusterv1.Cluster{}},
291+
if err := c.Watch(source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
292292
handler.EnqueueRequestsFromMapFunc(r.requeueClusterProfileForCluster),
293293
ClusterPredicates(mgr.GetLogger().WithValues("predicate", "clusterpredicate")),
294294
); err != nil {
295295
return err
296296
}
297297
// When cluster-api machine changes, according to ClusterPredicates,
298298
// one or more ClusterProfiles need to be reconciled.
299-
if err := c.Watch(&source.Kind{Type: &clusterv1.Machine{}},
299+
if err := c.Watch(source.Kind(mgr.GetCache(), &clusterv1.Machine{}),
300300
handler.EnqueueRequestsFromMapFunc(r.requeueClusterProfileForMachine),
301301
MachinePredicates(mgr.GetLogger().WithValues("predicate", "machinepredicate")),
302302
); err != nil {

0 commit comments

Comments
 (0)