ceph: extract rbd-mirror to its own crd
Previously, the rbd-mirror daemon was integrated into the `CephCluster` CRD. This wasn't really practical since we would have to wait for the whole orchestration to be done to actually set it up. The same goes for any CR update. Let's say you want to change the number of daemons, Rook would go through mons, mgrs and osds until it get to rbd-mirror. This triggers an undesired full orchestration. With its own CRD this component just gains a lot more flexibility. Closes: https://github.com/rook/rook/issues/5084 Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
1 parent
8c8b74afc3
commit
c1b8a7aa9e
44 files changed
+1504
-310
No files matched your search
@@ -128,9 +128,6 @@ If this value is empty, each pod will get an ephemeral directory to store their
|
||||
For more details on the mons and when to choose a number other than `3`, see the [mon health design doc](https://github.com/rook/rook/blob/master/design/ceph/mon-health.md).
|
||||
* `mgr`: manager top level section
|
||||
* `modules`: is the list of Ceph manager modules to enable
|
||||
* `rbdMirroring`: The settings for rbd mirror daemon(s). Configuring which pools or images to be mirrored must be completed in the rook toolbox by running the
|
||||
[rbd mirror](http://docs.ceph.com/docs/mimic/rbd/rbd-mirroring/) command.
|
||||
* `workers`: The number of rbd daemons to perform the rbd mirroring between clusters.
|
||||
* `crashCollector`: The settings for crash collector daemon(s).
|
||||
* `disable`: is set to `true`, the crash collector will not run on any node where a Ceph daemon runs
|
||||
* `annotations`: [annotations configuration settings](#annotations-configuration-settings)
|
||||
@@ -346,13 +343,12 @@ You can set annotations for Rook components for the list of key value pairs:
|
||||
* `mgr`: Set annotations for MGRs
|
||||
* `mon`: Set annotations for mons
|
||||
* `osd`: Set annotations for OSDs
|
||||
* `rbdmirror`: Set annotations for RBD Mirrors
|
||||
|
||||
When other keys are set, `all` will be merged together with the specific component.
|
||||
|
||||
### Placement Configuration Settings
|
||||
|
||||
Placement configuration for the cluster services. It includes the following keys: `mgr`, `mon`, `rbdmirror` and `all`. Each service will have its placement configuration generated by merging the generic configuration under `all` with the most specific one (which will override any attributes).
|
||||
Placement configuration for the cluster services. It includes the following keys: `mgr`, `mon` and `all`. Each service will have its placement configuration generated by merging the generic configuration under `all` with the most specific one (which will override any attributes).
|
||||
|
||||
**NOTE:** Placement of OSD pods is controlled using the [Storage Class Device Set](#storage-class-device-sets), not the general `placement` configuration.
|
||||
|
||||
@@ -381,7 +377,6 @@ You can set resource requests/limits for Rook components through the [Resource R
|
||||
* `mgr`: Set resource requests/limits for MGRs
|
||||
* `mon`: Set resource requests/limits for mons
|
||||
* `osd`: Set resource requests/limits for OSDs
|
||||
* `rbdmirror`: Set resource requests/limits for RBD Mirrors
|
||||
* `prepareosd`: Set resource requests/limits for OSD prepare job
|
||||
* `crashcollector`: Set resource requests/limits for crash. This pod runs wherever there is a Ceph pod running.
|
||||
It scrapes for Ceph daemon core dumps and sends them to the Ceph manager crash module so that core dumps are centralized and can be easily listed/accessed.
|
||||
@@ -395,7 +390,6 @@ Here are the current minimum amounts of memory in MB to apply so that Rook will
|
||||
* `mgr`: 512MB
|
||||
* `osd`: 2048MB
|
||||
* `mds`: 4096MB
|
||||
* `rbdmirror`: 512MB
|
||||
|
||||
Rook does not enforce any minimum limit nor request on the following:
|
||||
|
||||
@@ -419,11 +413,10 @@ Priority class names can be specified so that the Rook components will have thos
|
||||
|
||||
You can set priority class names for Rook components for the list of key value pairs:
|
||||
|
||||
* `all`: Set priority class names for MGRs, Mons, OSDs, and RBD Mirrors.
|
||||
* `all`: Set priority class names for MGRs, Mons, OSDs.
|
||||
* `mgr`: Set priority class names for MGRs.
|
||||
* `mon`: Set priority class names for Mons.
|
||||
* `osd`: Set priority class names for OSDs.
|
||||
* `rbdmirror`: Set priority class names for RBD Mirrors.
|
||||
|
||||
The specific component keys will act as overrides to `all`.
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: RBDMirror CRD
|
||||
weight: 3500
|
||||
indent: true
|
||||
---
|
||||
|
||||
# Ceph RBDMirror CRD
|
||||
|
||||
Rook allows creation and updating rbd-mirror daemon(s) through the custom resource definitions (CRDs).
|
||||
RBD images can be asynchronously mirrored between two Ceph clusters.
|
||||
For more information about user management and capabilities see the [Ceph docs](https://docs.ceph.com/docs/master/rbd/rbd-mirroring/).
|
||||
|
||||
## Creating daemons
|
||||
|
||||
To get you started, here is a simple example of a CRD to deploy an rbd-mirror daemon.
|
||||
|
||||
```yaml
|
||||
apiVersion: ceph.rook.io/v1
|
||||
kind: CephRBDMirror
|
||||
metadata:
|
||||
name: my-rbd-mirror
|
||||
namespace: rook-ceph
|
||||
spec:
|
||||
count: 1
|
||||
```
|
||||
|
||||
### Prerequisites
|
||||
|
||||
This guide assumes you have created a Rook cluster as explained in the main [Quickstart guide](ceph-quickstart.md)
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
### Ceph
|
||||
|
||||
- Ceph RBD Mirror daemon has been extracted to its own CRD, it has been removed from the `CephCluster` CRD, see the [rbd-mirror crd](Documentation/ceph-rbd-mirror-crd.html).
|
||||
|
||||
### EdgeFS
|
||||
|
||||
### YugabyteDB
|
||||
@@ -14,6 +16,11 @@
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
### Ceph
|
||||
|
||||
- rbd-mirror daemons that were deployed through the CephCluster CR won't be managed anymore as they have their own CRD now.
|
||||
To transition, you can inject the new rbd mirror CR with the desired `count` of daemons and delete the previously managed rbd mirror deployments manually.
|
||||
|
||||
## Known Issues
|
||||
|
||||
### <Storage Provider>
|
||||
|
||||
@@ -275,6 +275,8 @@ spec:
|
||||
- name: Age
|
||||
type: date
|
||||
JSONPath: .metadata.creationTimestamp
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
@@ -548,3 +550,28 @@ spec:
|
||||
type: object
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: cephrbdmirrors.ceph.rook.io
|
||||
spec:
|
||||
group: ceph.rook.io
|
||||
names:
|
||||
kind: CephRBDMirror
|
||||
listKind: CephRBDMirrorList
|
||||
plural: cephrbdmirrors
|
||||
singular: cephrbdmirror
|
||||
scope: Namespaced
|
||||
version: v1
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
spec:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -163,10 +163,6 @@ spec:
|
||||
type: boolean
|
||||
rulesNamespace:
|
||||
type: string
|
||||
rbdMirroring:
|
||||
properties:
|
||||
workers:
|
||||
type: integer
|
||||
removeOSDsIfOutAndSafeToRemove:
|
||||
type: boolean
|
||||
external:
|
||||
@@ -233,6 +229,33 @@ spec:
|
||||
subresources:
|
||||
status: {}
|
||||
# OLM: END CEPH CLIENT CRD
|
||||
# OLM: BEGIN CEPH RBD MIRROR CRD
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: cephrbdmirrors.ceph.rook.io
|
||||
spec:
|
||||
group: ceph.rook.io
|
||||
names:
|
||||
kind: CephRBDMirror
|
||||
listKind: CephRBDMirrorList
|
||||
plural: cephrbdmirrors
|
||||
singular: cephrbdmirror
|
||||
scope: Namespaced
|
||||
version: v1
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
spec:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
subresources:
|
||||
status: {}
|
||||
# OLM: END CEPH RBD MIRROR CRD
|
||||
# OLM: BEGIN CEPH FS CRD
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#################################################################################################################
|
||||
# Create rbd-mirror daemon(s)
|
||||
# kubectl create -f rbdmirror.yaml
|
||||
#################################################################################################################
|
||||
|
||||
apiVersion: ceph.rook.io/v1
|
||||
kind: CephRBDMirror
|
||||
metadata:
|
||||
name: my-rbd-mirror
|
||||
namespace: rook-ceph
|
||||
spec:
|
||||
# the number of rbd-mirror daemons to deploy
|
||||
count: 1
|
||||
# The affinity rules to apply to the mds deployment
|
||||
placement:
|
||||
# nodeAffinity:
|
||||
# requiredDuringSchedulingIgnoredDuringExecution:
|
||||
# nodeSelectorTerms:
|
||||
# - matchExpressions:
|
||||
# - key: role
|
||||
# operator: In
|
||||
# values:
|
||||
# - rgw-node
|
||||
# tolerations:
|
||||
# - key: rbd-mirror-node
|
||||
# operator: Exists
|
||||
# podAffinity:
|
||||
# podAntiAffinity:
|
||||
# A key/value list of annotations
|
||||
annotations:
|
||||
# key: value
|
||||
resources:
|
||||
# The requests and limits, for example to allow the rbd-mirror pod(s) to use half of one CPU core and 1 gigabyte of memory
|
||||
# limits:
|
||||
# cpu: "500m"
|
||||
# memory: "1024Mi"
|
||||
# requests:
|
||||
# cpu: "500m"
|
||||
# memory: "1024Mi"
|
||||
# priorityClassName: my-priority-class
|
||||
@@ -522,4 +522,4 @@ spec:
|
||||
scope: Namespaced
|
||||
version: v1alpha2
|
||||
subresources:
|
||||
status: {}
|
||||
status: {}
|
||||
@@ -0,0 +1,25 @@
|
||||
# Latest custom resource definitions
|
||||
# Do NOT apply this until after all Rook-Ceph clusters have been updated
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: cephrbdmirrors.ceph.rook.io
|
||||
spec:
|
||||
group: ceph.rook.io
|
||||
names:
|
||||
kind: CephRBDMirror
|
||||
listKind: CephRBDMirrorList
|
||||
plural: cephrbdmirrrors
|
||||
singular: cephrbdmirror
|
||||
scope: Namespaced
|
||||
version: v1
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
spec:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -97,6 +97,7 @@ CEPH_OBJECT_STORE_USERS_YAML_FILE="$OLM_CATALOG_DIR/deploy/crds/rookcephobjectst
|
||||
CEPH_FILESYSTEMS_CRD_YAML_FILE="$OLM_CATALOG_DIR/deploy/crds/rookcephfilesystems.crd.yaml"
|
||||
CEPH_NFS_CRD_YAML_FILE="$OLM_CATALOG_DIR/deploy/crds/rookcephnfses.crd.yaml"
|
||||
CEPH_CLIENT_CRD_YAML_FILE="$OLM_CATALOG_DIR/deploy/crds/rookcephclients.crd.yaml"
|
||||
CEPH_RBD_MIRROR_CRD_YAML_FILE="$OLM_CATALOG_DIR/deploy/crds/rookcephrbdmirrors.crd.yaml"
|
||||
|
||||
#############
|
||||
# FUNCTIONS #
|
||||
@@ -195,6 +196,8 @@ function generate_crds_yaml() {
|
||||
sed -n '/^# OLM: BEGIN CEPH BLOCK POOL CRD$/,/# OLM: END CEPH BLOCK POOL CRD$/p' "$COMMON_YAML_FILE" > "$CEPH_BLOCK_POOLS_CRD_YAML_FILE"
|
||||
sed -n '/^# OLM: BEGIN CEPH NFS CRD$/,/# OLM: END CEPH NFS CRD$/p' "$COMMON_YAML_FILE" > "$CEPH_NFS_CRD_YAML_FILE"
|
||||
sed -n '/^# OLM: BEGIN CEPH CLIENT CRD$/,/# OLM: END CEPH CLIENT CRD$/p' "$COMMON_YAML_FILE" > "$CEPH_CLIENT_CRD_YAML_FILE"
|
||||
sed -n '/^# OLM: BEGIN CEPH RBD MIRROR CRD$/,/# OLM: END CEPH RBD MIRROR CRD$/p' "$COMMON_YAML_FILE" > "$CEPH_CLIENT_CRD_YAML_FILE"
|
||||
sed -n '/^# OLM: BEGIN CEPH RBD MIRROR CRD$/,/# OLM: END CEPH RBD MIRROR CRD$/p' "$COMMON_YAML_FILE" > "$CEPH_CLIENT_CRD_YAML_FILE"
|
||||
|
||||
if [ -n "$OLM_INCLUDE_CEPHFS_CSI" ]; then
|
||||
sed -n '/^# OLM: BEGIN CEPH FS CRD$/,/# OLM: END CEPH FS CRD/p' "$COMMON_YAML_FILE" > "$CEPH_FILESYSTEMS_CRD_YAML_FILE"
|
||||
|
||||
@@ -40,11 +40,6 @@ func GetRGWAnnotations(a rook.AnnotationsSpec) rook.Annotations {
|
||||
return mergeAllAnnotationsWithKey(a, KeyRGW)
|
||||
}
|
||||
|
||||
// GetRBDMirrorAnnotations returns the Annotations for the RBD mirrors
|
||||
func GetRBDMirrorAnnotations(a rook.AnnotationsSpec) rook.Annotations {
|
||||
return mergeAllAnnotationsWithKey(a, KeyRBDMirror)
|
||||
}
|
||||
|
||||
func mergeAllAnnotationsWithKey(a rook.AnnotationsSpec, name rook.KeyType) rook.Annotations {
|
||||
all := a.All()
|
||||
if all != nil {
|
||||
|
||||
@@ -49,9 +49,6 @@ func TestAnnotationMerge(t *testing.T) {
|
||||
a = GetRGWAnnotations(testAnnotations)
|
||||
assert.Equal(t, "rgwval", a["rgwkey"])
|
||||
assert.Equal(t, 1, len(a))
|
||||
a = GetRBDMirrorAnnotations(testAnnotations)
|
||||
assert.Equal(t, "rbdmirrorval", a["rbdmirrorkey"])
|
||||
assert.Equal(t, 1, len(a))
|
||||
|
||||
// No annotations matching the component
|
||||
testAnnotations = rook.AnnotationsSpec{
|
||||
|
||||
@@ -33,8 +33,3 @@ func GetMonPlacement(p rookv1.PlacementSpec) rookv1.Placement {
|
||||
func GetOSDPlacement(p rookv1.PlacementSpec) rookv1.Placement {
|
||||
return p.All().Merge(p[KeyOSD])
|
||||
}
|
||||
|
||||
// GetRBDMirrorPlacement returns the placement for the RBD mirrors
|
||||
func GetRBDMirrorPlacement(p rookv1.PlacementSpec) rookv1.Placement {
|
||||
return p.All().Merge(p[KeyRBDMirror])
|
||||
}
|
||||
@@ -43,11 +43,3 @@ func GetOSDPriorityClassName(p rook.PriorityClassNamesSpec) string {
|
||||
}
|
||||
return p[KeyOSD]
|
||||
}
|
||||
|
||||
// GetRBDMirrorPriorityClassName returns the priority class name for the RBD Mirrors
|
||||
func GetRBDMirrorPriorityClassName(p rook.PriorityClassNamesSpec) string {
|
||||
if _, ok := p[KeyRBDMirror]; !ok {
|
||||
return p.All()
|
||||
}
|
||||
return p[KeyRBDMirror]
|
||||
}
|
||||
@@ -68,6 +68,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
&CephObjectStoreList{},
|
||||
&CephObjectStoreUser{},
|
||||
&CephObjectStoreUserList{},
|
||||
&CephRBDMirror{},
|
||||
&CephRBDMirrorList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
|
||||
@@ -56,11 +56,6 @@ func GetPrepareOSDResources(p rook.ResourceSpec) v1.ResourceRequirements {
|
||||
return p[ResourcesKeyPrepareOSD]
|
||||
}
|
||||
|
||||
// GetRBDMirrorResources returns the placement for the RBD Mirrors
|
||||
func GetRBDMirrorResources(p rook.ResourceSpec) v1.ResourceRequirements {
|
||||
return p[ResourcesKeyRBDMirror]
|
||||
}
|
||||
|
||||
// GetCrashCollectorResources returns the placement for the crash daemon
|
||||
func GetCrashCollectorResources(p rook.ResourceSpec) v1.ResourceRequirements {
|
||||
return p[ResourcesKeyCrashCollector]
|
||||
|
||||
@@ -86,9 +86,6 @@ type ClusterSpec struct {
|
||||
// A spec for mon related options
|
||||
Mon MonSpec `json:"mon,omitempty"`
|
||||
|
||||
// A spec for rbd mirroring
|
||||
RBDMirroring RBDMirroringSpec `json:"rbdMirroring"`
|
||||
|
||||
// A spec for the crash controller
|
||||
CrashCollector CrashCollectorSpec `json:"crashCollector"`
|
||||
|
||||
@@ -230,10 +227,6 @@ type ExternalSpec struct {
|
||||
Enable bool `json:"enable"`
|
||||
}
|
||||
|
||||
type RBDMirroringSpec struct {
|
||||
Workers int `json:"workers"`
|
||||
}
|
||||
|
||||
// CrashCollectorSpec represents options to configure the crash controller
|
||||
type CrashCollectorSpec struct {
|
||||
Disable bool `json:"disable"`
|
||||
@@ -554,3 +547,39 @@ type ClientSpec struct {
|
||||
type CleanupPolicySpec struct {
|
||||
DeleteDataDirOnHosts string `json:"deleteDataDirOnHosts"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type CephRBDMirror struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
Spec RBDMirroringSpec `json:"spec"`
|
||||
Status *Status `json:"status"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type CephRBDMirrorList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
Items []CephRBDMirror `json:"items"`
|
||||
}
|
||||
|
||||
type RBDMirroringSpec struct {
|
||||
// Count represents the number of rbd mirror instance to run
|
||||
Count int `json:"count"`
|
||||
|
||||
// The affinity to place the rgw pods (default is to place on any available node)
|
||||
Placement rookv1.Placement `json:"placement"`
|
||||
|
||||
// The annotations-related configuration to add/set on each Pod related object.
|
||||
Annotations rookv1.Annotations `json:"annotations,omitempty"`
|
||||
|
||||
// The resource requirements for the rgw pods
|
||||
Resources v1.ResourceRequirements `json:"resources"`
|
||||
|
||||
// PriorityClassName sets priority classes on the rgw pods
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
}
|
||||
@@ -488,6 +488,71 @@ func (in *CephObjectStoreUserList) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *CephRBDMirror) DeepCopyInto(out *CephRBDMirror) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
if in.Status != nil {
|
||||
in, out := &in.Status, &out.Status
|
||||
*out = new(Status)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CephRBDMirror.
|
||||
func (in *CephRBDMirror) DeepCopy() *CephRBDMirror {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(CephRBDMirror)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *CephRBDMirror) 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 *CephRBDMirrorList) DeepCopyInto(out *CephRBDMirrorList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]CephRBDMirror, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CephRBDMirrorList.
|
||||
func (in *CephRBDMirrorList) DeepCopy() *CephRBDMirrorList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(CephRBDMirrorList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *CephRBDMirrorList) 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 *CephStatus) DeepCopyInto(out *CephStatus) {
|
||||
*out = *in
|
||||
@@ -612,7 +677,6 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
|
||||
}
|
||||
out.DisruptionManagement = in.DisruptionManagement
|
||||
in.Mon.DeepCopyInto(&out.Mon)
|
||||
out.RBDMirroring = in.RBDMirroring
|
||||
out.CrashCollector = in.CrashCollector
|
||||
out.Dashboard = in.Dashboard
|
||||
out.Monitoring = in.Monitoring
|
||||
@@ -1058,6 +1122,15 @@ func (in *PoolSpec) DeepCopy() *PoolSpec {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RBDMirroringSpec) DeepCopyInto(out *RBDMirroringSpec) {
|
||||
*out = *in
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
if in.Annotations != nil {
|
||||
in, out := &in.Annotations, &out.Annotations
|
||||
*out = make(rookiov1.Annotations, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
in.Resources.DeepCopyInto(&out.Resources)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ type CephV1Interface interface {
|
||||
CephNFSesGetter
|
||||
CephObjectStoresGetter
|
||||
CephObjectStoreUsersGetter
|
||||
CephRBDMirrorsGetter
|
||||
}
|
||||
|
||||
// CephV1Client is used to interact with features provided by the ceph.rook.io group.
|
||||
@@ -68,6 +69,10 @@ func (c *CephV1Client) CephObjectStoreUsers(namespace string) CephObjectStoreUse
|
||||
return newCephObjectStoreUsers(c, namespace)
|
||||
}
|
||||
|
||||
func (c *CephV1Client) CephRBDMirrors(namespace string) CephRBDMirrorInterface {
|
||||
return newCephRBDMirrors(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new CephV1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*CephV1Client, error) {
|
||||
config := *c
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
scheme "github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// CephRBDMirrorsGetter has a method to return a CephRBDMirrorInterface.
|
||||
// A group's client should implement this interface.
|
||||
type CephRBDMirrorsGetter interface {
|
||||
CephRBDMirrors(namespace string) CephRBDMirrorInterface
|
||||
}
|
||||
|
||||
// CephRBDMirrorInterface has methods to work with CephRBDMirror resources.
|
||||
type CephRBDMirrorInterface interface {
|
||||
Create(*v1.CephRBDMirror) (*v1.CephRBDMirror, error)
|
||||
Update(*v1.CephRBDMirror) (*v1.CephRBDMirror, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
|
||||
Get(name string, options metav1.GetOptions) (*v1.CephRBDMirror, error)
|
||||
List(opts metav1.ListOptions) (*v1.CephRBDMirrorList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.CephRBDMirror, err error)
|
||||
CephRBDMirrorExpansion
|
||||
}
|
||||
|
||||
// cephRBDMirrors implements CephRBDMirrorInterface
|
||||
type cephRBDMirrors struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newCephRBDMirrors returns a CephRBDMirrors
|
||||
func newCephRBDMirrors(c *CephV1Client, namespace string) *cephRBDMirrors {
|
||||
return &cephRBDMirrors{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the cephRBDMirror, and returns the corresponding cephRBDMirror object, and an error if there is any.
|
||||
func (c *cephRBDMirrors) Get(name string, options metav1.GetOptions) (result *v1.CephRBDMirror, err error) {
|
||||
result = &v1.CephRBDMirror{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of CephRBDMirrors that match those selectors.
|
||||
func (c *cephRBDMirrors) List(opts metav1.ListOptions) (result *v1.CephRBDMirrorList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1.CephRBDMirrorList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested cephRBDMirrors.
|
||||
func (c *cephRBDMirrors) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a cephRBDMirror and creates it. Returns the server's representation of the cephRBDMirror, and an error, if there is any.
|
||||
func (c *cephRBDMirrors) Create(cephRBDMirror *v1.CephRBDMirror) (result *v1.CephRBDMirror, err error) {
|
||||
result = &v1.CephRBDMirror{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
Body(cephRBDMirror).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a cephRBDMirror and updates it. Returns the server's representation of the cephRBDMirror, and an error, if there is any.
|
||||
func (c *cephRBDMirrors) Update(cephRBDMirror *v1.CephRBDMirror) (result *v1.CephRBDMirror, err error) {
|
||||
result = &v1.CephRBDMirror{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
Name(cephRBDMirror.Name).
|
||||
Body(cephRBDMirror).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the cephRBDMirror and deletes it. Returns an error if one occurs.
|
||||
func (c *cephRBDMirrors) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *cephRBDMirrors) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched cephRBDMirror.
|
||||
func (c *cephRBDMirrors) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.CephRBDMirror, err error) {
|
||||
result = &v1.CephRBDMirror{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("cephrbdmirrors").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -56,6 +56,10 @@ func (c *FakeCephV1) CephObjectStoreUsers(namespace string) v1.CephObjectStoreUs
|
||||
return &FakeCephObjectStoreUsers{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeCephV1) CephRBDMirrors(namespace string) v1.CephRBDMirrorInterface {
|
||||
return &FakeCephRBDMirrors{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeCephV1) RESTClient() rest.Interface {
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
cephrookiov1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// FakeCephRBDMirrors implements CephRBDMirrorInterface
|
||||
type FakeCephRBDMirrors struct {
|
||||
Fake *FakeCephV1
|
||||
ns string
|
||||
}
|
||||
|
||||
var cephrbdmirrorsResource = schema.GroupVersionResource{Group: "ceph.rook.io", Version: "v1", Resource: "cephrbdmirrors"}
|
||||
|
||||
var cephrbdmirrorsKind = schema.GroupVersionKind{Group: "ceph.rook.io", Version: "v1", Kind: "CephRBDMirror"}
|
||||
|
||||
// Get takes name of the cephRBDMirror, and returns the corresponding cephRBDMirror object, and an error if there is any.
|
||||
func (c *FakeCephRBDMirrors) Get(name string, options v1.GetOptions) (result *cephrookiov1.CephRBDMirror, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(cephrbdmirrorsResource, c.ns, name), &cephrookiov1.CephRBDMirror{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*cephrookiov1.CephRBDMirror), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of CephRBDMirrors that match those selectors.
|
||||
func (c *FakeCephRBDMirrors) List(opts v1.ListOptions) (result *cephrookiov1.CephRBDMirrorList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(cephrbdmirrorsResource, cephrbdmirrorsKind, c.ns, opts), &cephrookiov1.CephRBDMirrorList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &cephrookiov1.CephRBDMirrorList{ListMeta: obj.(*cephrookiov1.CephRBDMirrorList).ListMeta}
|
||||
for _, item := range obj.(*cephrookiov1.CephRBDMirrorList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested cephRBDMirrors.
|
||||
func (c *FakeCephRBDMirrors) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(cephrbdmirrorsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a cephRBDMirror and creates it. Returns the server's representation of the cephRBDMirror, and an error, if there is any.
|
||||
func (c *FakeCephRBDMirrors) Create(cephRBDMirror *cephrookiov1.CephRBDMirror) (result *cephrookiov1.CephRBDMirror, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(cephrbdmirrorsResource, c.ns, cephRBDMirror), &cephrookiov1.CephRBDMirror{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*cephrookiov1.CephRBDMirror), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a cephRBDMirror and updates it. Returns the server's representation of the cephRBDMirror, and an error, if there is any.
|
||||
func (c *FakeCephRBDMirrors) Update(cephRBDMirror *cephrookiov1.CephRBDMirror) (result *cephrookiov1.CephRBDMirror, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(cephrbdmirrorsResource, c.ns, cephRBDMirror), &cephrookiov1.CephRBDMirror{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*cephrookiov1.CephRBDMirror), err
|
||||
}
|
||||
|
||||
// Delete takes name of the cephRBDMirror and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeCephRBDMirrors) Delete(name string, options *v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(cephrbdmirrorsResource, c.ns, name), &cephrookiov1.CephRBDMirror{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeCephRBDMirrors) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(cephrbdmirrorsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &cephrookiov1.CephRBDMirrorList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched cephRBDMirror.
|
||||
func (c *FakeCephRBDMirrors) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *cephrookiov1.CephRBDMirror, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(cephrbdmirrorsResource, c.ns, name, pt, data, subresources...), &cephrookiov1.CephRBDMirror{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*cephrookiov1.CephRBDMirror), err
|
||||
}
|
||||
@@ -31,3 +31,5 @@ type CephNFSExpansion interface{}
|
||||
type CephObjectStoreExpansion interface{}
|
||||
|
||||
type CephObjectStoreUserExpansion interface{}
|
||||
|
||||
type CephRBDMirrorExpansion interface{}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
cephrookiov1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
versioned "github.com/rook/rook/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/rook/rook/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1 "github.com/rook/rook/pkg/client/listers/ceph.rook.io/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// CephRBDMirrorInformer provides access to a shared informer and lister for
|
||||
// CephRBDMirrors.
|
||||
type CephRBDMirrorInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1.CephRBDMirrorLister
|
||||
}
|
||||
|
||||
type cephRBDMirrorInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewCephRBDMirrorInformer constructs a new informer for CephRBDMirror type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewCephRBDMirrorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredCephRBDMirrorInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredCephRBDMirrorInformer constructs a new informer for CephRBDMirror type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredCephRBDMirrorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CephV1().CephRBDMirrors(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CephV1().CephRBDMirrors(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&cephrookiov1.CephRBDMirror{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *cephRBDMirrorInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredCephRBDMirrorInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *cephRBDMirrorInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&cephrookiov1.CephRBDMirror{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *cephRBDMirrorInformer) Lister() v1.CephRBDMirrorLister {
|
||||
return v1.NewCephRBDMirrorLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -38,6 +38,8 @@ type Interface interface {
|
||||
CephObjectStores() CephObjectStoreInformer
|
||||
// CephObjectStoreUsers returns a CephObjectStoreUserInformer.
|
||||
CephObjectStoreUsers() CephObjectStoreUserInformer
|
||||
// CephRBDMirrors returns a CephRBDMirrorInformer.
|
||||
CephRBDMirrors() CephRBDMirrorInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
@@ -85,3 +87,8 @@ func (v *version) CephObjectStores() CephObjectStoreInformer {
|
||||
func (v *version) CephObjectStoreUsers() CephObjectStoreUserInformer {
|
||||
return &cephObjectStoreUserInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// CephRBDMirrors returns a CephRBDMirrorInformer.
|
||||
func (v *version) CephRBDMirrors() CephRBDMirrorInformer {
|
||||
return &cephRBDMirrorInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
@@ -77,6 +77,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectStores().Informer()}, nil
|
||||
case v1.SchemeGroupVersion.WithResource("cephobjectstoreusers"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectStoreUsers().Informer()}, nil
|
||||
case v1.SchemeGroupVersion.WithResource("cephrbdmirrors"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephRBDMirrors().Informer()}, nil
|
||||
|
||||
// Group=cockroachdb.rook.io, Version=v1alpha1
|
||||
case cockroachdbrookiov1alpha1.SchemeGroupVersion.WithResource("clusters"):
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
v1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// CephRBDMirrorLister helps list CephRBDMirrors.
|
||||
type CephRBDMirrorLister interface {
|
||||
// List lists all CephRBDMirrors in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1.CephRBDMirror, err error)
|
||||
// CephRBDMirrors returns an object that can list and get CephRBDMirrors.
|
||||
CephRBDMirrors(namespace string) CephRBDMirrorNamespaceLister
|
||||
CephRBDMirrorListerExpansion
|
||||
}
|
||||
|
||||
// cephRBDMirrorLister implements the CephRBDMirrorLister interface.
|
||||
type cephRBDMirrorLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewCephRBDMirrorLister returns a new CephRBDMirrorLister.
|
||||
func NewCephRBDMirrorLister(indexer cache.Indexer) CephRBDMirrorLister {
|
||||
return &cephRBDMirrorLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all CephRBDMirrors in the indexer.
|
||||
func (s *cephRBDMirrorLister) List(selector labels.Selector) (ret []*v1.CephRBDMirror, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1.CephRBDMirror))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// CephRBDMirrors returns an object that can list and get CephRBDMirrors.
|
||||
func (s *cephRBDMirrorLister) CephRBDMirrors(namespace string) CephRBDMirrorNamespaceLister {
|
||||
return cephRBDMirrorNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// CephRBDMirrorNamespaceLister helps list and get CephRBDMirrors.
|
||||
type CephRBDMirrorNamespaceLister interface {
|
||||
// List lists all CephRBDMirrors in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1.CephRBDMirror, err error)
|
||||
// Get retrieves the CephRBDMirror from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1.CephRBDMirror, error)
|
||||
CephRBDMirrorNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// cephRBDMirrorNamespaceLister implements the CephRBDMirrorNamespaceLister
|
||||
// interface.
|
||||
type cephRBDMirrorNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all CephRBDMirrors in the indexer for a given namespace.
|
||||
func (s cephRBDMirrorNamespaceLister) List(selector labels.Selector) (ret []*v1.CephRBDMirror, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1.CephRBDMirror))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the CephRBDMirror from the indexer for a given namespace and name.
|
||||
func (s cephRBDMirrorNamespaceLister) Get(name string) (*v1.CephRBDMirror, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1.Resource("cephrbdmirror"), name)
|
||||
}
|
||||
return obj.(*v1.CephRBDMirror), nil
|
||||
}
|
||||
@@ -73,3 +73,11 @@ type CephObjectStoreUserListerExpansion interface{}
|
||||
// CephObjectStoreUserNamespaceListerExpansion allows custom methods to be added to
|
||||
// CephObjectStoreUserNamespaceLister.
|
||||
type CephObjectStoreUserNamespaceListerExpansion interface{}
|
||||
|
||||
// CephRBDMirrorListerExpansion allows custom methods to be added to
|
||||
// CephRBDMirrorLister.
|
||||
type CephRBDMirrorListerExpansion interface{}
|
||||
|
||||
// CephRBDMirrorNamespaceListerExpansion allows custom methods to be added to
|
||||
// CephRBDMirrorNamespaceLister.
|
||||
type CephRBDMirrorNamespaceListerExpansion interface{}
|
||||
@@ -37,7 +37,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mgr"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/rbd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
@@ -299,16 +298,6 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers
|
||||
return errors.Wrapf(err, "failed to start the osds")
|
||||
}
|
||||
|
||||
// Start the rbd mirroring daemon(s)
|
||||
rbdmirror := rbd.New(c.Info, c.context, c.Namespace, rookImage, spec.CephVersion, cephv1.GetRBDMirrorPlacement(spec.Placement),
|
||||
cephv1.GetRBDMirrorAnnotations(spec.Annotations), spec.Network, spec.RBDMirroring,
|
||||
cephv1.GetRBDMirrorResources(spec.Resources), cephv1.GetRBDMirrorPriorityClassName(spec.PriorityClassNames),
|
||||
c.ownerRef, c.Spec.DataDirHostPath, c.Spec.SkipUpgradeChecks)
|
||||
err = rbdmirror.Start()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to start the rbd mirrors")
|
||||
}
|
||||
|
||||
logger.Infof("Done creating rook instance in namespace %s", c.Namespace)
|
||||
c.initCompleted = true
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
@@ -40,12 +39,14 @@ type daemonConfig struct {
|
||||
ResourceName string // the name rook gives to mirror resources in k8s metadata
|
||||
DaemonID string // the ID of the Ceph daemon ("a", "b", ...)
|
||||
DataPathMap *config.DataPathMap // location to store data in container
|
||||
ownerRef metav1.OwnerReference
|
||||
namespace string
|
||||
}
|
||||
|
||||
func (m *Mirroring) generateKeyring(daemonConfig *daemonConfig) (string, error) {
|
||||
func (r *ReconcileCephRBDMirror) generateKeyring(daemonConfig *daemonConfig) (string, error) {
|
||||
user := fullDaemonName(daemonConfig.DaemonID)
|
||||
access := []string{"mon", "profile rbd-mirror", "osd", "profile rbd"}
|
||||
s := keyring.GetSecretStore(m.context, m.Namespace, &m.ownerRef)
|
||||
s := keyring.GetSecretStore(r.context, daemonConfig.namespace, &daemonConfig.ownerRef)
|
||||
|
||||
key, err := s.GenerateKey(user, access)
|
||||
if err != nil {
|
||||
@@ -53,7 +54,7 @@ func (m *Mirroring) generateKeyring(daemonConfig *daemonConfig) (string, error)
|
||||
}
|
||||
|
||||
// Delete legacy key store for upgrade from Rook v0.9.x to v1.0.x
|
||||
err = m.context.Clientset.CoreV1().Secrets(m.Namespace).Delete(daemonConfig.ResourceName, &metav1.DeleteOptions{})
|
||||
err = r.context.Clientset.CoreV1().Secrets(daemonConfig.namespace).Delete(daemonConfig.ResourceName, &metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
logger.Debugf("legacy rbd-mirror key %q is already removed", daemonConfig.ResourceName)
|
||||
@@ -66,11 +67,6 @@ func (m *Mirroring) generateKeyring(daemonConfig *daemonConfig) (string, error)
|
||||
return keyring, s.CreateOrUpdate(daemonConfig.ResourceName, keyring)
|
||||
}
|
||||
|
||||
func (m *Mirroring) associateKeyring(existingKeyring string, d *apps.Deployment) error {
|
||||
s := keyring.GetSecretStoreForDeployment(m.context, d)
|
||||
return s.CreateOrUpdate(d.GetName(), existingKeyring)
|
||||
}
|
||||
|
||||
func fullDaemonName(daemonID string) string {
|
||||
return fmt.Sprintf("client.rbd-mirror.%s", daemonID)
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
Copyright 2020 The Rook Authors. All rights reserved.
|
||||
|
||||
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 rbd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
opconfig "github.com/rook/rook/pkg/operator/ceph/config"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"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 (
|
||||
controllerName = "ceph-rbd-mirror-controller"
|
||||
)
|
||||
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", controllerName)
|
||||
|
||||
// List of object resources to watch by the controller
|
||||
var objectsToWatch = []runtime.Object{
|
||||
&v1.Service{TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: v1.SchemeGroupVersion.String()}},
|
||||
&v1.ConfigMap{TypeMeta: metav1.TypeMeta{Kind: "ConfigMap", APIVersion: v1.SchemeGroupVersion.String()}},
|
||||
&appsv1.Deployment{TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: appsv1.SchemeGroupVersion.String()}},
|
||||
}
|
||||
|
||||
var cephRBDMirrorKind = reflect.TypeOf(cephv1.CephRBDMirror{}).Name()
|
||||
|
||||
// Sets the type meta for the controller main object
|
||||
var controllerTypeMeta = metav1.TypeMeta{
|
||||
Kind: cephRBDMirrorKind,
|
||||
APIVersion: fmt.Sprintf("%s/%s", cephv1.CustomResourceGroup, cephv1.Version),
|
||||
}
|
||||
|
||||
// ReconcileCephRBDMirror reconciles a cephRBDMirror object
|
||||
type ReconcileCephRBDMirror struct {
|
||||
client client.Client
|
||||
scheme *runtime.Scheme
|
||||
context *clusterd.Context
|
||||
cephClusterSpec *cephv1.ClusterSpec
|
||||
clusterInfo *cephconfig.ClusterInfo
|
||||
}
|
||||
|
||||
// Add creates a new cephRBDMirror Controller and adds it to the Manager. The Manager will set fields on the Controller
|
||||
// and Start it when the Manager is Started.
|
||||
func Add(mgr manager.Manager, context *clusterd.Context) error {
|
||||
return add(mgr, newReconciler(mgr, context))
|
||||
}
|
||||
|
||||
// newReconciler returns a new reconcile.Reconciler
|
||||
func newReconciler(mgr manager.Manager, context *clusterd.Context) reconcile.Reconciler {
|
||||
// Add the cephv1 scheme to the manager scheme so that the controller knows about it
|
||||
mgrScheme := mgr.GetScheme()
|
||||
cephv1.AddToScheme(mgr.GetScheme())
|
||||
|
||||
return &ReconcileCephRBDMirror{
|
||||
client: mgr.GetClient(),
|
||||
scheme: mgrScheme,
|
||||
context: context,
|
||||
}
|
||||
}
|
||||
|
||||
func add(mgr manager.Manager, r reconcile.Reconciler) error {
|
||||
// Create a new controller
|
||||
c, err := controller.New(controllerName, mgr, controller.Options{Reconciler: r})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Watch for changes on the cephRBDMirror CRD object
|
||||
err = c.Watch(&source.Kind{Type: &cephv1.CephRBDMirror{TypeMeta: controllerTypeMeta}}, &handler.EnqueueRequestForObject{}, opcontroller.WatchControllerPredicate())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Watch all other resources
|
||||
for _, t := range objectsToWatch {
|
||||
err = c.Watch(&source.Kind{Type: t}, &handler.EnqueueRequestForOwner{
|
||||
IsController: true,
|
||||
OwnerType: &cephv1.CephRBDMirror{},
|
||||
}, opcontroller.WatchPredicateForNonCRDObject(&cephv1.CephRBDMirror{TypeMeta: controllerTypeMeta}, mgr.GetScheme()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reconcile reads that state of the cluster for a cephRBDMirror object and makes changes based on the state read
|
||||
// and what is in the cephRBDMirror.Spec
|
||||
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
|
||||
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
|
||||
func (r *ReconcileCephRBDMirror) Reconcile(request reconcile.Request) (reconcile.Result, error) {
|
||||
// workaround because the rook logging mechanism is not compatible with the controller-runtime loggin interface
|
||||
reconcileResponse, err := r.reconcile(request)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to reconcile %v", err)
|
||||
}
|
||||
|
||||
return reconcileResponse, err
|
||||
}
|
||||
|
||||
func (r *ReconcileCephRBDMirror) reconcile(request reconcile.Request) (reconcile.Result, error) {
|
||||
// Fetch the cephRBDMirror instance
|
||||
cephRBDMirror := &cephv1.CephRBDMirror{}
|
||||
err := r.client.Get(context.TODO(), request.NamespacedName, cephRBDMirror)
|
||||
if err != nil {
|
||||
if kerrors.IsNotFound(err) {
|
||||
logger.Debug("cephRBDMirror resource not found. Ignoring since object must be deleted.")
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
// Error reading the object - requeue the request.
|
||||
return reconcile.Result{}, errors.Wrap(err, "failed to get cephRBDMirror")
|
||||
}
|
||||
|
||||
// The CR was just created, initializing status fields
|
||||
if cephRBDMirror.Status == nil {
|
||||
updateStatus(r.client, request.NamespacedName, k8sutil.Created)
|
||||
}
|
||||
|
||||
// Make sure a CephCluster is present otherwise do nothing
|
||||
cephClusterSpec, isReadyToReconcile, _, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
|
||||
if !isReadyToReconcile {
|
||||
logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String())
|
||||
return reconcileResponse, nil
|
||||
}
|
||||
r.cephClusterSpec = &cephClusterSpec
|
||||
|
||||
// Populate clusterInfo
|
||||
// Always populate it during each reconcile
|
||||
clusterInfo, _, _, err := mon.LoadClusterInfo(r.context, request.NamespacedName.Namespace)
|
||||
if err != nil {
|
||||
return reconcile.Result{}, errors.Wrap(err, "failed to populate cluster info")
|
||||
}
|
||||
r.clusterInfo = clusterInfo
|
||||
|
||||
// Populate CephVersion
|
||||
daemon := string(opconfig.MonType)
|
||||
currentCephVersion, err := cephclient.LeastUptodateDaemonVersion(r.context, r.clusterInfo.Name, daemon)
|
||||
if err != nil {
|
||||
return reconcile.Result{}, errors.Wrapf(err, "failed to retrieve current ceph %q version", daemon)
|
||||
}
|
||||
r.clusterInfo.CephVersion = currentCephVersion
|
||||
|
||||
// CREATE/UPDATE
|
||||
logger.Debug("reconciling ceph rbd mirror deployments")
|
||||
reconcileResponse, err = r.reconcileCreateCephRBDMirror(cephRBDMirror)
|
||||
if err != nil {
|
||||
updateStatus(r.client, request.NamespacedName, k8sutil.FailedStatus)
|
||||
return reconcile.Result{}, errors.Wrap(err, "failed to create ceph rbd mirror deployments")
|
||||
}
|
||||
|
||||
// Set Ready status, we are done reconciling
|
||||
updateStatus(r.client, request.NamespacedName, k8sutil.ReadyStatus)
|
||||
|
||||
// Return and do not requeue
|
||||
logger.Debug("done reconciling ceph rbd mirror")
|
||||
return reconcile.Result{}, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *ReconcileCephRBDMirror) reconcileCreateCephRBDMirror(cephRBDMirror *cephv1.CephRBDMirror) (reconcile.Result, error) {
|
||||
if r.cephClusterSpec.External.Enable {
|
||||
_, err := opcontroller.ValidateCephVersionsBetweenLocalAndExternalClusters(r.context, cephRBDMirror.Namespace, r.clusterInfo.CephVersion)
|
||||
if err != nil {
|
||||
// This handles the case where the operator is running, the external cluster has been upgraded and a CR creation is called
|
||||
// If that's a major version upgrade we fail, if it's a minor version, we continue, it's not ideal but not critical
|
||||
return reconcile.Result{}, errors.Wrapf(err, "refusing to run new crd")
|
||||
}
|
||||
}
|
||||
|
||||
err := r.start(cephRBDMirror)
|
||||
if err != nil {
|
||||
return reconcile.Result{}, errors.Wrapf(err, "failed to start rbd mirror")
|
||||
}
|
||||
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
|
||||
func (r *ReconcileCephRBDMirror) setFailedStatus(cephRBDMirror *cephv1.CephRBDMirror, errMessage string, err error) (reconcile.Result, error) {
|
||||
cephRBDMirror.Status.Phase = k8sutil.ReconcileFailedStatus
|
||||
errStatus := opcontroller.UpdateStatus(r.client, cephRBDMirror)
|
||||
if errStatus != nil {
|
||||
logger.Errorf("failed to set status. %v", errStatus)
|
||||
}
|
||||
|
||||
return reconcile.Result{}, errors.Wrapf(err, "%s", errMessage)
|
||||
}
|
||||
|
||||
// updateStatus updates an object with a given status
|
||||
func updateStatus(client client.Client, name types.NamespacedName, status string) {
|
||||
rbdMirror := &cephv1.CephRBDMirror{}
|
||||
err := client.Get(context.TODO(), name, rbdMirror)
|
||||
if err != nil {
|
||||
if kerrors.IsNotFound(err) {
|
||||
logger.Debug("CephRBDMirror resource not found. Ignoring since object must be deleted.")
|
||||
return
|
||||
}
|
||||
logger.Warningf("failed to retrieve rbd mirror %q to update status to %q. %v", name, status, err)
|
||||
return
|
||||
}
|
||||
|
||||
if rbdMirror.Status == nil {
|
||||
rbdMirror.Status = &cephv1.Status{}
|
||||
}
|
||||
|
||||
rbdMirror.Status.Phase = status
|
||||
if err := opcontroller.UpdateStatus(client, rbdMirror); err != nil {
|
||||
logger.Errorf("failed to set rbd mirror %q status to %q. %v", rbdMirror.Name, status, err)
|
||||
return
|
||||
}
|
||||
logger.Debugf("rbd mirror %q status updated to %q", name, status)
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
Copyright 2020 The Rook Authors. All rights reserved.
|
||||
|
||||
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 file to manage a rook filesystem
|
||||
package rbd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookclient "github.com/rook/rook/pkg/client/clientset/versioned/fake"
|
||||
"github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
)
|
||||
|
||||
const (
|
||||
cephAuthGetOrCreateKey = `{"key":"AQCvzWBeIV9lFRAAninzm+8XFxbSfTiPwoX50g=="}`
|
||||
dummyVersionsRaw = `
|
||||
{
|
||||
"mon": {
|
||||
"ceph version 14.2.8 (3a54b2b6d167d4a2a19e003a705696d4fe619afc) nautilus (stable)": 3
|
||||
}
|
||||
}`
|
||||
)
|
||||
|
||||
func TestCephRBDMirrorController(t *testing.T) {
|
||||
var (
|
||||
name = "my-fs"
|
||||
namespace = "rook-ceph"
|
||||
)
|
||||
// Set DEBUG logging
|
||||
capnslog.SetGlobalLogLevel(capnslog.DEBUG)
|
||||
os.Setenv("ROOK_LOG_LEVEL", "DEBUG")
|
||||
|
||||
//
|
||||
// TEST 1 SETUP
|
||||
//
|
||||
// FAILURE because no CephCluster
|
||||
//
|
||||
// An rbd-mirror resource with metadata and spec.
|
||||
fs := &cephv1.CephRBDMirror{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: cephv1.RBDMirroringSpec{
|
||||
Count: 1,
|
||||
},
|
||||
TypeMeta: controllerTypeMeta,
|
||||
}
|
||||
cephCluster := &cephv1.CephCluster{}
|
||||
|
||||
// Objects to track in the fake client.
|
||||
object := []runtime.Object{
|
||||
fs,
|
||||
}
|
||||
|
||||
executor := &exectest.MockExecutor{
|
||||
MockExecuteCommandWithOutputFile: func(command, outfile string, args ...string) (string, error) {
|
||||
if args[0] == "status" {
|
||||
return `{"fsid":"c47cac40-9bee-4d52-823b-ccd803ba5bfe","health":{"checks":{},"status":"HEALTH_ERR"},"pgmap":{"num_pgs":100,"pgs_by_state":[{"state_name":"active+clean","count":100}]}}`, nil
|
||||
}
|
||||
if args[0] == "auth" && args[1] == "get-or-create-key" {
|
||||
return cephAuthGetOrCreateKey, nil
|
||||
}
|
||||
if args[0] == "versions" {
|
||||
return dummyVersionsRaw, nil
|
||||
}
|
||||
return "", nil
|
||||
},
|
||||
}
|
||||
clientset := test.New(t, 3)
|
||||
c := &clusterd.Context{
|
||||
Executor: executor,
|
||||
RookClientset: rookclient.NewSimpleClientset(),
|
||||
Clientset: clientset,
|
||||
}
|
||||
|
||||
// Register operator types with the runtime scheme.
|
||||
s := scheme.Scheme
|
||||
s.AddKnownTypes(cephv1.SchemeGroupVersion, &cephv1.CephObjectStore{})
|
||||
s.AddKnownTypes(cephv1.SchemeGroupVersion, &cephv1.CephCluster{})
|
||||
|
||||
// Create a fake client to mock API calls.
|
||||
cl := fake.NewFakeClientWithScheme(s, object...)
|
||||
// Create a ReconcileCephRBDMirror object with the scheme and fake client.
|
||||
r := &ReconcileCephRBDMirror{client: cl, scheme: s, context: c}
|
||||
|
||||
// Mock request to simulate Reconcile() being called on an event for a
|
||||
// watched resource .
|
||||
req := reconcile.Request{
|
||||
NamespacedName: types.NamespacedName{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
}
|
||||
logger.Info("STARTING PHASE 1")
|
||||
res, err := r.Reconcile(req)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, res.Requeue)
|
||||
logger.Info("PHASE 1 DONE")
|
||||
|
||||
//
|
||||
// TEST 2:
|
||||
//
|
||||
// FAILURE we have a cluster but it's not ready
|
||||
//
|
||||
cephCluster = &cephv1.CephCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: namespace,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Status: cephv1.ClusterStatus{
|
||||
Phase: "",
|
||||
},
|
||||
}
|
||||
object = append(object, cephCluster)
|
||||
// Create a fake client to mock API calls.
|
||||
cl = fake.NewFakeClientWithScheme(s, object...)
|
||||
// Create a ReconcileCephRBDMirror object with the scheme and fake client.
|
||||
r = &ReconcileCephRBDMirror{client: cl, scheme: s, context: c}
|
||||
logger.Info("STARTING PHASE 2")
|
||||
res, err = r.Reconcile(req)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, res.Requeue)
|
||||
logger.Info("PHASE 2 DONE")
|
||||
|
||||
//
|
||||
// TEST 3:
|
||||
//
|
||||
// SUCCESS! The CephCluster is ready
|
||||
//
|
||||
|
||||
// Mock clusterInfo
|
||||
secrets := map[string][]byte{
|
||||
"cluster-name": []byte("foo-cluster"),
|
||||
"fsid": []byte(name),
|
||||
"mon-secret": []byte("monsecret"),
|
||||
"admin-secret": []byte("adminsecret"),
|
||||
}
|
||||
secret := &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "rook-ceph-mon",
|
||||
Namespace: namespace,
|
||||
},
|
||||
Data: secrets,
|
||||
Type: k8sutil.RookType,
|
||||
}
|
||||
_, err = c.Clientset.CoreV1().Secrets(namespace).Create(secret)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Add ready status to the CephCluster
|
||||
cephCluster.Status.Phase = k8sutil.ReadyStatus
|
||||
|
||||
// Create a fake client to mock API calls.
|
||||
cl = fake.NewFakeClientWithScheme(s, object...)
|
||||
|
||||
executor = &exectest.MockExecutor{
|
||||
MockExecuteCommandWithOutputFile: func(command, outfile string, args ...string) (string, error) {
|
||||
if args[0] == "status" {
|
||||
return `{"fsid":"c47cac40-9bee-4d52-823b-ccd803ba5bfe","health":{"checks":{},"status":"HEALTH_OK"},"pgmap":{"num_pgs":100,"pgs_by_state":[{"state_name":"active+clean","count":100}]}}`, nil
|
||||
}
|
||||
if args[0] == "auth" && args[1] == "get-or-create-key" {
|
||||
return cephAuthGetOrCreateKey, nil
|
||||
}
|
||||
return "", nil
|
||||
},
|
||||
}
|
||||
c.Executor = executor
|
||||
|
||||
// Create a ReconcileCephRBDMirror object with the scheme and fake client.
|
||||
r = &ReconcileCephRBDMirror{client: cl, scheme: s, context: c}
|
||||
|
||||
logger.Info("STARTING PHASE 3")
|
||||
res, err = r.Reconcile(req)
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, res.Requeue)
|
||||
err = r.client.Get(context.TODO(), req.NamespacedName, fs)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "Ready", fs.Status.Phase, fs)
|
||||
logger.Info("PHASE 3 DONE")
|
||||
}
|
||||
@@ -21,23 +21,18 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/banzaicloud/k8s-objectmatcher/patch"
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
)
|
||||
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "rbd-mirror")
|
||||
|
||||
const (
|
||||
// AppName is the ceph rbd mirror application name
|
||||
AppName = "rook-ceph-rbd-mirror"
|
||||
@@ -45,86 +40,49 @@ const (
|
||||
cephRbdMirrorPodMinimumMemory uint64 = 512
|
||||
)
|
||||
|
||||
// Mirroring represents the Rook and environment configuration settings needed to set up rbd mirroring.
|
||||
type Mirroring struct {
|
||||
ClusterInfo *cephconfig.ClusterInfo
|
||||
Namespace string
|
||||
placement rookv1.Placement
|
||||
annotations rookv1.Annotations
|
||||
context *clusterd.Context
|
||||
resources v1.ResourceRequirements
|
||||
priorityClassName string
|
||||
ownerRef metav1.OwnerReference
|
||||
spec cephv1.RBDMirroringSpec
|
||||
cephVersion cephv1.CephVersionSpec
|
||||
rookVersion string
|
||||
Network cephv1.NetworkSpec
|
||||
dataDirHostPath string
|
||||
skipUpgradeChecks bool
|
||||
}
|
||||
|
||||
// New creates an instance of the rbd mirroring
|
||||
func New(
|
||||
cluster *cephconfig.ClusterInfo,
|
||||
context *clusterd.Context,
|
||||
namespace, rookVersion string,
|
||||
cephVersion cephv1.CephVersionSpec,
|
||||
placement rookv1.Placement,
|
||||
annotations rookv1.Annotations,
|
||||
network cephv1.NetworkSpec,
|
||||
spec cephv1.RBDMirroringSpec,
|
||||
resources v1.ResourceRequirements,
|
||||
priorityClassName string,
|
||||
ownerRef metav1.OwnerReference,
|
||||
dataDirHostPath string,
|
||||
skipUpgradeChecks bool,
|
||||
) *Mirroring {
|
||||
return &Mirroring{
|
||||
ClusterInfo: cluster,
|
||||
context: context,
|
||||
Namespace: namespace,
|
||||
placement: placement,
|
||||
annotations: annotations,
|
||||
rookVersion: rookVersion,
|
||||
cephVersion: cephVersion,
|
||||
spec: spec,
|
||||
Network: network,
|
||||
resources: resources,
|
||||
priorityClassName: priorityClassName,
|
||||
ownerRef: ownerRef,
|
||||
dataDirHostPath: dataDirHostPath,
|
||||
skipUpgradeChecks: skipUpgradeChecks,
|
||||
}
|
||||
}
|
||||
|
||||
var updateDeploymentAndWait = mon.UpdateCephDeploymentAndWait
|
||||
|
||||
// Start begins the process of running rbd mirroring daemons.
|
||||
func (m *Mirroring) Start() error {
|
||||
func (r *ReconcileCephRBDMirror) start(cephRBDMirror *cephv1.CephRBDMirror) error {
|
||||
// Validate pod's memory if specified
|
||||
err := controller.CheckPodMemory(m.resources, cephRbdMirrorPodMinimumMemory)
|
||||
err := controller.CheckPodMemory(cephRBDMirror.Spec.Resources, cephRbdMirrorPodMinimumMemory)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error checking pod memory")
|
||||
}
|
||||
|
||||
logger.Infof("configure rbd-mirroring with %d workers", m.spec.Workers)
|
||||
// Create the controller owner ref
|
||||
// It will be associated to all resources of the CephRBDMirror
|
||||
ref, err := opcontroller.GetControllerObjectOwnerReference(cephRBDMirror, r.scheme)
|
||||
if err != nil || ref == nil {
|
||||
return errors.Wrapf(err, "failed to get controller %q owner reference", cephRBDMirror.Name)
|
||||
}
|
||||
|
||||
for i := 0; i < m.spec.Workers; i++ {
|
||||
logger.Infof("configure rbd-mirroring with %d workers", cephRBDMirror.Spec.Count)
|
||||
|
||||
for i := 0; i < cephRBDMirror.Spec.Count; i++ {
|
||||
daemonID := k8sutil.IndexToName(i)
|
||||
resourceName := fmt.Sprintf("%s-%s", AppName, daemonID)
|
||||
daemonConf := &daemonConfig{
|
||||
DaemonID: daemonID,
|
||||
ResourceName: resourceName,
|
||||
DataPathMap: config.NewDatalessDaemonDataPathMap(m.Namespace, m.dataDirHostPath),
|
||||
DataPathMap: config.NewDatalessDaemonDataPathMap(cephRBDMirror.Namespace, r.cephClusterSpec.DataDirHostPath),
|
||||
ownerRef: *ref,
|
||||
namespace: cephRBDMirror.Namespace,
|
||||
}
|
||||
|
||||
keyring, err := m.generateKeyring(daemonConf)
|
||||
_, err := r.generateKeyring(daemonConf)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to generate keyring for %q", resourceName)
|
||||
}
|
||||
|
||||
// Start the deployment
|
||||
d := m.makeDeployment(daemonConf)
|
||||
d := r.makeDeployment(daemonConf, cephRBDMirror)
|
||||
|
||||
// Set owner ref to cephRBDMirror object
|
||||
err = controllerutil.SetControllerReference(cephRBDMirror, d, r.scheme)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to set owner reference for ceph filesystem %q secret", d.Name)
|
||||
}
|
||||
|
||||
// Set the deployment hash as an annotation
|
||||
err = patch.DefaultAnnotator.SetLastAppliedAnnotation(d)
|
||||
@@ -132,37 +90,30 @@ func (m *Mirroring) Start() error {
|
||||
return errors.Wrapf(err, "failed to set annotation for deployment %q", d.Name)
|
||||
}
|
||||
|
||||
if _, err := m.context.Clientset.AppsV1().Deployments(m.Namespace).Create(d); err != nil {
|
||||
if _, err := r.context.Clientset.AppsV1().Deployments(cephRBDMirror.Namespace).Create(d); err != nil {
|
||||
if !kerrors.IsAlreadyExists(err) {
|
||||
return errors.Wrapf(err, "failed to create %s deployment", resourceName)
|
||||
return errors.Wrapf(err, "failed to create %q deployment", resourceName)
|
||||
}
|
||||
logger.Infof("deployment for rbd-mirror %s already exists. updating if needed", resourceName)
|
||||
logger.Infof("deployment for rbd-mirror %q already exists. updating if needed", resourceName)
|
||||
|
||||
if err := updateDeploymentAndWait(m.context, d, m.Namespace, config.RbdMirrorType, daemonConf.DaemonID, m.skipUpgradeChecks, false); err != nil {
|
||||
if err := updateDeploymentAndWait(r.context, d, cephRBDMirror.Namespace, config.RbdMirrorType, daemonConf.DaemonID, r.cephClusterSpec.SkipUpgradeChecks, false); err != nil {
|
||||
// fail could be an issue updating label selector (immutable), so try del and recreate
|
||||
logger.Debugf("updateDeploymentAndWait failed for rbd-mirror %q. Attempting del-and-recreate. %v", resourceName, err)
|
||||
err = m.context.Clientset.AppsV1().Deployments(m.Namespace).Delete(d.Name, &metav1.DeleteOptions{})
|
||||
err = r.context.Clientset.AppsV1().Deployments(cephRBDMirror.Namespace).Delete(cephRBDMirror.Name, &metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete rbd-mirror %s during del-and-recreate update attempt", resourceName)
|
||||
return errors.Wrapf(err, "failed to delete rbd-mirror %q during del-and-recreate update attempt", resourceName)
|
||||
}
|
||||
if _, err := m.context.Clientset.AppsV1().Deployments(m.Namespace).Create(d); err != nil {
|
||||
return errors.Wrapf(err, "failed to recreate rbd-mirror deployment %s during del-and-recreate update attempt", resourceName)
|
||||
if _, err := r.context.Clientset.AppsV1().Deployments(cephRBDMirror.Namespace).Create(d); err != nil {
|
||||
return errors.Wrapf(err, "failed to recreate rbd-mirror deployment %q during del-and-recreate update attempt", resourceName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if existingDeployment, err := m.context.Clientset.AppsV1().Deployments(m.Namespace).Get(d.GetName(), metav1.GetOptions{}); err != nil {
|
||||
logger.Warningf("failed to find rbd-mirror deployment %q for keyring association. %v", resourceName, err)
|
||||
} else {
|
||||
if err = m.associateKeyring(keyring, existingDeployment); err != nil {
|
||||
logger.Warningf("failed to associate keyring with rbd-mirror deployment %q. %v", resourceName, err)
|
||||
}
|
||||
}
|
||||
logger.Infof("%s deployment started", resourceName)
|
||||
logger.Infof("%q deployment started", resourceName)
|
||||
}
|
||||
|
||||
// Remove extra rbd-mirror deployments if necessary
|
||||
err = m.removeExtraMirrors()
|
||||
err = r.removeExtraMirrors(cephRBDMirror)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to remove extra mirrors. %v", err)
|
||||
}
|
||||
@@ -170,20 +121,20 @@ func (m *Mirroring) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mirroring) removeExtraMirrors() error {
|
||||
func (r *ReconcileCephRBDMirror) removeExtraMirrors(cephRBDMirror *cephv1.CephRBDMirror) error {
|
||||
opts := metav1.ListOptions{LabelSelector: fmt.Sprintf("app=%s", AppName)}
|
||||
d, err := m.context.Clientset.AppsV1().Deployments(m.Namespace).List(opts)
|
||||
d, err := r.context.Clientset.AppsV1().Deployments(cephRBDMirror.Namespace).List(opts)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get mirrors")
|
||||
}
|
||||
|
||||
if len(d.Items) <= m.spec.Workers {
|
||||
logger.Infof("no extra daemons to remove")
|
||||
if len(d.Items) <= cephRBDMirror.Spec.Count {
|
||||
logger.Info("no extra daemons to remove")
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, deploy := range d.Items {
|
||||
daemonName, ok := deploy.Labels["rbdmirror"]
|
||||
daemonName, ok := deploy.Labels["rbd-mirror"]
|
||||
if !ok {
|
||||
logger.Warningf("unrecognized rbdmirror %s", deploy.Name)
|
||||
continue
|
||||
@@ -193,16 +144,16 @@ func (m *Mirroring) removeExtraMirrors() error {
|
||||
logger.Warningf("unrecognized rbdmirror %s with label %s", deploy.Name, daemonName)
|
||||
continue
|
||||
}
|
||||
if index >= m.spec.Workers {
|
||||
logger.Infof("removing extra rbd-mirror %s", daemonName)
|
||||
if index >= cephRBDMirror.Spec.Count {
|
||||
logger.Infof("removing extra rbd-mirror %q", daemonName)
|
||||
var gracePeriod int64
|
||||
propagation := metav1.DeletePropagationForeground
|
||||
deleteOpts := metav1.DeleteOptions{GracePeriodSeconds: &gracePeriod, PropagationPolicy: &propagation}
|
||||
if err = m.context.Clientset.AppsV1().Deployments(m.Namespace).Delete(deploy.Name, &deleteOpts); err != nil {
|
||||
if err = r.context.Clientset.AppsV1().Deployments(cephRBDMirror.Namespace).Delete(deploy.Name, &deleteOpts); err != nil {
|
||||
logger.Warningf("failed to delete rbd-mirror %q. %v", daemonName, err)
|
||||
}
|
||||
|
||||
logger.Infof("removed rbd-mirror %s", daemonName)
|
||||
logger.Infof("removed rbd-mirror %q", daemonName)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
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 rbd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
||||
testop "github.com/rook/rook/pkg/operator/test"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestRBDMirror(t *testing.T) {
|
||||
clientset := testop.New(t, 1)
|
||||
keysCreated := map[string]bool{}
|
||||
executor := &exectest.MockExecutor{}
|
||||
executor.MockExecuteCommandWithOutputFile = func(command string, outFileArg string, args ...string) (string, error) {
|
||||
logger.Infof("%s %+v", command, args)
|
||||
if args[0] == "auth" && args[1] == "get-or-create-key" {
|
||||
daemonName := args[2]
|
||||
keysCreated[daemonName] = true
|
||||
return "{\"key\":\"mysecurekey\"}", nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
c := New(
|
||||
&cephconfig.ClusterInfo{FSID: "myfsid"},
|
||||
&clusterd.Context{Clientset: clientset, Executor: executor},
|
||||
"ns",
|
||||
"rook/rook:myversion",
|
||||
cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"},
|
||||
rookv1.Placement{},
|
||||
rookv1.Annotations{},
|
||||
cephv1.NetworkSpec{},
|
||||
cephv1.RBDMirroringSpec{Workers: 2},
|
||||
v1.ResourceRequirements{},
|
||||
"my-priority-class",
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
false,
|
||||
)
|
||||
|
||||
err := c.Start()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, keysCreated[fullDaemonName("a")])
|
||||
assert.True(t, keysCreated[fullDaemonName("b")])
|
||||
assert.False(t, keysCreated[fullDaemonName("c")])
|
||||
|
||||
opts := metav1.ListOptions{}
|
||||
d, err := clientset.AppsV1().Deployments(c.Namespace).List(opts)
|
||||
assert.Equal(t, 2, len(d.Items))
|
||||
for _, de := range d.Items {
|
||||
daemonName := de.Name[len(de.Name)-1:]
|
||||
assert.True(t, keysCreated[fullDaemonName(daemonName)])
|
||||
assert.Equal(t, "my-priority-class", de.Spec.Template.Spec.PriorityClassName)
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package rbd
|
||||
|
||||
import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -26,42 +27,42 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func (m *Mirroring) makeDeployment(daemonConfig *daemonConfig) *apps.Deployment {
|
||||
func (r *ReconcileCephRBDMirror) makeDeployment(daemonConfig *daemonConfig, rbdMirror *cephv1.CephRBDMirror) *apps.Deployment {
|
||||
podSpec := v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: daemonConfig.ResourceName,
|
||||
Labels: controller.PodLabels(AppName, m.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
||||
Labels: controller.PodLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
InitContainers: []v1.Container{
|
||||
m.makeChownInitContainer(daemonConfig),
|
||||
r.makeChownInitContainer(daemonConfig, rbdMirror),
|
||||
},
|
||||
Containers: []v1.Container{
|
||||
m.makeMirroringDaemonContainer(daemonConfig),
|
||||
r.makeMirroringDaemonContainer(daemonConfig, rbdMirror),
|
||||
},
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
Volumes: controller.DaemonVolumes(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
||||
HostNetwork: m.Network.IsHost(),
|
||||
PriorityClassName: m.priorityClassName,
|
||||
HostNetwork: r.cephClusterSpec.Network.IsHost(),
|
||||
PriorityClassName: rbdMirror.Spec.PriorityClassName,
|
||||
},
|
||||
}
|
||||
// Replace default unreachable node toleration
|
||||
k8sutil.AddUnreachableNodeToleration(&podSpec.Spec)
|
||||
|
||||
if m.Network.IsHost() {
|
||||
if r.cephClusterSpec.Network.IsHost() {
|
||||
podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
|
||||
} else if m.Network.NetworkSpec.IsMultus() {
|
||||
k8sutil.ApplyMultus(m.Network.NetworkSpec, &podSpec.ObjectMeta)
|
||||
} else if r.cephClusterSpec.Network.IsMultus() {
|
||||
k8sutil.ApplyMultus(r.cephClusterSpec.Network.NetworkSpec, &podSpec.ObjectMeta)
|
||||
}
|
||||
m.placement.ApplyToPodSpec(&podSpec.Spec)
|
||||
rbdMirror.Spec.Placement.ApplyToPodSpec(&podSpec.Spec)
|
||||
|
||||
replicas := int32(1)
|
||||
d := &apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: daemonConfig.ResourceName,
|
||||
Namespace: m.Namespace,
|
||||
Annotations: m.annotations,
|
||||
Labels: controller.PodLabels(AppName, m.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
||||
Namespace: rbdMirror.Namespace,
|
||||
Annotations: rbdMirror.Spec.Annotations,
|
||||
Labels: controller.PodLabels(AppName, rbdMirror.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
||||
},
|
||||
Spec: apps.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
@@ -72,36 +73,36 @@ func (m *Mirroring) makeDeployment(daemonConfig *daemonConfig) *apps.Deployment
|
||||
},
|
||||
}
|
||||
k8sutil.AddRookVersionLabelToDeployment(d)
|
||||
controller.AddCephVersionLabelToDeployment(m.ClusterInfo.CephVersion, d)
|
||||
k8sutil.SetOwnerRef(&d.ObjectMeta, &m.ownerRef)
|
||||
controller.AddCephVersionLabelToDeployment(r.clusterInfo.CephVersion, d)
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
func (m *Mirroring) makeChownInitContainer(daemonConfig *daemonConfig) v1.Container {
|
||||
func (r *ReconcileCephRBDMirror) makeChownInitContainer(daemonConfig *daemonConfig, rbdMirror *cephv1.CephRBDMirror) v1.Container {
|
||||
return controller.ChownCephDataDirsInitContainer(
|
||||
*daemonConfig.DataPathMap,
|
||||
m.cephVersion.Image,
|
||||
r.cephClusterSpec.CephVersion.Image,
|
||||
controller.DaemonVolumeMounts(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
||||
m.resources,
|
||||
rbdMirror.Spec.Resources,
|
||||
mon.PodSecurityContext(),
|
||||
)
|
||||
}
|
||||
|
||||
func (m *Mirroring) makeMirroringDaemonContainer(daemonConfig *daemonConfig) v1.Container {
|
||||
func (r *ReconcileCephRBDMirror) makeMirroringDaemonContainer(daemonConfig *daemonConfig, rbdMirror *cephv1.CephRBDMirror) v1.Container {
|
||||
container := v1.Container{
|
||||
Name: "rbd-mirror",
|
||||
Command: []string{
|
||||
"rbd-mirror",
|
||||
},
|
||||
Args: append(
|
||||
controller.DaemonFlags(m.ClusterInfo, daemonConfig.DaemonID),
|
||||
controller.DaemonFlags(r.clusterInfo, daemonConfig.DaemonID),
|
||||
"--foreground",
|
||||
"--name="+fullDaemonName(daemonConfig.DaemonID),
|
||||
),
|
||||
Image: m.cephVersion.Image,
|
||||
Image: r.cephClusterSpec.CephVersion.Image,
|
||||
VolumeMounts: controller.DaemonVolumeMounts(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
||||
Env: controller.DaemonEnvVars(m.cephVersion.Image),
|
||||
Resources: m.resources,
|
||||
Env: controller.DaemonEnvVars(r.cephClusterSpec.CephVersion.Image),
|
||||
Resources: rbdMirror.Spec.Resources,
|
||||
SecurityContext: mon.PodSecurityContext(),
|
||||
// TODO:
|
||||
// Not implemented at this point since the socket name is '/run/ceph/ceph-client.rbd-mirror.a.1.94362516231272.asok'
|
||||
|
||||
@@ -20,52 +20,71 @@ import (
|
||||
"testing"
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
||||
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
cephtest "github.com/rook/rook/pkg/operator/ceph/test"
|
||||
optest "github.com/rook/rook/pkg/operator/test"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/stretchr/testify/assert"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
)
|
||||
|
||||
func TestPodSpec(t *testing.T) {
|
||||
clientset := optest.New(t, 1)
|
||||
c := New(
|
||||
&cephconfig.ClusterInfo{FSID: "myfsid"},
|
||||
&clusterd.Context{Clientset: clientset},
|
||||
"ns",
|
||||
"rook/rook:myversion",
|
||||
cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"},
|
||||
rookv1.Placement{},
|
||||
rookv1.Annotations{},
|
||||
cephv1.NetworkSpec{},
|
||||
cephv1.RBDMirroringSpec{Workers: 2},
|
||||
v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(200.0, resource.BinarySI),
|
||||
v1.ResourceMemory: *resource.NewQuantity(600.0, resource.BinarySI),
|
||||
},
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI),
|
||||
v1.ResourceMemory: *resource.NewQuantity(300.0, resource.BinarySI),
|
||||
},
|
||||
},
|
||||
"my-priority-class",
|
||||
metav1.OwnerReference{},
|
||||
"/var/lib/rook/",
|
||||
false,
|
||||
)
|
||||
namespace := "ns"
|
||||
daemonConf := daemonConfig{
|
||||
DaemonID: "a",
|
||||
ResourceName: "rook-ceph-rbd-mirror-a",
|
||||
DataPathMap: config.NewDatalessDaemonDataPathMap("rook-ceph", "/var/lib/rook"),
|
||||
namespace: namespace,
|
||||
}
|
||||
cephCluster := &cephv1.CephCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: namespace,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: cephv1.ClusterSpec{
|
||||
CephVersion: cephv1.CephVersionSpec{
|
||||
Image: "ceph/ceph:v14",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
d := c.makeDeployment(&daemonConf)
|
||||
rbdMirror := &cephv1.CephRBDMirror{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "a",
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: cephv1.RBDMirroringSpec{
|
||||
Count: 1,
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(200.0, resource.BinarySI),
|
||||
v1.ResourceMemory: *resource.NewQuantity(600.0, resource.BinarySI),
|
||||
},
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI),
|
||||
v1.ResourceMemory: *resource.NewQuantity(300.0, resource.BinarySI),
|
||||
},
|
||||
},
|
||||
PriorityClassName: "my-priority-class",
|
||||
},
|
||||
TypeMeta: controllerTypeMeta,
|
||||
}
|
||||
clusterInfo := &cephconfig.ClusterInfo{
|
||||
CephVersion: cephver.Nautilus,
|
||||
}
|
||||
s := scheme.Scheme
|
||||
object := []runtime.Object{rbdMirror}
|
||||
cl := fake.NewFakeClientWithScheme(s, object...)
|
||||
r := &ReconcileCephRBDMirror{client: cl, scheme: s}
|
||||
r.cephClusterSpec = &cephCluster.Spec
|
||||
r.clusterInfo = clusterInfo
|
||||
|
||||
d := r.makeDeployment(&daemonConf, rbdMirror)
|
||||
assert.Equal(t, "rook-ceph-rbd-mirror-a", d.Name)
|
||||
|
||||
// Deployment should have Ceph labels
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/crash"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/rbd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/file"
|
||||
"github.com/rook/rook/pkg/operator/ceph/nfs"
|
||||
"github.com/rook/rook/pkg/operator/ceph/object"
|
||||
@@ -37,6 +38,7 @@ var AddToManagerFuncs = []func(manager.Manager, *clusterd.Context) error{
|
||||
object.Add,
|
||||
file.Add,
|
||||
nfs.Add,
|
||||
rbd.Add,
|
||||
}
|
||||
|
||||
// AddToManager adds all the registered controllers to the passed manager.
|
||||
|
||||
@@ -135,11 +135,19 @@ func WatchControllerPredicate() predicate.Funcs {
|
||||
} else if objOld.GetGeneration() != objNew.GetGeneration() {
|
||||
logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name)
|
||||
}
|
||||
// Handling upgrades
|
||||
isUpgrade := isUpgrade(objOld.GetLabels(), objNew.GetLabels())
|
||||
if isUpgrade {
|
||||
|
||||
case *cephv1.CephRBDMirror:
|
||||
objNew := e.ObjectNew.(*cephv1.CephRBDMirror)
|
||||
logger.Debug("update event from the parent object CephRBDMirror")
|
||||
diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer)
|
||||
if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() {
|
||||
// Checking if diff is not empty so we don't print it when the CR gets deleted
|
||||
if diff != "" {
|
||||
logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
logger.Debug("wont update unknown object")
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright 2020 The Rook Authors. All rights reserved.
|
||||
|
||||
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 clients
|
||||
|
||||
import (
|
||||
"github.com/rook/rook/tests/framework/installer"
|
||||
"github.com/rook/rook/tests/framework/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// RBDMirrorOperation is a wrapper for k8s rook rbd mirror operations
|
||||
type RBDMirrorOperation struct {
|
||||
k8sh *utils.K8sHelper
|
||||
manifests installer.CephManifests
|
||||
}
|
||||
|
||||
// CreateRBDMirrorOperation Constructor to create RBDMirrorOperation - client to perform ceph rbd mirror operations on k8s
|
||||
func CreateRBDMirrorOperation(k8sh *utils.K8sHelper, manifests installer.CephManifests) *RBDMirrorOperation {
|
||||
return &RBDMirrorOperation{k8sh, manifests}
|
||||
}
|
||||
|
||||
// Create creates a rbd-mirror in Rook
|
||||
func (r *RBDMirrorOperation) Create(namespace, name string, daemonCount int) error {
|
||||
|
||||
logger.Infof("creating the RBDMirror daemons via CRD")
|
||||
if err := r.k8sh.ResourceOperation("apply", r.manifests.GetRBDMirror(namespace, name, daemonCount)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Infof("Make sure rook-ceph-rbd-mirror pod is running")
|
||||
err := r.k8sh.WaitForLabeledPodsToRun("app=rook-ceph-rbd-mirror", namespace)
|
||||
assert.Nil(r.k8sh.T(), err)
|
||||
|
||||
assert.True(r.k8sh.T(), r.k8sh.CheckPodCountAndState("rook-ceph-rbd-mirror", namespace, daemonCount, "Running"),
|
||||
"Make sure all rbd-mirror daemon pods are in Running state")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes a rbd-mirror in Rook
|
||||
func (r *RBDMirrorOperation) Delete(namespace, name string) error {
|
||||
options := &metav1.DeleteOptions{}
|
||||
logger.Infof("Deleting rbd-mirror %s in namespace %s", name, namespace)
|
||||
err := r.k8sh.RookClientset.CephV1().CephRBDMirrors(namespace).Delete(name, options)
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Infof("Deleted rbd-mirror %s in namespace %s", name, namespace)
|
||||
return nil
|
||||
}
|
||||
@@ -38,6 +38,7 @@ type TestClient struct {
|
||||
PoolClient *PoolOperation
|
||||
BucketClient *BucketOperation
|
||||
UserClient *ClientOperation
|
||||
RBDMirrorClient *RBDMirrorOperation
|
||||
k8sh *utils.K8sHelper
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ func CreateTestClient(k8sHelper *utils.K8sHelper, manifests installer.CephManife
|
||||
CreatePoolOperation(k8sHelper, manifests),
|
||||
CreateBucketOperation(k8sHelper, manifests),
|
||||
CreateClientOperation(k8sHelper, manifests),
|
||||
CreateRBDMirrorOperation(k8sHelper, manifests),
|
||||
k8sHelper,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (h *CephInstaller) CreateRookToolbox(namespace string) (err error) {
|
||||
|
||||
// CreateRookCluster creates rook cluster via kubectl
|
||||
func (h *CephInstaller) CreateRookCluster(namespace, systemNamespace, storeType string, usePVC bool, storageClassName string,
|
||||
mon cephv1.MonSpec, startWithAllNodes bool, rbdMirrorWorkers int, cephVersion cephv1.CephVersionSpec) error {
|
||||
mon cephv1.MonSpec, startWithAllNodes bool, cephVersion cephv1.CephVersionSpec) error {
|
||||
|
||||
dataDirHostPath, err := h.initTestDir(namespace)
|
||||
if err != nil {
|
||||
@@ -201,7 +201,7 @@ osd_pool_default_size = 1
|
||||
}
|
||||
|
||||
logger.Infof("Starting Rook Cluster with yaml")
|
||||
settings := &ClusterSettings{namespace, storeType, dataDirHostPath, mon.Count, rbdMirrorWorkers, usePVC, storageClassName, cephVersion}
|
||||
settings := &ClusterSettings{namespace, storeType, dataDirHostPath, mon.Count, 0, usePVC, storageClassName, cephVersion}
|
||||
rookCluster := h.Manifests.GetRookCluster(settings)
|
||||
if _, err := h.k8shelper.KubectlWithStdin(rookCluster, createFromStdinArgs...); err != nil {
|
||||
return fmt.Errorf("Failed to create rook cluster : %v ", err)
|
||||
@@ -219,12 +219,6 @@ osd_pool_default_size = 1
|
||||
return err
|
||||
}
|
||||
|
||||
if rbdMirrorWorkers > 0 {
|
||||
if err := h.k8shelper.WaitForPodCount("app=rook-ceph-rbd-mirror", namespace, rbdMirrorWorkers); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Infof("Rook Cluster started")
|
||||
err = h.k8shelper.WaitForLabeledPodsToRun("app=rook-ceph-osd", namespace)
|
||||
return err
|
||||
@@ -409,8 +403,7 @@ func (h *CephInstaller) InstallRook(namespace, storeType string, usePVC bool, st
|
||||
|
||||
// Create rook cluster
|
||||
err = h.CreateRookCluster(namespace, onamespace, storeType, usePVC, storageClassName,
|
||||
cephv1.MonSpec{Count: mon.Count, AllowMultiplePerNode: mon.AllowMultiplePerNode}, startWithAllNodes,
|
||||
rbdMirrorWorkers, h.CephVersion)
|
||||
cephv1.MonSpec{Count: mon.Count, AllowMultiplePerNode: mon.AllowMultiplePerNode}, startWithAllNodes, h.CephVersion)
|
||||
if err != nil {
|
||||
logger.Errorf("Rook cluster %s not installed, error -> %v", namespace, err)
|
||||
return false, err
|
||||
@@ -512,7 +505,8 @@ func (h *CephInstaller) UninstallRookFromMultipleNS(systemNamespace string, name
|
||||
"cephclients.ceph.rook.io",
|
||||
"volumes.rook.io",
|
||||
"objectbuckets.objectbucket.io",
|
||||
"objectbucketclaims.objectbucket.io")
|
||||
"objectbucketclaims.objectbucket.io",
|
||||
"cephrbdmirrors.ceph.rook.io")
|
||||
checkError(h.T(), err, "cannot delete CRDs")
|
||||
|
||||
if h.useHelm {
|
||||
|
||||
@@ -43,6 +43,7 @@ type CephManifests interface {
|
||||
GetBlockPVCDef(claimName, namespace, storageClassName, accessModes, size string) string
|
||||
GetFilesystem(namepace, name string, activeCount int) string
|
||||
GetNFS(namepace, name, pool string, daemonCount int) string
|
||||
GetRBDMirror(namepace, name string, daemonCount int) string
|
||||
GetObjectStore(namespace, name string, replicaCount, port int) string
|
||||
GetObjectStoreUser(namespace, name, displayName, store string) string
|
||||
GetBucketStorageClass(namespace, storeName, storageClassName, reclaimPolicy, region string) string
|
||||
@@ -640,6 +641,31 @@ spec:
|
||||
type: string
|
||||
mds:
|
||||
type: string
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: cephrbdmirrors.ceph.rook.io
|
||||
spec:
|
||||
group: ceph.rook.io
|
||||
names:
|
||||
kind: CephRBDMirror
|
||||
listKind: CephRBDMirrorList
|
||||
plural: cephrbdmirrors
|
||||
singular: cephrbdmirror
|
||||
scope: Namespaced
|
||||
version: v1
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
spec:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
subresources:
|
||||
status: {}`
|
||||
}
|
||||
@@ -1836,8 +1862,6 @@ spec:
|
||||
continueUpgradeAfterChecksEvenIfNotHealthy: false
|
||||
dashboard:
|
||||
enabled: true
|
||||
rbdMirroring:
|
||||
workers: ` + strconv.Itoa(settings.RBDMirrorWorkers) + `
|
||||
network:
|
||||
hostNetwork: false
|
||||
crashCollector:
|
||||
@@ -1884,8 +1908,6 @@ spec:
|
||||
dashboard:
|
||||
enabled: true
|
||||
skipUpgradeChecks: true
|
||||
rbdMirroring:
|
||||
workers: ` + strconv.Itoa(settings.RBDMirrorWorkers) + `
|
||||
metadataDevice:
|
||||
storage:
|
||||
useAllNodes: true
|
||||
@@ -2140,6 +2162,17 @@ spec:
|
||||
active: ` + strconv.Itoa(count)
|
||||
}
|
||||
|
||||
// GetRBDMirror returns the manifest to create a Rook Ceph RBD Mirror resource with the given config.
|
||||
func (m *CephManifestsMaster) GetRBDMirror(namespace, name string, count int) string {
|
||||
return `apiVersion: ceph.rook.io/v1
|
||||
kind: CephRBDMirror
|
||||
metadata:
|
||||
name: ` + name + `
|
||||
namespace: ` + namespace + `
|
||||
spec:
|
||||
count: ` + strconv.Itoa(count)
|
||||
}
|
||||
|
||||
func (m *CephManifestsMaster) GetObjectStore(namespace, name string, replicaCount, port int) string {
|
||||
return `apiVersion: ceph.rook.io/v1
|
||||
kind: CephObjectStore
|
||||
|
||||
@@ -1856,3 +1856,8 @@ func (m *CephManifestsV1_1) GetRookExternalCluster(settings *ClusterExternalSett
|
||||
// Not implemented in v1.1
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CephManifestsV1_1) GetRBDMirror(namespace, name string, count int) string {
|
||||
// Not implemented in v1.1
|
||||
return ""
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func (o MCTestOperations) Teardown() {
|
||||
func (o MCTestOperations) startCluster(namespace, store string) error {
|
||||
logger.Infof("starting cluster %s", namespace)
|
||||
err := o.installer.CreateRookCluster(namespace, o.systemNamespace, store, o.testOverPVC, o.storageClassName,
|
||||
cephv1.MonSpec{Count: 1, AllowMultiplePerNode: true}, true, 1, installer.NautilusVersion)
|
||||
cephv1.MonSpec{Count: 1, AllowMultiplePerNode: true}, true, installer.NautilusVersion)
|
||||
if err != nil {
|
||||
o.T().Fail()
|
||||
o.installer.GatherAllRookLogs(o.T().Name(), namespace, o.systemNamespace)
|
||||
|
||||
@@ -272,6 +272,16 @@ func (suite *SmokeSuite) TestCreateClient() {
|
||||
require.Equal(suite.T(), "allow *", caps["osd"], "wrong caps")
|
||||
}
|
||||
|
||||
// Smoke Test for RBD Mirror CRD
|
||||
func (suite *SmokeSuite) TestCreateRBDMirrorClient() {
|
||||
logger.Infof("Create rbd-mirror Smoke Test")
|
||||
|
||||
rbdMirrorName := "my-rbd-mirror"
|
||||
|
||||
err := suite.helper.RBDMirrorClient.Create(suite.namespace, rbdMirrorName, 1)
|
||||
require.Nil(suite.T(), err)
|
||||
}
|
||||
|
||||
func (suite *SmokeSuite) getNonCanaryMonDeployments() ([]appsv1.Deployment, error) {
|
||||
opts := metav1.ListOptions{LabelSelector: "app=rook-ceph-mon"}
|
||||
deployments, err := suite.k8sh.Clientset.AppsV1().Deployments(suite.namespace).List(opts)
|
||||
|
||||
Reference in new issue
Block a user