Skip to content

Commit

Permalink
deploy: enable multigroup api
Browse files Browse the repository at this point in the history
This commit enables the multigroup api to allow
different group for csi-addons and volume-replication

updates: #116

Signed-off-by: yati1998 <ypadia@redhat.com>
  • Loading branch information
yati1998 authored and mergify[bot] committed Aug 1, 2022
1 parent 620b248 commit d944f60
Show file tree
Hide file tree
Showing 7 changed files with 374 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="{./api/...,./cmd/...,./controllers/...,./sidecar/...}" output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="{./apis/...,./api/...,./cmd/...,./controllers/...,./sidecar/...}" output:crd:artifacts:config=config/crd/bases
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG} rbac-proxy=${RBAC_PROXY_IMG}
$(KUSTOMIZE) build config/crd > deploy/controller/crds.yaml
$(KUSTOMIZE) build config/rbac > deploy/controller/rbac.yaml
Expand Down
17 changes: 17 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
domain: openshift.io
layout:
- go.kubebuilder.io/v3
multigroup: true
projectName: kubernetes-csi-addons
repo: github.com/csi-addons/kubernetes-csi-addons
resources:
Expand Down Expand Up @@ -40,4 +41,20 @@ resources:
kind: PersistentVolumeClaim
path: k8s.io/api/core/v1
version: v1
- api:
crdVersion: v1
namespaced: true
domain: openshift.io
group: replication.storage
kind: VolumeReplication
path: github.com/csi-addons/kubernetes-csi-addons/apis/replication.storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: openshift.io
group: replication.storage
kind: VolumeReplicationClass
path: github.com/csi-addons/kubernetes-csi-addons/apis/replication.storage/v1alpha1
version: v1alpha1
version: "3"
2 changes: 2 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"

csiaddonsv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/v1alpha1"
replicationstoragev1alpha1 "github.com/csi-addons/kubernetes-csi-addons/apis/replication.storage/v1alpha1"
"github.com/csi-addons/kubernetes-csi-addons/controllers"
"github.com/csi-addons/kubernetes-csi-addons/internal/connection"
//+kubebuilder:scaffold:imports
Expand All @@ -51,6 +52,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(csiaddonsv1alpha1.AddToScheme(scheme))
utilruntime.Must(replicationstoragev1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
6 changes: 6 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ resources:
- bases/csiaddons.openshift.io_reclaimspacecronjobs.yaml
- bases/csiaddons.openshift.io_reclaimspacejobs.yaml
- bases/csiaddons.openshift.io_networkfences.yaml
- bases/replication.storage.openshift.io_volumereplications.yaml
- bases/replication.storage.openshift.io_volumereplicationclasses.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_csiaddonsnodes.yaml
#- patches/webhook_in_reclaimspacejobs.yaml
#- patches/webhook_in_volumereplications.yaml
#- patches/webhook_in_volumereplicationclasses.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_csiaddonsnodes.yaml
#- patches/cainjection_in_reclaimspacejobs.yaml
#- patches/cainjection_in_volumereplications.yaml
#- patches/cainjection_in_volumereplicationclasses.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
10 changes: 10 additions & 0 deletions config/manifests/bases/clusterserviceversion.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ spec:
kind: ReclaimSpaceJob
name: reclaimspacejobs.csiaddons.openshift.io
version: v1alpha1
- description: VolumeReplicationClass is the Schema for the volumereplicationclasses API
displayName: Volume Replication Class
kind: VolumeReplicationClass
name: volumereplicationclasses.replication.storage.openshift.io
version: v1alpha1
- description: VolumeReplication is the Schema for the volumereplications API
displayName: Volume Replication
kind: VolumeReplication
name: volumereplications.replication.storage.openshift.io
version: v1alpha1
description: CSI Addons provides the CSI Addons Controller that enables advanced
storage operations for CSI-drivers.
displayName: CSI Addons
Expand Down
85 changes: 85 additions & 0 deletions controllers/csiaddons/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2021 The Kubernetes-CSI-Addons Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

import (
"path/filepath"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

corev1 "k8s.io/api/core/v1"

csiaddonsv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/apis/csiaddons/v1alpha1"
//+kubebuilder:scaffold:imports
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
}

var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: true,
}

cfg, err := testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

err = csiaddonsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

err = corev1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())

}, 60)

var _ = AfterSuite(func() {
By("tearing down the test environment")
err := testEnv.Stop()
Expect(err).NotTo(HaveOccurred())
})
Loading

0 comments on commit d944f60

Please sign in to comment.