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

Add lvm provisioner (backport #128) #131

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ spec:
a string with the partition's mount point, or "" if no mount point was discovered
type: string
provisioned:
description: a bool indicating whether the filesystem can be provisioned
as a disk for the node to store data.
description: |-
a bool indicating whether the filesystem can be provisioned as a disk for the node to store data.
Deprecated: Replaced by field `spec.provision`
type: boolean
repaired:
description: a bool indicating whether the filesystem is manually
Expand All @@ -87,6 +88,10 @@ spec:
nodeName:
description: name of the node to which the block device is attached
type: string
provision:
default: false
description: a bool for the device to be provisioned
type: boolean
provisioner:
properties:
longhorn:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{}
name: lvmvolumegroups.harvesterhci.io
spec:
group: harvesterhci.io
names:
kind: LVMVolumeGroup
listKind: LVMVolumeGroupList
plural: lvmvolumegroups
shortNames:
- lvmvg
- lvmvgs
singular: lvmvolumegroup
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.parameters
name: Parameters
type: string
- jsonPath: .status.vgStatus
name: Status
type: string
- jsonPath: .spec.nodeName
name: Node
type: string
name: v1beta1
schema:
openAPIV3Schema:
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:
properties:
desiredState:
description: |-
DesiredState is the desired state of the volume group
enabled means we will keep this vg active, disabled means we will keep this vg inactive
enum:
- Enabled
- Disabled
type: string
devices:
additionalProperties:
type: string
description: |-
The devices of the volume group
format: map[<bd Name>]=devPath"
e.g. map[087fc9702c450bfca5ba56b06ba7d7f2] = /dev/sda
type: object
nodeName:
description: NodeName is the name of the node where the volume group
is created
type: string
parameters:
description: Parameters is the parameters for creating the volume
group *optional*
type: string
vgName:
description: VGName is the name of the volume group
type: string
required:
- desiredState
- nodeName
- vgName
type: object
status:
properties:
conditions:
description: The conditions of the volume group
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
devices:
additionalProperties:
type: string
description: |-
The devices of the volume group
format: map[<bd Name>]=devPath"
type: object
parameters:
description: Parameters is the current parameters of the volume group
type: string
vgStatus:
default: Unknown
description: The status of the volume group
enum:
- Active
- Inactive
- Unknown
type: string
vgTargetType:
description: VGTargetType is the target type of the volume group,
now only support stripe/dm-thin
type: string
type: object
required:
- metadata
- spec
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
name: {{ include "harvester-node-disk-manager.name" . }}
rules:
- apiGroups: [ "harvesterhci.io" ]
resources: [ "blockdevices" ]
resources: [ "blockdevices", "lvmvolumegroups", "lvmvolumegroups/status" ]
verbs: [ "*" ]
- apiGroups: [ "longhorn.io" ]
resources: [ "nodes" ]
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/harvester/node-disk-manager/pkg/block"
blockdevicev1 "github.com/harvester/node-disk-manager/pkg/controller/blockdevice"
nodev1 "github.com/harvester/node-disk-manager/pkg/controller/node"
volumegroupv1 "github.com/harvester/node-disk-manager/pkg/controller/volumegroup"
"github.com/harvester/node-disk-manager/pkg/filter"
ctldisk "github.com/harvester/node-disk-manager/pkg/generated/controllers/harvesterhci.io"
ctllonghorn "github.com/harvester/node-disk-manager/pkg/generated/controllers/longhorn.io"
Expand Down Expand Up @@ -219,6 +220,7 @@ func run(opt *option.Option) error {
locker := &sync.Mutex{}
cond := sync.NewCond(locker)
bds := disks.Harvesterhci().V1beta1().BlockDevice()
lvmVGs := disks.Harvesterhci().V1beta1().LVMVolumeGroup()
nodes := lhs.Longhorn().V1beta2().Node()
scanner := blockdevicev1.NewScanner(
opt.NodeName,
Expand All @@ -237,6 +239,7 @@ func run(opt *option.Option) error {
ctx,
nodes,
bds,
lvmVGs,
block,
opt,
scanner,
Expand All @@ -248,6 +251,10 @@ func run(opt *option.Option) error {
logrus.Fatalf("failed to register ndm node controller, %s", err.Error())
}

if err := volumegroupv1.Register(ctx, lvmVGs, opt); err != nil {
logrus.Fatalf("failed to register ndm volume group controller, %s", err.Error())
}

if err := start.All(ctx, opt.Threadiness, disks, lhs); err != nil {
logrus.Fatalf("error starting, %s", err.Error())
}
Expand Down
9 changes: 7 additions & 2 deletions manifests/crds/harvesterhci.io_blockdevices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ spec:
a string with the partition's mount point, or "" if no mount point was discovered
type: string
provisioned:
description: a bool indicating whether the filesystem can be provisioned
as a disk for the node to store data.
description: |-
a bool indicating whether the filesystem can be provisioned as a disk for the node to store data.
Deprecated: Replaced by field `spec.provision`
type: boolean
repaired:
description: a bool indicating whether the filesystem is manually
Expand All @@ -87,6 +88,10 @@ spec:
nodeName:
description: name of the node to which the block device is attached
type: string
provision:
default: false
description: a bool for the device to be provisioned
type: boolean
provisioner:
properties:
longhorn:
Expand Down
138 changes: 138 additions & 0 deletions manifests/crds/harvesterhci.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{}
name: lvmvolumegroups.harvesterhci.io
spec:
group: harvesterhci.io
names:
kind: LVMVolumeGroup
listKind: LVMVolumeGroupList
plural: lvmvolumegroups
shortNames:
- lvmvg
- lvmvgs
singular: lvmvolumegroup
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.parameters
name: Parameters
type: string
- jsonPath: .status.vgStatus
name: Status
type: string
- jsonPath: .spec.nodeName
name: Node
type: string
name: v1beta1
schema:
openAPIV3Schema:
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:
properties:
desiredState:
description: |-
DesiredState is the desired state of the volume group
enabled means we will keep this vg active, disabled means we will keep this vg inactive
enum:
- Enabled
- Disabled
type: string
devices:
additionalProperties:
type: string
description: |-
The devices of the volume group
format: map[<bd Name>]=devPath"
e.g. map[087fc9702c450bfca5ba56b06ba7d7f2] = /dev/sda
type: object
nodeName:
description: NodeName is the name of the node where the volume group
is created
type: string
parameters:
description: Parameters is the parameters for creating the volume
group *optional*
type: string
vgName:
description: VGName is the name of the volume group
type: string
required:
- desiredState
- nodeName
- vgName
type: object
status:
properties:
conditions:
description: The conditions of the volume group
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
devices:
additionalProperties:
type: string
description: |-
The devices of the volume group
format: map[<bd Name>]=devPath"
type: object
parameters:
description: Parameters is the current parameters of the volume group
type: string
vgStatus:
default: Unknown
description: The status of the volume group
enum:
- Active
- Inactive
- Unknown
type: string
vgTargetType:
description: VGTargetType is the target type of the volume group,
now only support stripe/dm-thin
type: string
type: object
required:
- metadata
- spec
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type BlockDeviceSpec struct {
Tags []string `json:"tags,omitempty"`

Provisioner *ProvisionerInfo `json:"provisioner,omitempty"`

// a bool for the device to be provisioned
// +kubebuilder:default:=false
Provision bool `json:"provision,omitempty"`
}

type BlockDeviceStatus struct {
Expand Down Expand Up @@ -102,6 +106,8 @@ type FilesystemInfo struct {
ForceFormatted bool `json:"forceFormatted,omitempty"`

// a bool indicating whether the filesystem can be provisioned as a disk for the node to store data.
// Deprecated: Replaced by field `spec.provision`
// +optional
Provisioned bool `json:"provisioned,omitempty"`

// a bool indicating whether the filesystem is manually repaired of not
Expand Down
Loading
Loading