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

Storageclusterpeer #2466

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ resources:
kind: StorageRequest
path: github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: ocs
kind: StorageClusterPeer
path: github.com/red-hat-storage/ocs-operator/api/v4/v1
version: v1
version: "3"
1 change: 1 addition & 0 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&OCSInitialization{}, &OCSInitializationList{},
&StorageCluster{}, &StorageClusterList{},
&StorageProfile{}, &StorageProfileList{},
&StorageClusterPeer{}, &StorageClusterPeerList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
Expand Down
88 changes: 88 additions & 0 deletions api/v1/storageclusterpeer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
Copyright 2020 Red Hat OpenShift Container Storage.

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 v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type StorageClusterPeerState string

const (
// StorageClusterPeerInitializing represents Initializing state of StorageClusterPeerState
StorageClusterPeerInitializing StorageClusterPeerState = "Initializing"
// StorageClusterPeerValidating represents Validating state of StorageClusterPeerState
StorageClusterPeerValidating StorageClusterPeerState = "Validating"
// StorageClusterPeerFailed represents Failed state of StorageClusterPeerState
StorageClusterPeerFailed StorageClusterPeerState = "Failed"
// StorageClusterPeerCreating represents Configuring state of StorageClusterPeerState
StorageClusterPeerCreating StorageClusterPeerState = "Creating"
// StorageClusterPeerConfiguring represents Configuring state of StorageClusterPeerState
StorageClusterPeerConfiguring StorageClusterPeerState = "Configuring"
// StorageClusterPeerReady represents Ready state of StorageClusterPeerState
StorageClusterPeerReady StorageClusterPeerState = "Ready"
// StorageClusterPeerDeleting represents Deleting state of StorageClusterPeerState
StorageClusterPeerDeleting StorageClusterPeerState = "Deleting"
)

const (
StorageClusterPeerFinalizer = "storageclusterpeer.ocs.openshift.io"
)

// StorageClusterPeerSpec defines the desired state of StorageClusterPeer
type StorageClusterPeerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// OCSAPIServerURI is the URI of the secondary ocs api server
OCSAPIServerURI string `json:"ocsApiServerUri,omitempty"`
}

// StorageClusterPeerStatus defines the observed state of StorageClusterPeer
type StorageClusterPeerStatus struct {

// Phase describes the Phase of StorageClusterPeer
// This is used by OLM UI to provide status information to the user
Phase StorageClusterPeerState `json:"phase,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp
//+kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase"
//+operator-sdk:csv:customresourcedefinitions:displayName="Storage Cluster Peer"

// StorageClusterPeer is the Schema for the storageclusterpeers API
type StorageClusterPeer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec StorageClusterPeerSpec `json:"spec,omitempty"`
Status StorageClusterPeerStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// StorageClusterPeerList contains a list of StorageClusterPeer
type StorageClusterPeerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []StorageClusterPeer `json:"items"`
}
89 changes: 89 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageclusterpeers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: storageclusterpeers.ocs.openshift.io
spec:
group: ocs.openshift.io
names:
kind: StorageClusterPeer
listKind: StorageClusterPeerList
plural: storageclusterpeers
singular: storageclusterpeer
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Current Phase
jsonPath: .status.phase
name: Phase
type: string
name: v1
schema:
openAPIV3Schema:
description: StorageClusterPeer is the Schema for the storageclusterpeers
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: StorageClusterPeerSpec defines the desired state of StorageClusterPeer
properties:
ocsApiServerUri:
description: OCSAPIServerURI is the URI of the secondary ocs api server
type: string
type: object
status:
description: StorageClusterPeerStatus defines the observed state of StorageClusterPeer
properties:
phase:
description: Phase describes the Phase of StorageClusterPeer This
is used by OLM UI to provide status information to the user
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resources:
- bases/ocs.openshift.io_storageconsumers.yaml
- bases/ocs.openshift.io_storagerequests.yaml
- bases/ocs.openshift.io_storageprofiles.yaml
- bases/ocs.openshift.io_storageclusterpeers.yaml
# +kubebuilder:scaffold:crdkustomizeresource

# patchesStrategicMerge:
Expand All @@ -17,6 +18,7 @@ resources:
#- patches/webhook_in_storageconsumers.yaml
#- patches/webhook_in_storagerequests.yaml
#- patches/webhook_in_storageprofiles.yaml
#- patches/webhook_in_storageclusterpeers.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -26,6 +28,7 @@ resources:
#- patches/cainjection_in_storageconsumers.yaml
#- patches/cainjection_in_storagerequests.yaml
#- patches/cainjection_in_storageprofiles.yaml
#- patches/cainjection_in_storageclusterpeers.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_storageclusterpeers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: storageclusterpeers.ocs.openshift.io
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_storageclusterpeers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: storageclusterpeers.ocs.openshift.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ spec:
kind: OCSInitialization
name: ocsinitializations.ocs.openshift.io
version: v1
- description: StorageClusterPeer is the Schema for the storageclusterpeers API
displayName: Storage Cluster Peer
kind: StorageClusterPeer
name: storageclusterpeers.ocs.openshift.io
version: v1
- description: StorageCluster represents a cluster including Ceph Cluster, NooBaa
and all the storage and compute resources required.
displayName: Storage Cluster
Expand Down
40 changes: 40 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ rules:
- cephrbdmirrors
verbs:
- '*'
- apiGroups:
- ceph.rook.io
resources:
- cephblockpools
verbs:
- create
- list
- update
- apiGroups:
- ceph.rook.io
resources:
Expand Down Expand Up @@ -155,6 +163,12 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- apiGroups:
- k8s.cni.cncf.io
resources:
Expand Down Expand Up @@ -227,6 +241,32 @@ rules:
- patch
- update
- watch
- apiGroups:
- ocs.openshift.io
resources:
- storageclusterpeers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ocs.openshift.io
resources:
- storageclusterpeers/finalizers
verbs:
- update
- apiGroups:
- ocs.openshift.io
resources:
- storageclusterpeers/status
verbs:
- get
- patch
- update
- apiGroups:
- ocs.openshift.io
resources:
Expand Down