-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created crd and api-models, renamed files for better reading
Signed-off-by: viktor.kramarenko <[email protected]>
- Loading branch information
1 parent
f669618
commit d3b6f7f
Showing
13 changed files
with
372 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: logicalvolumes.storage.deckhouse.io | ||
labels: | ||
heritage: deckhouse | ||
module: storage | ||
spec: | ||
group: storage.deckhouse.io | ||
scope: Cluster | ||
names: | ||
kind: LvmLogicalVolume | ||
plural: lvmlogicalvolumes | ||
singular: lvmlogicalvolume | ||
shortNames: | ||
- llv | ||
preserveUnknownFields: false | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
storage: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
description: | | ||
properties: | ||
spec: | ||
type: object | ||
description: | | ||
properties: | ||
type: | ||
type: string | ||
enum: [Thick, Thin] | ||
size: | ||
type: string | ||
lvmVolumeGroup: | ||
type: string | ||
thinPoolName: | ||
type: string | ||
source: | ||
type: string | ||
status: | ||
type: object | ||
description: | | ||
properties: | ||
phase: | ||
type: string | ||
enum: [Created, Failed] | ||
reason: | ||
type: string | ||
size: | ||
type: string | ||
actualVGNameOnTheNode: | ||
type: string | ||
additionalPrinterColumns: | ||
- jsonPath: .spec.lvmVolumeGroup | ||
name: LVMVolumeGroup | ||
type: string | ||
description: The selected LVMVolumeGroup resource. | ||
- jsonPath: .spec.thinPoolName | ||
name: ThinPool | ||
type: string | ||
description: The selected ThinPool in LVMVolumeGroup. Might be empty if the LVMVolumeGroup is thick. | ||
- jsonPath: .status.size | ||
name: Size | ||
type: string | ||
description: Actual LVMLogicalVolume size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2023 Flant JSC | ||
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 LVMLogicalVolumeList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
|
||
Items []LVMLogicalVolume `json:"items"` | ||
} | ||
|
||
type LVMLogicalVolume struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec LVMLogicalVolumeSpec `json:"spec"` | ||
Status LVMLogicalVolumeStatus `json:"status,omitempty"` | ||
} | ||
|
||
type LVMLogicalVolumeSpec struct { | ||
Type string `json:"type"` | ||
Size resource.Quantity `json:"size"` | ||
LvmVolumeGroup string `json:"lvmVolumeGroup"` | ||
ThinPoolName string `json:"thinPoolName"` | ||
Source string `json:"source"` | ||
} | ||
|
||
type LVMLogicalVolumeStatus struct { | ||
Phase string `json:"phase"` | ||
Reason string `json:"reason"` | ||
Size resource.Quantity `json:"size"` | ||
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package controller | ||
|
||
import ( | ||
"context" | ||
"sds-node-configurator/api/v1alpha1" | ||
"sds-node-configurator/config" | ||
"sds-node-configurator/pkg/logger" | ||
"sds-node-configurator/pkg/monitoring" | ||
"sigs.k8s.io/controller-runtime/pkg/controller" | ||
"sigs.k8s.io/controller-runtime/pkg/handler" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
"sigs.k8s.io/controller-runtime/pkg/source" | ||
) | ||
|
||
const ( | ||
LVMLogicalVolumeWatcherCtrlName = "lvm-logical-volume-watcher-controller" | ||
) | ||
|
||
func RunLVMLogicalVolumeController( | ||
mgr manager.Manager, | ||
cfg config.Options, | ||
log logger.Logger, | ||
metrics monitoring.Metrics, | ||
) (controller.Controller, error) { | ||
//cl := mgr.GetClient() | ||
cache := mgr.GetCache() | ||
|
||
c, err := controller.New(LVMLogicalVolumeWatcherCtrlName, mgr, controller.Options{ | ||
Reconciler: reconcile.Func(func(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { | ||
return reconcile.Result{}, nil | ||
}), | ||
}) | ||
if err != nil { | ||
log.Error(err, "[RunLVMLogicalVolumeController] unable to create controller") | ||
return nil, err | ||
} | ||
|
||
err = c.Watch(source.Kind(cache, &v1alpha1.LVMLogicalVolume{}), handler.Funcs{ | ||
CreateFunc: nil, | ||
UpdateFunc: nil, | ||
DeleteFunc: nil, | ||
GenericFunc: nil, | ||
}) | ||
if err != nil { | ||
log.Error(err, "[RunLVMLogicalVolumeController] the controller is unable to watch") | ||
return nil, err | ||
} | ||
|
||
return c, err | ||
} |
Oops, something went wrong.