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

[controller] Add LVMVolumeGroupSet #99

Merged
merged 17 commits into from
Nov 4, 2024
66 changes: 66 additions & 0 deletions api/v1alpha1/lvm_volume_group_set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2024 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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type LVMVolumeGroupSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []LVMVolumeGroupSet `json:"items"`
}

type LVMVolumeGroupSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LVMVolumeGroupSetSpec `json:"spec"`
Status LVMVolumeGroupSetStatus `json:"status,omitempty"`
}

type LVMVolumeGroupSetSpec struct {
NodeSelector *metav1.LabelSelector `json:"nodeSelector"`
LVGTemplate LVMVolumeGroupTemplate `json:"lvmVolumeGroupTemplate"`
Strategy string `json:"strategy"`
}
type LVMVolumeGroupTemplate struct {
Metadata LVMVolumeGroupTemplateMeta `json:"metadata"`
BlockDeviceSelector *metav1.LabelSelector `json:"blockDeviceSelector"`
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
ThinPools []LVMVolumeGroupThinPoolSpec `json:"thinPools"`
Type string `json:"type"`
}

type LVMVolumeGroupTemplateMeta struct {
Labels map[string]string `json:"labels"`
}

type LVMVolumeGroupSetStatus struct {
CreatedLVGs []LVMVolumeGroupSetStatusLVG `json:"createdLVMVolumeGroups"`
CurrentLVGCount int `json:"currentLvgCount"`
DesiredLVGCount int `json:"desiredLvgCount"`
Phase string `json:"phase"`
Reason string `json:"reason"`
}

type LVMVolumeGroupSetStatusLVG struct {
LVMVolumeGroupName string `json:"lvmVolumeGroupName"`
NodeName string `json:"nodeName"`
}
2 changes: 2 additions & 0 deletions api/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&LVMVolumeGroupList{},
&LVMLogicalVolume{},
&LVMLogicalVolumeList{},
&LVMVolumeGroupSet{},
&LVMVolumeGroupSetList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
57 changes: 57 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,60 @@ func (in *LVMLogicalVolumeList) DeepCopyObject() runtime.Object {
}
return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LVMVolumeGroupSet) DeepCopyInto(out *LVMVolumeGroupSet) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmptyBlockDevice.
func (in *LVMVolumeGroupSet) DeepCopy() *LVMVolumeGroupSet {
if in == nil {
return nil
}
out := new(LVMVolumeGroupSet)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LVMVolumeGroupSet) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LVMVolumeGroupSetList) DeepCopyInto(out *LVMVolumeGroupSetList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]LVMVolumeGroupSet, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GuestbookList.
func (in *LVMVolumeGroupSetList) DeepCopy() *LVMVolumeGroupSetList {
if in == nil {
return nil
}
out := new(LVMVolumeGroupSetList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LVMVolumeGroupSetList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
3 changes: 3 additions & 0 deletions crds/doc-ru-lvmvolumegroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
Желаемый размер thin pool. Может быть указан как в численном, так и процентном отношении к общему размеру VG.

> Обратите внимание, что при указании размера в процентах thin pool будет автоматически расширен при расширении VG.
allocationLimit:
description: |
Максимальная степень расширения thin pool-а. По умолчанию 150%.
status:
properties:
phase:
Expand Down
92 changes: 92 additions & 0 deletions crds/doc-ru-lvmvolumegroupset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
spec:
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: |
Интерфейс для одновременного создания нескольких LVMVolumeGroup ресурсов по общему шаблону.
properties:
spec:
properties:
strategy:
description: |
Стратегия (правила) создания LVMVolumeGroup ресурсов по текущему ресурсу.
nodeSelector:
description: |
Желаемый selector для узлов, которые будут использованы LVMVolumeGroup ресурсами.
properties:
matchLabels:
description: |
Желаемые метки.
matchExpressions:
description: |
Желаемые выражения.
lvmVolumeGroupTemplate:
description: |
Общий шаблон для LVMVolumeGroup ресурсов, созданных с помощью данного ресурса.
properties:
blockDeviceSelector:
description: |
Желаемый селектор для BlockDevice ресурсов, используемый в LVMVolumeGroup ресурсах.
properties:
matchLabels:
description: |
Желаемые метки.
matchExpressions:
description: |
Желаемые выражения.
metadata:
description: |
Метаинформация для LVMVolumeGroup ресурсов.
properties:
labels:
description: |
Обязательные метки для LVMVolumeGroup ресурсов.
type:
description: |
Тип Volume Group. Может быть:
- Local, то есть локальным, если используемые девайсы не являются распределенными (не Shared LUN).
actualVGNameOnTheNode:
description: |
Желаемое имя для Volume Group. Должно быть уникальным в рамках узла, на котором будет располагаться.

> Неизменяемое поле.
> Обратите внимание, что указанное имя Volume Group будет одинаковым для каждого LVMVolumeGroup ресурса.
thinPools:
description: |
Желаемая конфигурация для Thin-pool'ов текущей Volume Group.

> Обратите внимание, что данная конфигурация будет одинаковой для каждого LVMVolumeGroup ресурса.
items:
properties:
name:
description: |
Желаемое имя thin pool.

> Неизменяемое поле.
size:
description: |
Желаемый размер thin pool. Может быть указан как в численном, так и процентном отношении к общему размеру VG.

> Обратите внимание, что при указании размера в процентах thin pool будет автоматически расширен при расширении VG.
allocationLimit:
description: |
Максимальная степень расширения thin pool-а. По умолчанию 150%.
status:
type: object
properties:
createdLVMVolumeGroups:
description: |
Короткая информация о LVMVolumeGroup ресурсах, созданных по текущему ресурсу.
currentLvgCount:
description: |
Текущее количество созданных LVMVolumeGroup ресурсов.
desiredLvgCount:
description: |
Желаемое количество созданных LVMVolumeGroup ресурсов.
phase:
description: |
Показывает статус создания LVMVolumeGroup ресурсов.
reason:
description: |
Показывает причину текущего статуса.
Loading
Loading