Skip to content

Commit

Permalink
controllers: add StorageConsumerClient api and controller
Browse files Browse the repository at this point in the history
Signed-off-by: Jose A. Rivera <[email protected]>
  • Loading branch information
jarrpa committed Aug 22, 2022
1 parent ab4b461 commit 3c61ead
Show file tree
Hide file tree
Showing 22 changed files with 1,008 additions and 4 deletions.
10 changes: 10 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@ plugins:
scorecard.sdk.operatorframework.io/v2: {}
projectName: ocs-client-operator
repo: github.com/red-hat-storage/ocs-client-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: odf
kind: OcsClient
path: github.com/red-hat-storage/ocs-client-operator/api/v1alpha1
version: v1alpha1
version: "3"
88 changes: 88 additions & 0 deletions api/v1alpha1/ocsclient_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
Copyright 2022 Red Hat, Inc.
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 v1alpha1

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

type ocsClientPhase string

const (
// OcsClientInitializing represents Initializing state of OcsClient
OcsClientInitializing ocsClientPhase = "Initializing"
// OcsClientOnboarding represents Onboarding state of OcsClient
OcsClientOnboarding ocsClientPhase = "Onboarding"
// OcsClientConnected represents Onboarding state of OcsClient
OcsClientConnected ocsClientPhase = "Connected"
// OcsClientUpdating represents Onboarding state of OcsClient
OcsClientUpdating ocsClientPhase = "Updating"
// OcsClientOffboarding represents Onboarding state of OcsClient
OcsClientOffboarding ocsClientPhase = "Offboarding"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// OcsClientSpec defines the desired state of OcsClient
type OcsClientSpec struct {
// StorageProviderEndpoint holds info to establish connection with the storage providing cluster.
StorageProviderEndpoint string `json:"storageProviderEndpoint"`

// OnboardingTicket holds an identity information required for consumer to onboard.
OnboardingTicket string `json:"onboardingTicket"`

// RequestedCapacity Will define the desired capacity requested by a consumer cluster.
RequestedCapacity *resource.Quantity `json:"requestedCapacity,omitempty"`
}

// OcsClientStatus defines the observed state of OcsClient
type OcsClientStatus struct {
Phase ocsClientPhase `json:"phase,omitempty"`

// GrantedCapacity Will report the actual capacity
// granted to the consumer cluster by the provider cluster.
GrantedCapacity resource.Quantity `json:"grantedCapacity,omitempty"`

// ConsumerID will hold the identity of this cluster inside the attached provider cluster
ConsumerID string `json:"id,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

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

Spec OcsClientSpec `json:"spec,omitempty"`
Status OcsClientStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// OcsClientList contains a list of OcsClient
type OcsClientList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []OcsClient `json:"items"`
}

func init() {
SchemeBuilder.Register(&OcsClient{}, &OcsClientList{})
}
121 changes: 121 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

46 changes: 44 additions & 2 deletions bundle/manifests/ocs-client-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
alm-examples: '[]'
alm-examples: |-
[
{
"apiVersion": "odf.openshift.io/v1alpha1",
"kind": "OcsClient",
"metadata": {
"name": "ocsclient-sample"
},
"spec": null
}
]
capabilities: Basic Install
olm.skipRange: ""
operators.operatorframework.io/builder: operator-sdk-v1.19.0+git
Expand All @@ -12,7 +22,13 @@ metadata:
namespace: placeholder
spec:
apiservicedefinitions: {}
customresourcedefinitions: {}
customresourcedefinitions:
owned:
- description: OcsClient is the Schema for the ocsclients API
displayName: Ocs Client
kind: OcsClient
name: ocsclients.odf.openshift.io
version: v1alpha1
description: foo
displayName: OpenShift Data Foundation Client Operator
icon:
Expand All @@ -22,6 +38,32 @@ spec:
spec:
clusterPermissions:
- rules:
- apiGroups:
- odf.openshift.io
resources:
- ocsclients
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- odf.openshift.io
resources:
- ocsclients/finalizers
verbs:
- update
- apiGroups:
- odf.openshift.io
resources:
- ocsclients/status
verbs:
- get
- patch
- update
- apiGroups:
- authentication.k8s.io
resources:
Expand Down
85 changes: 85 additions & 0 deletions bundle/manifests/odf.openshift.io_ocsclients.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: ocsclients.odf.openshift.io
spec:
group: odf.openshift.io
names:
kind: OcsClient
listKind: OcsClientList
plural: ocsclients
singular: ocsclient
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: OcsClient is the Schema for the ocsclients 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: OcsClientSpec defines the desired state of OcsClient
properties:
onboardingTicket:
description: OnboardingTicket holds an identity information required
for consumer to onboard.
type: string
requestedCapacity:
anyOf:
- type: integer
- type: string
description: RequestedCapacity Will define the desired capacity requested
by a consumer cluster.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
storageProviderEndpoint:
description: StorageProviderEndpoint holds info to establish connection
with the storage providing cluster.
type: string
required:
- onboardingTicket
- storageProviderEndpoint
type: object
status:
description: OcsClientStatus defines the observed state of OcsClient
properties:
grantedCapacity:
anyOf:
- type: integer
- type: string
description: GrantedCapacity Will report the actual capacity granted
to the consumer cluster by the provider cluster.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
id:
description: ConsumerID will hold the identity of this cluster inside
the attached provider cluster
type: string
phase:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 3c61ead

Please sign in to comment.