From 0c6eb7aa3d1cd612712230b6ab3c3b21dd2ff997 Mon Sep 17 00:00:00 2001 From: Alexander Trost Date: Tue, 5 Mar 2019 11:21:57 +0100 Subject: [PATCH] crds: Set annotations pods, deployments and so on Allow the user to set annotations in the CRDs of the following operators which will then be set on the resulting Pods (Deployments, StatefulSets and so on). Operators: * Cassandra * Ceph * CockroachDB * EdgeFS * Minio * NFS The Annotations related structures have been added to the rook.io/v1alpha2 pkg. Signed-off-by: Alexander Trost --- Documentation/cassandra-cluster-crd.md | 18 ++-- Documentation/ceph-cluster-crd.md | 25 ++++-- Documentation/ceph-filesystem-crd.md | 4 + Documentation/ceph-nfs-crd.md | 3 + Documentation/ceph-object-store-crd.md | 4 + Documentation/cockroachdb-cluster-crd.md | 4 + Documentation/edgefs-cluster-crd.md | 14 ++++ Documentation/edgefs-iscsi-crd.md | 4 + Documentation/edgefs-isgw-crd.md | 6 +- Documentation/edgefs-nfs-crd.md | 4 + Documentation/edgefs-s3-crd.md | 4 + Documentation/edgefs-s3x-crd.md | 4 + Documentation/edgefs-swift-crd.md | 4 + Documentation/minio-object-store-crd.md | 6 +- Documentation/nfs-crd.md | 34 ++++---- .../kubernetes/cassandra/cluster.yaml | 4 +- cluster/examples/kubernetes/ceph/cluster.yaml | 6 ++ .../kubernetes/ceph/filesystem-ec.yaml | 3 + .../examples/kubernetes/ceph/filesystem.yaml | 3 + cluster/examples/kubernetes/ceph/nfs.yaml | 3 + .../examples/kubernetes/ceph/object-ec.yaml | 3 + .../kubernetes/ceph/object-openshift.yaml | 3 + cluster/examples/kubernetes/ceph/object.yaml | 3 + cluster/examples/kubernetes/ceph/pool-ec.yaml | 3 + cluster/examples/kubernetes/ceph/pool.yaml | 3 + .../kubernetes/cockroachdb/cluster.yaml | 3 + .../examples/kubernetes/edgefs/cluster.yaml | 9 +- cluster/examples/kubernetes/edgefs/iscsi.yaml | 9 +- cluster/examples/kubernetes/edgefs/isgw.yaml | 7 ++ cluster/examples/kubernetes/edgefs/nfs.yaml | 7 ++ cluster/examples/kubernetes/edgefs/s3.yaml | 8 ++ cluster/examples/kubernetes/edgefs/s3x.yaml | 7 ++ cluster/examples/kubernetes/edgefs/swift.yaml | 7 ++ .../kubernetes/minio/object-store.yaml | 3 + cluster/examples/kubernetes/nfs/nfs-ceph.yaml | 3 + cluster/examples/kubernetes/nfs/nfs.yaml | 3 + cmd/rook/cassandra/sidecar.go | 3 +- pkg/apis/cassandra.rook.io/v1alpha1/types.go | 4 + .../v1alpha1/zz_generated.deepcopy.go | 7 ++ pkg/apis/ceph.rook.io/v1/annotations.go | 46 ++++++++++ pkg/apis/ceph.rook.io/v1/keys.go | 29 +++++++ pkg/apis/ceph.rook.io/v1/placement.go | 15 +--- pkg/apis/ceph.rook.io/v1/types.go | 12 +++ .../ceph.rook.io/v1/zz_generated.deepcopy.go | 38 +++++++++ .../cockroachdb.rook.io/v1alpha1/types.go | 2 + .../v1alpha1/zz_generated.deepcopy.go | 8 ++ .../edgefs.rook.io/v1alpha1/annotations.go | 36 ++++++++ pkg/apis/edgefs.rook.io/v1alpha1/keys.go | 23 +++++ pkg/apis/edgefs.rook.io/v1alpha1/types.go | 12 +++ pkg/apis/minio.rook.io/v1alpha1/types.go | 3 + .../v1alpha1/zz_generated.deepcopy.go | 7 ++ pkg/apis/nfs.rook.io/v1alpha1/types.go | 5 +- .../v1alpha1/zz_generated.deepcopy.go | 8 ++ pkg/apis/rook.io/v1alpha2/annotations.go | 59 +++++++++++++ pkg/apis/rook.io/v1alpha2/annotations_test.go | 84 +++++++++++++++++++ pkg/apis/rook.io/v1alpha2/keys.go | 21 +++++ pkg/apis/rook.io/v1alpha2/placement.go | 6 +- pkg/apis/rook.io/v1alpha2/types.go | 9 +- .../rook.io/v1alpha2/zz_generated.deepcopy.go | 54 ++++++++++++ pkg/operator/cassandra/controller/cluster.go | 8 +- .../cassandra/controller/cluster_test.go | 13 ++- pkg/operator/cassandra/controller/sync.go | 2 +- pkg/operator/ceph/cluster/cluster.go | 10 ++- pkg/operator/ceph/cluster/mgr/mgr.go | 2 + pkg/operator/ceph/cluster/mgr/mgr_test.go | 1 + pkg/operator/ceph/cluster/mgr/spec.go | 11 ++- pkg/operator/ceph/cluster/mgr/spec_test.go | 3 + pkg/operator/ceph/cluster/migration_test.go | 16 ++-- pkg/operator/ceph/cluster/mon/mon.go | 5 +- pkg/operator/ceph/cluster/mon/node_test.go | 4 +- pkg/operator/ceph/cluster/mon/spec.go | 9 +- pkg/operator/ceph/cluster/osd/osd.go | 4 +- pkg/operator/ceph/cluster/osd/osd_test.go | 10 +-- pkg/operator/ceph/cluster/osd/spec.go | 25 +++--- pkg/operator/ceph/cluster/osd/spec_test.go | 8 +- pkg/operator/ceph/cluster/osd/status_test.go | 2 +- pkg/operator/ceph/cluster/rbd/mirror.go | 3 + pkg/operator/ceph/cluster/rbd/mirror_test.go | 1 + pkg/operator/ceph/cluster/rbd/spec.go | 7 +- pkg/operator/ceph/cluster/rbd/spec_test.go | 1 + pkg/operator/ceph/file/mds/spec.go | 7 +- pkg/operator/ceph/nfs/spec.go | 7 +- pkg/operator/ceph/object/spec.go | 12 +-- pkg/operator/cockroachdb/controller.go | 20 +++-- pkg/operator/edgefs/cluster/cluster.go | 9 +- pkg/operator/edgefs/cluster/mgr/mgr.go | 31 ++++--- pkg/operator/edgefs/cluster/mgr/mgr_test.go | 16 ++-- .../edgefs/cluster/prepare/prepare.go | 3 + pkg/operator/edgefs/cluster/target/pod.go | 2 + .../edgefs/cluster/target/pod_test.go | 2 +- pkg/operator/edgefs/cluster/target/target.go | 3 + pkg/operator/edgefs/iscsi/controller.go | 1 + pkg/operator/edgefs/iscsi/iscsi.go | 3 + pkg/operator/edgefs/isgw/controller.go | 1 + pkg/operator/edgefs/nfs/controller.go | 1 + pkg/operator/edgefs/nfs/nfs.go | 2 + pkg/operator/edgefs/s3/controller.go | 1 + pkg/operator/edgefs/s3/s3.go | 2 + pkg/operator/edgefs/s3x/controller.go | 1 + pkg/operator/edgefs/s3x/s3x.go | 2 + pkg/operator/minio/controller.go | 31 ++++++- pkg/operator/minio/controller_test.go | 4 + pkg/operator/nfs/controller.go | 2 + 103 files changed, 881 insertions(+), 156 deletions(-) create mode 100644 pkg/apis/ceph.rook.io/v1/annotations.go create mode 100644 pkg/apis/ceph.rook.io/v1/keys.go create mode 100644 pkg/apis/edgefs.rook.io/v1alpha1/annotations.go create mode 100644 pkg/apis/edgefs.rook.io/v1alpha1/keys.go create mode 100644 pkg/apis/rook.io/v1alpha2/annotations.go create mode 100644 pkg/apis/rook.io/v1alpha2/annotations_test.go create mode 100644 pkg/apis/rook.io/v1alpha2/keys.go diff --git a/Documentation/cassandra-cluster-crd.md b/Documentation/cassandra-cluster-crd.md index 658c635d2..40564e132 100644 --- a/Documentation/cassandra-cluster-crd.md +++ b/Documentation/cassandra-cluster-crd.md @@ -22,6 +22,9 @@ spec: version: 3.11.1 repository: my-private-repo.io/cassandra mode: cassandra + # A key/value list of annotations + annotations: + # key: value datacenter: name: us-east-1 racks: @@ -43,6 +46,9 @@ spec: limits: cpu: 8 memory: 32Gi + # A key/value list of annotations + annotations: + # key: value placement: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -50,35 +56,37 @@ spec: - matchExpressions: - key: failure-domain.beta.kubernetes.io/region operator: In - values: + values: - us-east-1 - key: failure-domain.beta.kubernetes.io/zone operator: In - values: + values: - us-east-1a ``` ## Settings Explanation -Cluster Settings: +### Cluster Settings * `version`: The version of Cassandra to use. It is used as the image tag to pull. * `repository`: Optional field. Specifies a custom image repo. If left unset, the official docker hub repo is used. * `mode`: Optional field. Specifies if this is a Cassandra or Scylla cluster. If left unset, it defaults to cassandra. Values: {scylla, cassandra} +* `annotations`: Key value pair list of annotations to add. In the Cassandra model, each cluster contains datacenters and each datacenter contains racks. At the moment, the operator only supports single datacenter setups. -Datacenter Settings: +### Datacenter Settings * `name`: Name of the datacenter. Usually, a datacenter corresponds to a region. * `racks`: List of racks for the specific datacenter. -Rack Settings: +### Rack Settings * `name`: Name of the rack. Usually, a rack corresponds to an availability zone. * `members`: Number of Cassandra members for the specific rack. (In Cassandra documentation, they are called nodes. We don't call them nodes to avoid confusion as a Cassandra Node corresponds to a Kubernetes Pod, not a Kubernetes Node). * `storage`: Defines the volumes to use for each Cassandra member. Currently, only 1 volume is supported. * `resources`: Defines the CPU and RAM resources for the Cassandra Pods. +* `annotations`: Key value pair list of annotations to add. * `placement`: Defines the placement of Cassandra Pods. Has the following subfields: * [`nodeAffinity`](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) * [`podAffinity`](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) diff --git a/Documentation/ceph-cluster-crd.md b/Documentation/ceph-cluster-crd.md index d6f4f3845..fbb47850c 100755 --- a/Documentation/ceph-cluster-crd.md +++ b/Documentation/ceph-cluster-crd.md @@ -68,6 +68,7 @@ For more details on the mons and when to choose a number other than `3`, see the - `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. +- `annotations`: [annotations configuration settings](#annotations-configuration-settings) - `placement`: [placement configuration settings](#placement-configuration-settings) - `resources`: [resources configuration settings](#cluster-wide-resources-configuration-settings) - `storage`: Storage selection and configuration that will be used across the cluster. Note that these settings can be overridden for specific nodes. @@ -159,8 +160,21 @@ The following storage selection settings are specific to Ceph and do not apply t - Mimic 13.2.3 or newer - Nautilus +### Annotations Configuration Settings +Annotations can be specified so that the Rook components will have those annotations added to them. + +You can set annotations for Rook components through the a list of key value pairs: + +- `all`: Set annotations for all components. +- `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`, `osd` 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`, `osd`, `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). A Placement configuration is specified (according to the kubernetes PodSpec) as: @@ -176,14 +190,15 @@ See the [mon design doc](https://github.com/rook/rook/blob/master/design/mon-hea The Rook Ceph operator creates a Job called `rook-ceph-detect-version` to detect the full Ceph version used by the given `cephVersion.image`. The placement from the `mon` section is used for the Job. ### Cluster-wide Resources Configuration Settings -Resources should be specified so that the rook components are handled after [Kubernetes Pod Quality of Service classes](https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/). -This allows to keep rook components running when for example a node runs out of memory and the rook components are not killed depending on their Quality of Service class. +Resources should be specified so that the Rook components are handled after [Kubernetes Pod Quality of Service classes](https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/). +This allows to keep Rook components running when for example a node runs out of memory and the Rook components are not killed depending on their Quality of Service class. -You can set resource requests/limits for rook components through the [Resource Requirements/Limits](#resource-requirementslimits) structure in the following keys: +You can set resource requests/limits for Rook components through the [Resource Requirements/Limits](#resource-requirementslimits) structure in the following keys: - `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. ### Resource Requirements/Limits For more information on resource requests/limits see the official Kubernetes documentation: [Kubernetes - Managing Compute Resources for Containers](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) @@ -352,7 +367,7 @@ spec: ``` ### Resource Requests/Limits -To control how many resources the rook components can request/use, you can set requests and limits in Kubernetes for them. +To control how many resources the Rook components can request/use, you can set requests and limits in Kubernetes for them. You can override these requests/limits for OSDs per node when using `useAllNodes: false` in the `node` item in the `nodes` list. **WARNING** Before setting resource requests/limits, please take a look at the Ceph documentation for recommendations for each component: [Ceph - Hardware Recommendations](http://docs.ceph.com/docs/master/start/hardware-recommendations/). diff --git a/Documentation/ceph-filesystem-crd.md b/Documentation/ceph-filesystem-crd.md index 3e17806b9..82b42b156 100644 --- a/Documentation/ceph-filesystem-crd.md +++ b/Documentation/ceph-filesystem-crd.md @@ -41,6 +41,9 @@ spec: metadataServer: activeCount: 1 activeStandby: true + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -116,5 +119,6 @@ The metadata server settings correspond to the MDS daemon settings. - `activeCount`: The number of active MDS instances. As load increases, CephFS will automatically partition the file system across the MDS instances. Rook will create double the number of MDS instances as requested by the active count. The extra instances will be in standby mode for failover. - `activeStandby`: If true, the extra MDS instances will be in active standby mode and will keep a warm cache of the file system metadata for faster failover. The instances will be assigned by CephFS in failover pairs. If false, the extra MDS instances will all be on passive standby mode and will not maintain a warm cache of the metadata. +- `annotations`: Key value pair list of annotations to add. - `placement`: The mds pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](https://github.com/rook/rook/blob/{{ branchName }}/cluster/examples/kubernetes/ceph/cluster.yaml). - `resources`: Set resource requests/limits for the Filesystem MDS Pod(s), see [Resource Requirements/Limits](ceph-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/ceph-nfs-crd.md b/Documentation/ceph-nfs-crd.md index a1eeaba67..33e7c4d69 100644 --- a/Documentation/ceph-nfs-crd.md +++ b/Documentation/ceph-nfs-crd.md @@ -32,6 +32,9 @@ spec: server: # the number of active NFS servers active: 2 + # A key/value list of annotations + annotations: + # key: value # where to run the NFS server placement: # nodeAffinity: diff --git a/Documentation/ceph-object-store-crd.md b/Documentation/ceph-object-store-crd.md index 4f26ae6b0..2e5c9f6e3 100644 --- a/Documentation/ceph-object-store-crd.md +++ b/Documentation/ceph-object-store-crd.md @@ -37,6 +37,9 @@ spec: securePort: instances: 1 allNodes: false + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -84,6 +87,7 @@ The gateway settings correspond to the RGW daemon settings. - `securePort`: The secure port on which RGW pods will be listening. An SSL certificate must be specified. - `instances`: The number of pods that will be started to load balance this object store. Ignored if `allNodes` is true. - `allNodes`: Whether RGW pods should be started on all nodes. If true, a daemonset is created. If false, `instances` must be set. +- `annotations`: Key value pair list of annotations to add. - `placement`: The Kubernetes placement settings to determine where the RGW pods should be started in the cluster. - `resources`: Set resource requests/limits for the Gateway Pod(s), see [Resource Requirements/Limits](ceph-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/cockroachdb-cluster-crd.md b/Documentation/cockroachdb-cluster-crd.md index 852c6e0a1..fe2561979 100644 --- a/Documentation/cockroachdb-cluster-crd.md +++ b/Documentation/cockroachdb-cluster-crd.md @@ -38,6 +38,9 @@ spec: secure: false cachePercent: 25 maxSQLMemoryPercent: 25 + # A key/value list of annotations + annotations: + # key: value ``` ## Cluster Settings @@ -49,6 +52,7 @@ The settings below are specific to CockroachDB database clusters: * `secure`: `true` to create a secure cluster installation using certificates and encryption. `false` to create an insecure installation (strongly discouraged for production usage). Currently, only insecure is supported. * `cachePercent`: The total size used for caches, expressed as a percentage of total physical memory. * `maxSQLMemoryPercent`: The maximum memory capacity available to store temporary data for SQL clients, expressed as a percentage of total physical memory. +* `annotations`: Key value pair list of annotations to add. ### Storage Scope diff --git a/Documentation/edgefs-cluster-crd.md b/Documentation/edgefs-cluster-crd.md index 0e673e8d3..932f75448 100644 --- a/Documentation/edgefs-cluster-crd.md +++ b/Documentation/edgefs-cluster-crd.md @@ -22,6 +22,13 @@ spec: dataDirHostPath: /data storage: useAllNodes: true + # A key/value list of annotations + annotations: + # all: + # key: value + # prepare: + # mgr: + # target: ``` or if you have raw block devices provisioned, it can dynamically detect, format and utilize all raw devices on all nodes with simple CRD as below: @@ -39,6 +46,13 @@ spec: storage: useAllNodes: true useAllDevices: true + # A key/value list of annotations + annotations: + # all: + # key: value + # prepare: + # mgr: + # target: ``` In addition to the CRD, you will also need to create a namespace, role, and role binding as seen in the [common cluster resources](#common-cluster-resources) below. diff --git a/Documentation/edgefs-iscsi-crd.md b/Documentation/edgefs-iscsi-crd.md index 82f9e40d3..a46ac4263 100644 --- a/Documentation/edgefs-iscsi-crd.md +++ b/Documentation/edgefs-iscsi-crd.md @@ -41,6 +41,9 @@ spec: # requests: # cpu: "500m" # memory: "1024Mi" + # A key/value list of annotations + annotations: + # key: value ``` ### Metadata @@ -56,6 +59,7 @@ spec: - `MaxBurstLength`: Value in range 512..16777215. Default is 1048576. - `MaxQueueCmd`: Value in range 1..128. Default is 64. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default iSCSI pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. +- `annotations`: Key value pair list of annotations to add. - `placement`: The iSCSI pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: iSCSI pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an iSCSI pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, iSCSI pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the iSCSI pods, see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/edgefs-isgw-crd.md b/Documentation/edgefs-isgw-crd.md index e6e687200..10ebf7add 100644 --- a/Documentation/edgefs-isgw-crd.md +++ b/Documentation/edgefs-isgw-crd.md @@ -69,13 +69,16 @@ spec: # podAffinity: # podAntiAffinity: #resourceProfile: embedded - #resources: + resources: # limits: # cpu: "2" # memory: "4Gi" # requests: # cpu: "2" # memory: "4Gi" + # A key/value list of annotations + annotations: + # key: value ``` ### Metadata @@ -90,6 +93,7 @@ spec: - `localAddr`: Defines local cluster pod service address and port. Used by ISGW link endpoint. Kubernetes ExternalIP will be automatically constructed if address is provided. Default is 0.0.0.0:14000. - `useEncryptedTunnel`: If true, enables usage of encrypted SSH tunnel. By default, transferred metadata and data chunks are just compressed but unencrypted. Enable encryption if ISGW links crossing boundaries of single data center or multiple clouds. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default ISGW pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. +- `annotations`: Key value pair list of annotations to add. - `placement`: The ISGW pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: ISGW pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an ISGW pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, ISGW pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the ISGW pods, see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/edgefs-nfs-crd.md b/Documentation/edgefs-nfs-crd.md index 7525a8606..f9949114e 100644 --- a/Documentation/edgefs-nfs-crd.md +++ b/Documentation/edgefs-nfs-crd.md @@ -21,6 +21,9 @@ spec: instances: 3 #relaxedDirUpdates: true #chunkCacheSize: 1Gi + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -52,6 +55,7 @@ spec: - `instances`: The number of active NFS service instances. EdgeFS NFS service is Multi-Head capable, such so that multiple PODs can mount same tenant's buckets via different endpoints. [EdgeFS CSI provisioner](edgefs-csi.md) orchestrates distribution and load balancing across NFS service instances in round-robin or random policy ways. - `relaxedDirUpdates`: If set to `true` then it will significantly improve performance of directory operations by defering updates, guaranteeing eventual directory consistency. This option is recommended when a bucket exported via single NFS instance and it is not a destination for ISGW Link synchronization. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default NFS pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. +- `annotations`: Key value pair list of annotations to add. - `placement`: The NFS PODs can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: NFS pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an NFS pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, NFS pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the NFS Pod(s), see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/edgefs-s3-crd.md b/Documentation/edgefs-s3-crd.md index 1616c24c1..a90a0bcdf 100644 --- a/Documentation/edgefs-s3-crd.md +++ b/Documentation/edgefs-s3-crd.md @@ -21,6 +21,9 @@ spec: instances: 3 #s3type: s3s #chunkCacheSize: 1Gi + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -55,6 +58,7 @@ spec: - `securePort`: The secure port on which S3 pods will be listening. If not defined then default SSL certificates will be used. Default port is 8443 for `s3` and 8444 for `s3s`. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default S3 pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. - `instances`: The number of active S3 service instances. For load balancing we recommend to use nginx and the like solutions. +- `annotations`: Key value pair list of annotations to add. - `placement`: The S3 pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: S3 pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an S3 pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, S3 pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the S3 pods, see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/edgefs-s3x-crd.md b/Documentation/edgefs-s3x-crd.md index d0013b868..d2147ed25 100644 --- a/Documentation/edgefs-s3x-crd.md +++ b/Documentation/edgefs-s3x-crd.md @@ -24,6 +24,9 @@ metadata: spec: instances: 3 #chunkCacheSize: 1Gi + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -57,6 +60,7 @@ spec: - `securePort`: The secure port on which Edge-X S3 pods will be listening. If not defined then default SSL certificates will be used. Default port is 3001. - `instances`: The number of active Edge-X S3 service instances. For load balancing we recommend to use nginx and the like solutions. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default S3X pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. +- `annotations`: Key value pair list of annotations to add. - `placement`: The Edge-X S3 PODs can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: S3X pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an S3X pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, S3X pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the Edge-X S3 Pod(s), see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/edgefs-swift-crd.md b/Documentation/edgefs-swift-crd.md index 5906c7bc6..e0b5251ac 100644 --- a/Documentation/edgefs-swift-crd.md +++ b/Documentation/edgefs-swift-crd.md @@ -20,6 +20,9 @@ metadata: spec: instances: 3 #chunkCacheSize: 1Gi + # A key/value list of annotations + annotations: + # key: value placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -53,6 +56,7 @@ spec: - `securePort`: The secure port on which SWIFT pods will be listening. If not defined then default SSL certificates will be used. Default port is 443. - `instances`: The number of active SWIFT service instances. For load balancing we recommend to use nginx and the like solutions. - `chunkCacheSize`: Limit amount of memory allocated for dynamic chunk cache. By default SWIFT pod uses up to 75% of available memory as chunk caching area. This option can influence this allocation strategy. +- `annotations`: Key value pair list of annotations to add. - `placement`: The SWIFT pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml). - `resourceProfile`: SWIFT pod resource utilization profile (Memory and CPU). Can be `embedded` or `performance` (default). In case of `performance` an SWIFT pod trying to increase amount of internal I/O resources that results in higher performance at the cost of additional memory allocation and more CPU load. In `embedded` profile case, SWIFT pod gives preference to preserving memory over I/O and limiting chunk cache (see `chunkCacheSize` option). The `performance` profile is the default unless cluster wide `embedded` option is defined. - `resources`: Set resource requests/limits for the SWIFT pods, see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits). diff --git a/Documentation/minio-object-store-crd.md b/Documentation/minio-object-store-crd.md index 7cc15ec08..6587827a4 100644 --- a/Documentation/minio-object-store-crd.md +++ b/Documentation/minio-object-store-crd.md @@ -49,6 +49,9 @@ spec: name: minio-my-store-access-keys namespace: rook-minio clusterDomain: + # A key/value list of annotations + annotations: + # key: value ``` ## Cluster Settings @@ -57,9 +60,10 @@ spec: The settings below are specific to Minio object stores: +* `scope`: See [Storage Scope](#storage-scope). * `credentials`: This accepts the `name` and `namespace` strings of an existing Secret to specify the access credentials for the object store. -* `storageAmount`: The size of the volume that will be mounted at the data directory. * `clusterDomain`: The local cluster domain for this cluster. This should be set if an alternative cluster domain is in use. If not set, then the default of cluster.local will be assumed. This field is needed to workaround https://github.com/minio/minio/issues/6775, and is expected to be removed in the future. +* `annotations`: Key value pair list of annotations to add. ### Storage Scope diff --git a/Documentation/nfs-crd.md b/Documentation/nfs-crd.md index 233f73a65..5bd8ad488 100644 --- a/Documentation/nfs-crd.md +++ b/Documentation/nfs-crd.md @@ -32,27 +32,31 @@ spec: squash: none persistentVolumeClaim: claimName: googlePD-claim + # A key/value list of annotations + annotations: + # key: value ``` ## Settings The table below explains in detail each configuration option that is available in the NFS CRD. -| Parameter | Description | Default | -|-------------------------------------------|------------------------------------------|-------------------------------| -| `replicas` | The number of NFS daemon to start | `1` | -| `exports` | Parameters for creating an export | `` | -| `exports.name` | Name of the volume being shared | `` | -| `exports.server` | NFS server configuration | `` | -| `exports.server.accessMode` | Volume access modes (Reading and Writing) for the share (Valid options are `ReadOnly`, `ReadWrite` and `none`) | `ReadWrite` | -| `exports.server.squash` | This prevents root users connected remotely from having root privileges (valid options are `none`, `rootId`, `root` and `all`) | `none` | -| `exports.server.allowedClients` | Access configuration for clients that can consume the NFS volume | `` | -| `exports.server.allowedClients.name` | Name of the host/hosts | `` | -| `exports.server.allowedClients.clients` | The host or network to which the export is being shared. Valid entries for this field are host names, IP addresses, netgroups, and CIDR network addresses. | `` | -| `exports.server.allowedClients.accessMode` | Reading and Writing permissions for the client* (valid options are same as `exports.server.accessMode`) | `ReadWrite` | -| `exports.server.allowedClients.squash` | Squash option for the client* (valid options are same as `exports.server.squash`) | `none` | -| `exports.persistentVolumeClaim` | The PVC that will serve as the backing volume to be exported by the NFS server. Any PVC is allowed, such as host paths, CephFS, Ceph RBD, Google PD, Amazon EBS, etc.. | `` | -| `exports.persistentVolumeClaim.claimName` | Name of the PVC | `` | +| Parameter | Description | Default | +| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `replicas` | The number of NFS daemon to start | `1` | +| `annotations` | Key value pair list of annotations to add. | `[]` | +| `exports` | Parameters for creating an export | `` | +| `exports.name` | Name of the volume being shared | `` | +| `exports.server` | NFS server configuration | `` | +| `exports.server.accessMode` | Volume access modes (Reading and Writing) for the share (Valid options are `ReadOnly`, `ReadWrite` and `none`) | `ReadWrite` | +| `exports.server.squash` | This prevents root users connected remotely from having root privileges (valid options are `none`, `rootId`, `root` and `all`) | `none` | +| `exports.server.allowedClients` | Access configuration for clients that can consume the NFS volume | `` | +| `exports.server.allowedClients.name` | Name of the host/hosts | `` | +| `exports.server.allowedClients.clients` | The host or network to which the export is being shared. Valid entries for this field are host names, IP addresses, netgroups, and CIDR network addresses. | `` | +| `exports.server.allowedClients.accessMode` | Reading and Writing permissions for the client* (valid options are same as `exports.server.accessMode`) | `ReadWrite` | +| `exports.server.allowedClients.squash` | Squash option for the client* (valid options are same as `exports.server.squash`) | `none` | +| `exports.persistentVolumeClaim` | The PVC that will serve as the backing volume to be exported by the NFS server. Any PVC is allowed, such as host paths, CephFS, Ceph RBD, Google PD, Amazon EBS, etc.. | `` | +| `exports.persistentVolumeClaim.claimName` | Name of the PVC | `` | *note: if `exports.server.allowedClients.accessMode` and `exports.server.allowedClients.squash` options are specified, `exports.server.accessMode` and `exports.server.squash` are overridden respectively. diff --git a/cluster/examples/kubernetes/cassandra/cluster.yaml b/cluster/examples/kubernetes/cassandra/cluster.yaml index 629642344..b6a918ff8 100644 --- a/cluster/examples/kubernetes/cassandra/cluster.yaml +++ b/cluster/examples/kubernetes/cassandra/cluster.yaml @@ -72,6 +72,9 @@ metadata: spec: version: 3.11.1 mode: cassandra + # A key/value list of annotations + annotations: + # key: value datacenter: name: us-east-1 racks: @@ -92,4 +95,3 @@ spec: limits: cpu: 1 memory: 2Gi - diff --git a/cluster/examples/kubernetes/ceph/cluster.yaml b/cluster/examples/kubernetes/ceph/cluster.yaml index 78c1082b7..4efbb5daa 100644 --- a/cluster/examples/kubernetes/ceph/cluster.yaml +++ b/cluster/examples/kubernetes/ceph/cluster.yaml @@ -71,6 +71,12 @@ spec: # mon: # osd: # mgr: + annotations: +# all: +# mon: +# osd: +# If no mgr annotations are set, prometheus scrape annotations will be set by default. +# mgr: resources: # The requests and limits set here, allow the mgr pod to use half of one CPU core and 1 gigabyte of memory # mgr: diff --git a/cluster/examples/kubernetes/ceph/filesystem-ec.yaml b/cluster/examples/kubernetes/ceph/filesystem-ec.yaml index 8ec103cf4..812bfb8d8 100644 --- a/cluster/examples/kubernetes/ceph/filesystem-ec.yaml +++ b/cluster/examples/kubernetes/ceph/filesystem-ec.yaml @@ -43,6 +43,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value resources: # The requests and limits set here, allow the filesystem MDS Pod(s) to use half of one CPU core and 1 gigabyte of memory # limits: diff --git a/cluster/examples/kubernetes/ceph/filesystem.yaml b/cluster/examples/kubernetes/ceph/filesystem.yaml index 1028ef78a..cb4ecfd0f 100644 --- a/cluster/examples/kubernetes/ceph/filesystem.yaml +++ b/cluster/examples/kubernetes/ceph/filesystem.yaml @@ -41,6 +41,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value resources: # The requests and limits set here, allow the filesystem MDS Pod(s) to use half of one CPU core and 1 gigabyte of memory # limits: diff --git a/cluster/examples/kubernetes/ceph/nfs.yaml b/cluster/examples/kubernetes/ceph/nfs.yaml index ef6cb1031..612f4647c 100644 --- a/cluster/examples/kubernetes/ceph/nfs.yaml +++ b/cluster/examples/kubernetes/ceph/nfs.yaml @@ -30,6 +30,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value # The requests and limits set here allow the ganesha pod(s) to use half of one CPU core and 1 gigabyte of memory resources: # limits: diff --git a/cluster/examples/kubernetes/ceph/object-ec.yaml b/cluster/examples/kubernetes/ceph/object-ec.yaml index 8f66b4fe1..94022033c 100644 --- a/cluster/examples/kubernetes/ceph/object-ec.yaml +++ b/cluster/examples/kubernetes/ceph/object-ec.yaml @@ -50,6 +50,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value resources: # The requests and limits set here, allow the object store gateway Pod(s) to use half of one CPU core and 1 gigabyte of memory # limits: diff --git a/cluster/examples/kubernetes/ceph/object-openshift.yaml b/cluster/examples/kubernetes/ceph/object-openshift.yaml index 7daab469f..c607d25e3 100644 --- a/cluster/examples/kubernetes/ceph/object-openshift.yaml +++ b/cluster/examples/kubernetes/ceph/object-openshift.yaml @@ -49,6 +49,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value resources: # The requests and limits set here, allow the object store gateway Pod(s) to use half of one CPU core and 1 gigabyte of memory # limits: diff --git a/cluster/examples/kubernetes/ceph/object.yaml b/cluster/examples/kubernetes/ceph/object.yaml index 27a81074b..309e73eeb 100644 --- a/cluster/examples/kubernetes/ceph/object.yaml +++ b/cluster/examples/kubernetes/ceph/object.yaml @@ -49,6 +49,9 @@ spec: # operator: Exists # podAffinity: # podAntiAffinity: + # A key/value list of annotations + annotations: + # key: value resources: # The requests and limits set here, allow the object store gateway Pod(s) to use half of one CPU core and 1 gigabyte of memory # limits: diff --git a/cluster/examples/kubernetes/ceph/pool-ec.yaml b/cluster/examples/kubernetes/ceph/pool-ec.yaml index 421168731..e3e550cea 100644 --- a/cluster/examples/kubernetes/ceph/pool-ec.yaml +++ b/cluster/examples/kubernetes/ceph/pool-ec.yaml @@ -17,3 +17,6 @@ spec: erasureCoded: dataChunks: 2 codingChunks: 1 + # A key/value list of annotations + annotations: + # key: value diff --git a/cluster/examples/kubernetes/ceph/pool.yaml b/cluster/examples/kubernetes/ceph/pool.yaml index d1a463830..b61130f0d 100644 --- a/cluster/examples/kubernetes/ceph/pool.yaml +++ b/cluster/examples/kubernetes/ceph/pool.yaml @@ -15,3 +15,6 @@ spec: # For a pool based on raw copies, specify the number of copies. A size of 1 indicates no redundancy. replicated: size: 3 + # A key/value list of annotations + annotations: + # key: value diff --git a/cluster/examples/kubernetes/cockroachdb/cluster.yaml b/cluster/examples/kubernetes/cockroachdb/cluster.yaml index 0f08b3e6e..9e2327b0c 100644 --- a/cluster/examples/kubernetes/cockroachdb/cluster.yaml +++ b/cluster/examples/kubernetes/cockroachdb/cluster.yaml @@ -34,3 +34,6 @@ spec: secure: false cachePercent: 25 maxSQLMemoryPercent: 25 + # A key/value list of annotations + annotations: + # key: value diff --git a/cluster/examples/kubernetes/edgefs/cluster.yaml b/cluster/examples/kubernetes/edgefs/cluster.yaml index fa7e86e01..c01e63242 100644 --- a/cluster/examples/kubernetes/edgefs/cluster.yaml +++ b/cluster/examples/kubernetes/edgefs/cluster.yaml @@ -54,7 +54,7 @@ subjects: - kind: ServiceAccount name: rook-edgefs-cluster namespace: rook-edgefs ---- +--- apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: @@ -176,3 +176,10 @@ spec: # requests: # cpu: "2" # memory: "4096Mi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/iscsi.yaml b/cluster/examples/kubernetes/edgefs/iscsi.yaml index 49ce6dcb0..ba91f757c 100644 --- a/cluster/examples/kubernetes/edgefs/iscsi.yaml +++ b/cluster/examples/kubernetes/edgefs/iscsi.yaml @@ -4,7 +4,7 @@ metadata: name: iscsi01 namespace: rook-edgefs spec: - #targetName: + #targetName: #placement: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -26,3 +26,10 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/isgw.yaml b/cluster/examples/kubernetes/edgefs/isgw.yaml index 48f31d39a..f5a6820ef 100644 --- a/cluster/examples/kubernetes/edgefs/isgw.yaml +++ b/cluster/examples/kubernetes/edgefs/isgw.yaml @@ -35,3 +35,10 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/nfs.yaml b/cluster/examples/kubernetes/edgefs/nfs.yaml index 79605f8b6..0422315a9 100644 --- a/cluster/examples/kubernetes/edgefs/nfs.yaml +++ b/cluster/examples/kubernetes/edgefs/nfs.yaml @@ -26,3 +26,10 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/s3.yaml b/cluster/examples/kubernetes/edgefs/s3.yaml index 797527cb7..0c7692784 100644 --- a/cluster/examples/kubernetes/edgefs/s3.yaml +++ b/cluster/examples/kubernetes/edgefs/s3.yaml @@ -30,3 +30,11 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/s3x.yaml b/cluster/examples/kubernetes/edgefs/s3x.yaml index 78411a15e..1ecc0914c 100644 --- a/cluster/examples/kubernetes/edgefs/s3x.yaml +++ b/cluster/examples/kubernetes/edgefs/s3x.yaml @@ -27,3 +27,10 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/edgefs/swift.yaml b/cluster/examples/kubernetes/edgefs/swift.yaml index 1c6670ec5..7c44ee31a 100644 --- a/cluster/examples/kubernetes/edgefs/swift.yaml +++ b/cluster/examples/kubernetes/edgefs/swift.yaml @@ -29,3 +29,10 @@ spec: # requests: # cpu: "2" # memory: "4Gi" + # A key value list of annotations + annotations: + # all: + # key: value + # mgr: + # prepare: + # target: diff --git a/cluster/examples/kubernetes/minio/object-store.yaml b/cluster/examples/kubernetes/minio/object-store.yaml index f288f85ce..af244d8c3 100644 --- a/cluster/examples/kubernetes/minio/object-store.yaml +++ b/cluster/examples/kubernetes/minio/object-store.yaml @@ -45,6 +45,9 @@ spec: # resources: # requests: # storage: "8Gi" + # A key value list of annotations + annotations: + # key: value placement: tolerations: nodeAffinity: diff --git a/cluster/examples/kubernetes/nfs/nfs-ceph.yaml b/cluster/examples/kubernetes/nfs/nfs-ceph.yaml index e0c43ad11..9c621b896 100644 --- a/cluster/examples/kubernetes/nfs/nfs-ceph.yaml +++ b/cluster/examples/kubernetes/nfs/nfs-ceph.yaml @@ -36,3 +36,6 @@ spec: # Create a ceph PVC after creating the rook ceph cluster using ceph-pvc.yaml persistentVolumeClaim: claimName: nfs-ceph-claim + # A key value list of annotations + annotations: + # key: value diff --git a/cluster/examples/kubernetes/nfs/nfs.yaml b/cluster/examples/kubernetes/nfs/nfs.yaml index da02adb50..29d42de47 100644 --- a/cluster/examples/kubernetes/nfs/nfs.yaml +++ b/cluster/examples/kubernetes/nfs/nfs.yaml @@ -31,3 +31,6 @@ spec: # A Persistent Volume Claim must be created before creating NFS CRD instance. persistentVolumeClaim: claimName: nfs-default-claim + # A key/value list of annotations + annotations: + # key: value diff --git a/cmd/rook/cassandra/sidecar.go b/cmd/rook/cassandra/sidecar.go index bb43afb53..0aa87baae 100644 --- a/cmd/rook/cassandra/sidecar.go +++ b/cmd/rook/cassandra/sidecar.go @@ -18,6 +18,8 @@ package cassandra import ( "fmt" + "os" + "github.com/rook/rook/cmd/rook/rook" "github.com/rook/rook/pkg/operator/cassandra/sidecar" "github.com/rook/rook/pkg/operator/k8sutil" @@ -27,7 +29,6 @@ import ( "k8s.io/apiserver/pkg/server" kubeinformers "k8s.io/client-go/informers" "k8s.io/client-go/informers/internalinterfaces" - "os" ) var sidecarCmd = &cobra.Command{ diff --git a/pkg/apis/cassandra.rook.io/v1alpha1/types.go b/pkg/apis/cassandra.rook.io/v1alpha1/types.go index d87eddaea..1a40d2183 100644 --- a/pkg/apis/cassandra.rook.io/v1alpha1/types.go +++ b/pkg/apis/cassandra.rook.io/v1alpha1/types.go @@ -58,6 +58,8 @@ type ClusterList struct { // ClusterSpec is the desired state for a Cassandra Cluster. type ClusterSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations // Version of Cassandra to use. Version string `json:"version"` // Repository to pull the image from. @@ -95,6 +97,8 @@ type RackSpec struct { ConfigMapName *string `json:"configMapName,omitempty"` // Storage describes the underlying storage that Cassandra will consume. Storage rook.StorageScopeSpec `json:"storage"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations // Placement describes restrictions for the nodes Cassandra is scheduled on. Placement *rook.Placement `json:"placement,omitempty"` // Resources the Cassandra Pods will use. diff --git a/pkg/apis/cassandra.rook.io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/cassandra.rook.io/v1alpha1/zz_generated.deepcopy.go index 4bdfae40e..3e40b89e0 100644 --- a/pkg/apis/cassandra.rook.io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/cassandra.rook.io/v1alpha1/zz_generated.deepcopy.go @@ -89,6 +89,13 @@ func (in *ClusterList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Repository != nil { in, out := &in.Repository, &out.Repository *out = new(string) diff --git a/pkg/apis/ceph.rook.io/v1/annotations.go b/pkg/apis/ceph.rook.io/v1/annotations.go new file mode 100644 index 000000000..bae56c751 --- /dev/null +++ b/pkg/apis/ceph.rook.io/v1/annotations.go @@ -0,0 +1,46 @@ +/* +Copyright 2019 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 v1 + +import ( + rook "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" +) + +// GetMgrAnnotations returns the Annotations for the MGR service +func GetMgrAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyMgr]) +} + +// GetMonAnnotations returns the Annotations for the MON service +func GetMonAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyMon]) +} + +// GetOSDAnnotations returns the annotations for the OSD service +func GetOSDAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyOSD]) +} + +// GetRGWAnnotations returns the Annotations for the RBD mirrors +func GetRGWAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyRGWMirror]) +} + +// GetRBDMirrorAnnotations returns the Annotations for the RBD mirrors +func GetRBDMirrorAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyRBDMirror]) +} diff --git a/pkg/apis/ceph.rook.io/v1/keys.go b/pkg/apis/ceph.rook.io/v1/keys.go new file mode 100644 index 000000000..b4825d461 --- /dev/null +++ b/pkg/apis/ceph.rook.io/v1/keys.go @@ -0,0 +1,29 @@ +/* +Copyright 2018 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 v1 + +import ( + rook "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" +) + +const ( + KeyMon rook.KeyType = "mon" + KeyMgr rook.KeyType = "mgr" + KeyOSD rook.KeyType = "osd" + KeyRBDMirror rook.KeyType = "rbdmirror" + KeyRGWMirror rook.KeyType = "rgw" +) diff --git a/pkg/apis/ceph.rook.io/v1/placement.go b/pkg/apis/ceph.rook.io/v1/placement.go index 4069a9d8d..38ea1d270 100644 --- a/pkg/apis/ceph.rook.io/v1/placement.go +++ b/pkg/apis/ceph.rook.io/v1/placement.go @@ -19,29 +19,22 @@ import ( rook "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" ) -const ( - PlacementKeyMgr = "mgr" - PlacementKeyMon = "mon" - PlacementKeyOSD = "osd" - PlacementKeyRBDMirror = "rbdmirror" -) - // GetMgrPlacement returns the placement for the MGR service func GetMgrPlacement(p rook.PlacementSpec) rook.Placement { - return p.All().Merge(p[PlacementKeyMgr]) + return p.All().Merge(p[KeyMgr]) } // GetMonPlacement returns the placement for the MON service func GetMonPlacement(p rook.PlacementSpec) rook.Placement { - return p.All().Merge(p[PlacementKeyMon]) + return p.All().Merge(p[KeyMon]) } // GetOSDPlacement returns the placement for the OSD service func GetOSDPlacement(p rook.PlacementSpec) rook.Placement { - return p.All().Merge(p[PlacementKeyOSD]) + return p.All().Merge(p[KeyOSD]) } // GetRBDMirrorPlacement returns the placement for the RBD mirrors func GetRBDMirrorPlacement(p rook.PlacementSpec) rook.Placement { - return p.All().Merge(p[PlacementKeyRBDMirror]) + return p.All().Merge(p[KeyRBDMirror]) } diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 87ba8d4dd..fa321ab69 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -54,6 +54,9 @@ type ClusterSpec struct { // A spec for available storage in the cluster and how it should be used Storage rook.StorageScopeSpec `json:"storage,omitempty"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.AnnotationsSpec `json:"annotations,omitempty"` + // The placement-related configuration to pass to kubernetes (affinity, node selector, tolerations). Placement rook.PlacementSpec `json:"placement,omitempty"` @@ -227,6 +230,9 @@ type MetadataServerSpec struct { // The affinity to place the mds pods (default is to place on all available node) with a daemonset Placement rook.Placement `json:"placement"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` + // The resource requirements for the rgw pods Resources v1.ResourceRequirements `json:"resources"` } @@ -306,6 +312,9 @@ type GatewaySpec struct { // The affinity to place the rgw pods (default is to place on any available node) Placement rook.Placement `json:"placement"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` + // The resource requirements for the rgw pods Resources v1.ResourceRequirements `json:"resources"` } @@ -350,6 +359,9 @@ type GaneshaServerSpec struct { // The affinity to place the ganesha pods Placement rook.Placement `json:"placement"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` + // Resources set resource requests and limits Resources v1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index 35b364995..36dbc02bd 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -446,6 +446,23 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = *in out.CephVersion = in.CephVersion in.Storage.DeepCopyInto(&out.Storage) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.AnnotationsSpec, len(*in)) + for key, val := range *in { + var outVal map[string]string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + } if in.Placement != nil { in, out := &in.Placement, &out.Placement *out = make(v1alpha2.PlacementSpec, len(*in)) @@ -578,6 +595,13 @@ func (in *GaneshaRADOSSpec) DeepCopy() *GaneshaRADOSSpec { func (in *GaneshaServerSpec) DeepCopyInto(out *GaneshaServerSpec) { *out = *in in.Placement.DeepCopyInto(&out.Placement) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Resources.DeepCopyInto(&out.Resources) return } @@ -596,6 +620,13 @@ func (in *GaneshaServerSpec) DeepCopy() *GaneshaServerSpec { func (in *GatewaySpec) DeepCopyInto(out *GatewaySpec) { *out = *in in.Placement.DeepCopyInto(&out.Placement) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Resources.DeepCopyInto(&out.Resources) return } @@ -614,6 +645,13 @@ func (in *GatewaySpec) DeepCopy() *GatewaySpec { func (in *MetadataServerSpec) DeepCopyInto(out *MetadataServerSpec) { *out = *in in.Placement.DeepCopyInto(&out.Placement) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Resources.DeepCopyInto(&out.Resources) return } diff --git a/pkg/apis/cockroachdb.rook.io/v1alpha1/types.go b/pkg/apis/cockroachdb.rook.io/v1alpha1/types.go index 5dec6d03b..0045ad73a 100644 --- a/pkg/apis/cockroachdb.rook.io/v1alpha1/types.go +++ b/pkg/apis/cockroachdb.rook.io/v1alpha1/types.go @@ -46,6 +46,8 @@ type ClusterList struct { } type ClusterSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` Storage rook.StorageScopeSpec `json:"scope,omitempty"` Network rook.NetworkSpec `json:"network,omitempty"` Secure bool `json:"secure,omitempty"` diff --git a/pkg/apis/cockroachdb.rook.io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/cockroachdb.rook.io/v1alpha1/zz_generated.deepcopy.go index 42c258183..6a43ecfd2 100644 --- a/pkg/apis/cockroachdb.rook.io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/cockroachdb.rook.io/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + v1alpha2 "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -87,6 +88,13 @@ func (in *ClusterList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Storage.DeepCopyInto(&out.Storage) in.Network.DeepCopyInto(&out.Network) return diff --git a/pkg/apis/edgefs.rook.io/v1alpha1/annotations.go b/pkg/apis/edgefs.rook.io/v1alpha1/annotations.go new file mode 100644 index 000000000..af848c664 --- /dev/null +++ b/pkg/apis/edgefs.rook.io/v1alpha1/annotations.go @@ -0,0 +1,36 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + rook "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" +) + +// GetPrepareAnnotations returns the Annotations for the prepare service +func GetPrepareAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyPrepare]) +} + +// GetMgrAnnotations returns the Annotations for the MGR service +func GetMgrAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyMgr]) +} + +// GetTargetAnnotations returns the Annotations for the target service +func GetTargetAnnotations(a rook.AnnotationsSpec) rook.Annotations { + return a.All().Merge(a[KeyTarget]) +} diff --git a/pkg/apis/edgefs.rook.io/v1alpha1/keys.go b/pkg/apis/edgefs.rook.io/v1alpha1/keys.go new file mode 100644 index 000000000..ab74e4d09 --- /dev/null +++ b/pkg/apis/edgefs.rook.io/v1alpha1/keys.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 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 v1alpha1 + +const ( + KeyPrepare = "prepare" + KeyMgr = "mgr" + KeyTarget = "target" +) diff --git a/pkg/apis/edgefs.rook.io/v1alpha1/types.go b/pkg/apis/edgefs.rook.io/v1alpha1/types.go index 164c9cc3f..feaaf955b 100644 --- a/pkg/apis/edgefs.rook.io/v1alpha1/types.go +++ b/pkg/apis/edgefs.rook.io/v1alpha1/types.go @@ -54,6 +54,8 @@ type ClusterList struct { type ClusterSpec struct { Storage rook.StorageScopeSpec `json:"storage,omitempty"` + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.AnnotationsSpec `json:"annotations,omitempty"` // The placement-related configuration to pass to kubernetes (affinity, node selector, tolerations). Placement rook.PlacementSpec `json:"placement,omitempty"` Network NetworkSpec `json:"network,omitempty"` @@ -112,6 +114,8 @@ type NFSList struct { // NFSSpec represent the spec of a pool type NFSSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` // The affinity to place the NFS pods (default is to place on any available nodes in EdgeFS running namespace) Placement rook.Placement `json:"placement"` // Resources set resource requests and limits @@ -143,6 +147,8 @@ type S3List struct { // S3Spec represent the spec of a s3 service type S3Spec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` // The affinity to place the S3 pods (default is to place on any available nodes in EdgeFS running namespace) Placement rook.Placement `json:"placement"` // Resources set resource requests and limits @@ -217,6 +223,8 @@ type S3XList struct { // S3XSpec represent the spec of a s3 service type S3XSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` // The affinity to place the S3X pods (default is to place on any available nodes in EdgeFS running namespace) Placement rook.Placement `json:"placement"` // Resources set resource requests and limits @@ -253,6 +261,8 @@ type ISCSIList struct { // ISCSISpec represent the spec of a iscsi service type ISCSISpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` // The affinity to place the ISCSI pods (default is to place on any available nodes in EdgeFS running namespace) Placement rook.Placement `json:"placement"` // Resources set resource requests and limits @@ -296,6 +306,8 @@ type ISGWList struct { // ISGWSpec represent the spec of a isgw service type ISGWSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` // The affinity to place the ISGW pods (default is to place on any available nodes in EdgeFS running namespace) Placement rook.Placement `json:"placement"` // Resources set resource requests and limits diff --git a/pkg/apis/minio.rook.io/v1alpha1/types.go b/pkg/apis/minio.rook.io/v1alpha1/types.go index 8f9fbae98..41aae8c00 100644 --- a/pkg/apis/minio.rook.io/v1alpha1/types.go +++ b/pkg/apis/minio.rook.io/v1alpha1/types.go @@ -56,6 +56,9 @@ type ObjectStoreSpec struct { // A spec for available storage in the cluster and how it should be used Storage rook.StorageScopeSpec `json:"scope,omitempty"` + // The annotations to add/set on each Pod related object. + Annotations rook.Annotations `json:"annotations,omitempty"` + // The placement-related configuration to pass to kubernetes (affinity, node selector, // tolerations). Placement rook.PlacementSpec `json:"placement,omitempty"` diff --git a/pkg/apis/minio.rook.io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/minio.rook.io/v1alpha1/zz_generated.deepcopy.go index 3cd68ec7a..7a975df27 100644 --- a/pkg/apis/minio.rook.io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/minio.rook.io/v1alpha1/zz_generated.deepcopy.go @@ -89,6 +89,13 @@ func (in *ObjectStoreList) DeepCopyObject() runtime.Object { func (in *ObjectStoreSpec) DeepCopyInto(out *ObjectStoreSpec) { *out = *in in.Storage.DeepCopyInto(&out.Storage) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Placement != nil { in, out := &in.Placement, &out.Placement *out = make(v1alpha2.PlacementSpec, len(*in)) diff --git a/pkg/apis/nfs.rook.io/v1alpha1/types.go b/pkg/apis/nfs.rook.io/v1alpha1/types.go index 1e637b141..144311814 100644 --- a/pkg/apis/nfs.rook.io/v1alpha1/types.go +++ b/pkg/apis/nfs.rook.io/v1alpha1/types.go @@ -16,6 +16,7 @@ limitations under the License. package v1alpha1 import ( + rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -46,6 +47,9 @@ type NFSServerList struct { // NFSSpec represents the spec of NFS daemon type NFSServerSpec struct { + // The annotations-related configuration to add/set on each Pod related object. + Annotations rookalpha.Annotations `json:"annotations,omitempty"` + // Replicas of the NFS daemon Replicas int `json:"replicas,omitempty"` @@ -67,7 +71,6 @@ type ExportsSpec struct { // ServerSpec represents the spec for configuring the NFS server type ServerSpec struct { - // Reading and Writing permissions on the export // Valid values are "ReadOnly", "ReadWrite" and "none" AccessMode string `json:"accessMode,omitempty"` diff --git a/pkg/apis/nfs.rook.io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/nfs.rook.io/v1alpha1/zz_generated.deepcopy.go index 30ed96311..c04a7cd5f 100644 --- a/pkg/apis/nfs.rook.io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/nfs.rook.io/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + v1alpha2 "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -126,6 +127,13 @@ func (in *NFSServerList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NFSServerSpec) DeepCopyInto(out *NFSServerSpec) { *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(v1alpha2.Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Exports != nil { in, out := &in.Exports, &out.Exports *out = make([]ExportsSpec, len(*in)) diff --git a/pkg/apis/rook.io/v1alpha2/annotations.go b/pkg/apis/rook.io/v1alpha2/annotations.go new file mode 100644 index 000000000..21a0cc5b8 --- /dev/null +++ b/pkg/apis/rook.io/v1alpha2/annotations.go @@ -0,0 +1,59 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func (a AnnotationsSpec) All() Annotations { + return a[KeyAll] +} + +// ApplyToObjectMeta adds or overwrites if exists annotations to object meta. +func (a Annotations) ApplyToObjectMeta(t *metav1.ObjectMeta) { + if t.Annotations == nil { + t.Annotations = map[string]string{} + } + for k, v := range a { + if _, ok := t.Annotations[k]; !ok { + t.Annotations[k] = v + } + } +} + +// Merge returns an Annotations which results from merging the attributes of the +// original Annotations with the attributes of the supplied one. The supplied +// Placement's attributes will override the original ones if defined. +func (a Annotations) Merge(with Annotations) Annotations { + ret := a + for k, v := range with { + if _, ok := ret[k]; !ok { + ret[k] = v + } + } + return ret +} + +// GetMapStringString return the Annotations as a +func (a Annotations) GetMapStringString() map[string]string { + res := map[string]string{} + for k, v := range a { + res[k] = v + } + return res +} diff --git a/pkg/apis/rook.io/v1alpha2/annotations_test.go b/pkg/apis/rook.io/v1alpha2/annotations_test.go new file mode 100644 index 000000000..d79915f72 --- /dev/null +++ b/pkg/apis/rook.io/v1alpha2/annotations_test.go @@ -0,0 +1,84 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + "encoding/json" + "testing" + + "github.com/ghodss/yaml" + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestAnnotationsSpec(t *testing.T) { + specYaml := []byte(` +mgr: + foo: bar + hello: world +mon: +`) + + // convert the raw spec yaml into JSON + rawJSON, err := yaml.YAMLToJSON(specYaml) + assert.Nil(t, err) + + // unmarshal the JSON into a strongly typed annotations spec object + var annotations AnnotationsSpec + err = json.Unmarshal(rawJSON, &annotations) + assert.Nil(t, err) + + // the unmarshalled annotations spec should equal the expected spec below + expected := AnnotationsSpec{ + "mgr": map[string]string{ + "foo": "bar", + "hello": "world", + }, + "mon": nil, + } + assert.Equal(t, expected, annotations) +} + +func TestAnnotations_ApplyToPodSpec(t *testing.T) { + objMeta := &metav1.ObjectMeta{} + testAnnotations := Annotations{ + "foo": "bar", + "hello": "world", + } + testAnnotations.ApplyToObjectMeta(objMeta) + assert.Equal(t, testAnnotations.GetMapStringString(), objMeta.Annotations) + + testAnnotations["isthisatest"] = "test" + testAnnotations.ApplyToObjectMeta(objMeta) + assert.Equal(t, testAnnotations.GetMapStringString(), objMeta.Annotations) +} + +func TestAnnotations_Merge(t *testing.T) { + testAnnotationsPart1 := Annotations{ + "foo": "bar", + "hello": "world", + } + testAnnotationsPart2 := Annotations{ + "bar": "foo", + "hello": "earth", + } + assert.Equal(t, map[string]string{ + "foo": "bar", + "bar": "foo", + "hello": "world", + }, testAnnotationsPart1.Merge(testAnnotationsPart2).GetMapStringString()) +} diff --git a/pkg/apis/rook.io/v1alpha2/keys.go b/pkg/apis/rook.io/v1alpha2/keys.go new file mode 100644 index 000000000..a29bc7c11 --- /dev/null +++ b/pkg/apis/rook.io/v1alpha2/keys.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 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 v1alpha2 + +const ( + KeyAll = "all" +) diff --git a/pkg/apis/rook.io/v1alpha2/placement.go b/pkg/apis/rook.io/v1alpha2/placement.go index 84fba9b4d..fe3abcfc8 100644 --- a/pkg/apis/rook.io/v1alpha2/placement.go +++ b/pkg/apis/rook.io/v1alpha2/placement.go @@ -19,12 +19,8 @@ import ( "k8s.io/api/core/v1" ) -const ( - PlacementKeyAll = "all" -) - func (p PlacementSpec) All() Placement { - return p[PlacementKeyAll] + return p[KeyAll] } // ApplyToPodSpec adds placement to a pod spec diff --git a/pkg/apis/rook.io/v1alpha2/types.go b/pkg/apis/rook.io/v1alpha2/types.go index 95b8c2a6e..b5e82ff76 100644 --- a/pkg/apis/rook.io/v1alpha2/types.go +++ b/pkg/apis/rook.io/v1alpha2/types.go @@ -67,7 +67,7 @@ type Selection struct { VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` } -type PlacementSpec map[string]Placement +type PlacementSpec map[KeyType]Placement type Placement struct { NodeAffinity *v1.NodeAffinity `json:"nodeAffinity,omitempty"` @@ -119,3 +119,10 @@ type VolumeList struct { metav1.ListMeta `json:"metadata"` Items []Volume `json:"items"` } + +// KeyType +type KeyType string + +type AnnotationsSpec map[KeyType]Annotations + +type Annotations map[string]string diff --git a/pkg/apis/rook.io/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/rook.io/v1alpha2/zz_generated.deepcopy.go index bef949fa3..71d2a5f2d 100644 --- a/pkg/apis/rook.io/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/rook.io/v1alpha2/zz_generated.deepcopy.go @@ -25,6 +25,60 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Annotations) DeepCopyInto(out *Annotations) { + { + in := &in + *out = make(Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Annotations. +func (in Annotations) DeepCopy() Annotations { + if in == nil { + return nil + } + out := new(Annotations) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in AnnotationsSpec) DeepCopyInto(out *AnnotationsSpec) { + { + in := &in + *out = make(AnnotationsSpec, len(*in)) + for key, val := range *in { + var outVal map[string]string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(Annotations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnnotationsSpec. +func (in AnnotationsSpec) DeepCopy() AnnotationsSpec { + if in == nil { + return nil + } + out := new(AnnotationsSpec) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Attachment) DeepCopyInto(out *Attachment) { *out = *in diff --git a/pkg/operator/cassandra/controller/cluster.go b/pkg/operator/cassandra/controller/cluster.go index 6eaa0da71..5ba64eaa6 100644 --- a/pkg/operator/cassandra/controller/cluster.go +++ b/pkg/operator/cassandra/controller/cluster.go @@ -18,6 +18,7 @@ package controller import ( "fmt" + cassandrav1alpha1 "github.com/rook/rook/pkg/apis/cassandra.rook.io/v1alpha1" "github.com/rook/rook/pkg/operator/cassandra/constants" "github.com/rook/rook/pkg/operator/cassandra/controller/util" @@ -29,7 +30,6 @@ import ( // It doesn't post the result to the API Server yet. // That will be done at the end of the sync loop. func (cc *ClusterController) updateStatus(c *cassandrav1alpha1.Cluster) error { - clusterStatus := cassandrav1alpha1.ClusterStatus{ Racks: map[string]*cassandrav1alpha1.RackStatus{}, } @@ -91,7 +91,6 @@ func (cc *ClusterController) updateStatus(c *cassandrav1alpha1.Cluster) error { // SyncCluster checks the Status and performs reconciliation for // the given Cassandra Cluster. func (cc *ClusterController) syncCluster(c *cassandrav1alpha1.Cluster) error { - // Check if any rack isn't created for _, rack := range c.Spec.Datacenter.Racks { // For each rack, check if a status entry exists @@ -144,8 +143,9 @@ func (cc *ClusterController) syncCluster(c *cassandrav1alpha1.Cluster) error { // createRack creates a new Cassandra Rack with 0 Members. func (cc *ClusterController) createRack(r cassandrav1alpha1.RackSpec, c *cassandrav1alpha1.Cluster) error { - sts := util.StatefulSetForRack(r, c, cc.rookImage) + c.Spec.Annotations.Merge(r.Annotations).ApplyToObjectMeta(&sts.Spec.Template.ObjectMeta) + c.Spec.Annotations.Merge(r.Annotations).ApplyToObjectMeta(&sts.ObjectMeta) existingStatefulset, err := cc.statefulSetLister.StatefulSets(sts.Namespace).Get(sts.Name) if err == nil { return util.VerifyOwner(existingStatefulset, c) @@ -175,7 +175,6 @@ func (cc *ClusterController) createRack(r cassandrav1alpha1.RackSpec, c *cassand // scaleUpRack handles scaling up for an existing Cassandra Rack. // Calling this action implies all members of the Rack are Ready. func (cc *ClusterController) scaleUpRack(r cassandrav1alpha1.RackSpec, c *cassandrav1alpha1.Cluster) error { - sts, err := cc.statefulSetLister.StatefulSets(c.Namespace).Get(util.StatefulSetNameForRack(r, c)) if err != nil { return fmt.Errorf("error trying to scale rack %s in namespace %s, underlying StatefulSet not found", r.Name, c.Namespace) @@ -201,7 +200,6 @@ func (cc *ClusterController) scaleUpRack(r cassandrav1alpha1.RackSpec, c *cassan // scaleDownRack handles scaling down for an existing Cassandra Rack. // Calling this action implies all members of the Rack are Ready. func (cc *ClusterController) scaleDownRack(r cassandrav1alpha1.RackSpec, c *cassandrav1alpha1.Cluster) error { - logger.Infof("Scaling down rack %s", r.Name) // Get the current actual number of Members diff --git a/pkg/operator/cassandra/controller/cluster_test.go b/pkg/operator/cassandra/controller/cluster_test.go index 58a1b5815..4b7dfd13e 100644 --- a/pkg/operator/cassandra/controller/cluster_test.go +++ b/pkg/operator/cassandra/controller/cluster_test.go @@ -18,6 +18,8 @@ package controller import ( "fmt" + "testing" + cassandrav1alpha1 "github.com/rook/rook/pkg/apis/cassandra.rook.io/v1alpha1" "github.com/rook/rook/pkg/operator/cassandra/constants" "github.com/rook/rook/pkg/operator/cassandra/controller/util" @@ -26,11 +28,9 @@ import ( appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "testing" ) func TestCreateRack(t *testing.T) { - simpleCluster := casstest.NewSimpleCluster(3) tests := []struct { @@ -77,14 +77,14 @@ func TestCreateRack(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { cc := newFakeClusterController(test.kubeObjects, nil) - err := cc.createRack(test.rack, test.cluster) - if err == nil { + if err := cc.createRack(test.rack, test.cluster); err == nil { if test.expectedErr { t.Errorf("Expected an error, got none.") } else { - sts, err := cc.kubeClient.AppsV1().StatefulSets(test.cluster.Namespace). + var sts *appsv1.StatefulSet + sts, err = cc.kubeClient.AppsV1().StatefulSets(test.cluster.Namespace). Get(util.StatefulSetNameForRack(test.rack, test.cluster), metav1.GetOptions{}) if err != nil { t.Errorf("Couldn't retrieve expected StatefulSet: %s", err.Error()) @@ -92,8 +92,7 @@ func TestCreateRack(t *testing.T) { t.Logf("Got StatefulSet as expected: %s", sts.Name) } } - } - if err != nil { + } else { if test.expectedErr { t.Logf("Got an error as expected: %s", err.Error()) } else { diff --git a/pkg/operator/cassandra/controller/sync.go b/pkg/operator/cassandra/controller/sync.go index 48d5b737f..119c4269d 100644 --- a/pkg/operator/cassandra/controller/sync.go +++ b/pkg/operator/cassandra/controller/sync.go @@ -26,7 +26,7 @@ const ( // SuccessSynced is used as part of the Event 'reason' when a Cluster is // synced. SuccessSynced = "Synced" - // ErrResourceExists is used as part of the Event 'reason' when a + // ErrSyncFailed is used as part of the Event 'reason' when a // Cluster fails to sync due to a resource of the same name already // existing. ErrSyncFailed = "ErrSyncFailed" diff --git a/pkg/operator/ceph/cluster/cluster.go b/pkg/operator/ceph/cluster/cluster.go index e3a18c437..9a38874b0 100755 --- a/pkg/operator/ceph/cluster/cluster.go +++ b/pkg/operator/ceph/cluster/cluster.go @@ -195,8 +195,8 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers } mgrs := mgr.New(c.Info, c.context, c.Namespace, rookImage, - spec.CephVersion, cephv1.GetMgrPlacement(spec.Placement), spec.Network.HostNetwork, - spec.Dashboard, cephv1.GetMgrResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath) + spec.CephVersion, cephv1.GetMgrPlacement(spec.Placement), cephv1.GetMgrAnnotations(c.Spec.Annotations), + spec.Network.HostNetwork, spec.Dashboard, cephv1.GetMgrResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath) err = mgrs.Start() if err != nil { return fmt.Errorf("failed to start the ceph mgr. %+v", err) @@ -204,7 +204,8 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers // Start the OSDs osds := osd.New(c.Info, c.context, c.Namespace, rookImage, spec.CephVersion, spec.Storage, spec.DataDirHostPath, - cephv1.GetOSDPlacement(spec.Placement), spec.Network.HostNetwork, cephv1.GetOSDResources(spec.Resources), c.ownerRef) + cephv1.GetOSDPlacement(spec.Placement), cephv1.GetOSDAnnotations(spec.Annotations), spec.Network.HostNetwork, + cephv1.GetOSDResources(spec.Resources), c.ownerRef) err = osds.Start() if err != nil { return fmt.Errorf("failed to start the osds. %+v", err) @@ -212,7 +213,8 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers // Start the rbd mirroring daemon(s) rbdmirror := rbd.New(c.Info, c.context, c.Namespace, rookImage, spec.CephVersion, cephv1.GetRBDMirrorPlacement(spec.Placement), - spec.Network.HostNetwork, spec.RBDMirroring, cephv1.GetRBDMirrorResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath) + cephv1.GetRBDMirrorAnnotations(spec.Annotations), spec.Network.HostNetwork, spec.RBDMirroring, + cephv1.GetRBDMirrorResources(spec.Resources), c.ownerRef, c.Spec.DataDirHostPath) err = rbdmirror.Start() if err != nil { return fmt.Errorf("failed to start the rbd mirrors. %+v", err) diff --git a/pkg/operator/ceph/cluster/mgr/mgr.go b/pkg/operator/ceph/cluster/mgr/mgr.go index e12f64980..e628d2f1f 100644 --- a/pkg/operator/ceph/cluster/mgr/mgr.go +++ b/pkg/operator/ceph/cluster/mgr/mgr.go @@ -51,6 +51,7 @@ type Cluster struct { Namespace string Replicas int placement rookalpha.Placement + annotations rookalpha.Annotations context *clusterd.Context dataDir string HostNetwork bool @@ -70,6 +71,7 @@ func New( namespace, rookVersion string, cephVersion cephv1.CephVersionSpec, placement rookalpha.Placement, + annotations rookalpha.Annotations, hostNetwork bool, dashboard cephv1.DashboardSpec, resources v1.ResourceRequirements, diff --git a/pkg/operator/ceph/cluster/mgr/mgr_test.go b/pkg/operator/ceph/cluster/mgr/mgr_test.go index 1bd7366dd..b3a0ad331 100755 --- a/pkg/operator/ceph/cluster/mgr/mgr_test.go +++ b/pkg/operator/ceph/cluster/mgr/mgr_test.go @@ -60,6 +60,7 @@ func TestStartMGR(t *testing.T) { "myversion", cephv1.CephVersionSpec{}, rookalpha.Placement{}, + rookalpha.Annotations{}, false, cephv1.DashboardSpec{Enabled: true}, v1.ResourceRequirements{}, diff --git a/pkg/operator/ceph/cluster/mgr/spec.go b/pkg/operator/ceph/cluster/mgr/spec.go index 930a27c12..f2450114a 100644 --- a/pkg/operator/ceph/cluster/mgr/spec.go +++ b/pkg/operator/ceph/cluster/mgr/spec.go @@ -37,8 +37,6 @@ func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *apps.Deployment { ObjectMeta: metav1.ObjectMeta{ Name: mgrConfig.ResourceName, Labels: c.getPodLabels(mgrConfig.DaemonID), - Annotations: map[string]string{"prometheus.io/scrape": "true", - "prometheus.io/port": strconv.Itoa(metricsPort)}, }, Spec: v1.PodSpec{ InitContainers: []v1.Container{ @@ -60,6 +58,7 @@ func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *apps.Deployment { if c.HostNetwork { podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet } + c.annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) c.placement.ApplyToPodSpec(&podSpec.Spec) if c.clusterInfo.CephVersion.IsLuminous() { // prepend the keyring-copy workaround for luminous clusters @@ -87,6 +86,14 @@ func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *apps.Deployment { }, } k8sutil.AddRookVersionLabelToDeployment(d) + if len(c.annotations) == 0 { + prometheusAnnotations := map[string]string{ + "prometheus.io/scrape": "true", + "prometheus.io/port": strconv.Itoa(metricsPort), + } + podSpec.ObjectMeta.Annotations = prometheusAnnotations + d.ObjectMeta.Annotations = prometheusAnnotations + } k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &d.ObjectMeta, &c.ownerRef) return d } diff --git a/pkg/operator/ceph/cluster/mgr/spec_test.go b/pkg/operator/ceph/cluster/mgr/spec_test.go index 759871850..807cfa1f7 100644 --- a/pkg/operator/ceph/cluster/mgr/spec_test.go +++ b/pkg/operator/ceph/cluster/mgr/spec_test.go @@ -41,6 +41,7 @@ func TestPodSpec(t *testing.T) { "rook/rook:myversion", cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"}, rookalpha.Placement{}, + rookalpha.Annotations{}, false, cephv1.DashboardSpec{}, v1.ResourceRequirements{ @@ -88,6 +89,7 @@ func TestServiceSpec(t *testing.T) { "myversion", cephv1.CephVersionSpec{}, rookalpha.Placement{}, + rookalpha.Annotations{}, false, cephv1.DashboardSpec{}, v1.ResourceRequirements{}, @@ -110,6 +112,7 @@ func TestHostNetwork(t *testing.T) { "myversion", cephv1.CephVersionSpec{}, rookalpha.Placement{}, + rookalpha.Annotations{}, true, cephv1.DashboardSpec{}, v1.ResourceRequirements{}, diff --git a/pkg/operator/ceph/cluster/migration_test.go b/pkg/operator/ceph/cluster/migration_test.go index ded99e004..01368ebb3 100644 --- a/pkg/operator/ceph/cluster/migration_test.go +++ b/pkg/operator/ceph/cluster/migration_test.go @@ -165,16 +165,16 @@ func TestConvertLegacyCluster(t *testing.T) { }, Network: rookv1alpha2.NetworkSpec{HostNetwork: true}, Placement: rookv1alpha2.PlacementSpec{ - rookv1alpha2.PlacementKeyAll: rookv1alpha2.Placement{Tolerations: []v1.Toleration{{Key: "storage-node", Operator: v1.TolerationOpExists}}}, - cephv1.PlacementKeyMon: rookv1alpha2.Placement{ + rookv1alpha2.KeyAll: rookv1alpha2.Placement{Tolerations: []v1.Toleration{{Key: "storage-node", Operator: v1.TolerationOpExists}}}, + cephv1.KeyMon: rookv1alpha2.Placement{ PodAntiAffinity: &v1.PodAntiAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ {LabelSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"label": "value"}}}, }, }, }, - cephv1.PlacementKeyMgr: rookv1alpha2.Placement{}, - cephv1.PlacementKeyOSD: rookv1alpha2.Placement{}, + cephv1.KeyMgr: rookv1alpha2.Placement{}, + cephv1.KeyOSD: rookv1alpha2.Placement{}, }, Resources: rookv1alpha2.ResourceSpec{ cephv1.ResourcesKeyOSD: v1.ResourceRequirements{Limits: v1.ResourceList{v1.ResourceMemory: resource.MustParse("250Mi")}}, @@ -251,16 +251,16 @@ func TestConvertLegacyCluster(t *testing.T) { }, Network: rookv1alpha2.NetworkSpec{HostNetwork: true}, Placement: rookv1alpha2.PlacementSpec{ - rookv1alpha2.PlacementKeyAll: rookv1alpha2.Placement{Tolerations: []v1.Toleration{{Key: "storage-node", Operator: v1.TolerationOpExists}}}, - cephv1.PlacementKeyMon: rookv1alpha2.Placement{ + rookv1alpha2.KeyAll: rookv1alpha2.Placement{Tolerations: []v1.Toleration{{Key: "storage-node", Operator: v1.TolerationOpExists}}}, + cephv1.KeyMon: rookv1alpha2.Placement{ PodAntiAffinity: &v1.PodAntiAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ {LabelSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"label": "value"}}}, }, }, }, - cephv1.PlacementKeyMgr: rookv1alpha2.Placement{}, - cephv1.PlacementKeyOSD: rookv1alpha2.Placement{}, + cephv1.KeyMgr: rookv1alpha2.Placement{}, + cephv1.KeyOSD: rookv1alpha2.Placement{}, }, Resources: rookv1alpha2.ResourceSpec{ cephv1.ResourcesKeyOSD: v1.ResourceRequirements{Limits: v1.ResourceList{v1.ResourceMemory: resource.MustParse("250Mi")}}, diff --git a/pkg/operator/ceph/cluster/mon/mon.go b/pkg/operator/ceph/cluster/mon/mon.go index de77788a7..030fab4ac 100644 --- a/pkg/operator/ceph/cluster/mon/mon.go +++ b/pkg/operator/ceph/cluster/mon/mon.go @@ -432,9 +432,8 @@ func (c *Cluster) waitForMonsToJoin(mons []*monConfig, requireAllInQuorum bool) func (c *Cluster) saveMonConfig() error { configMap := &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: EndpointConfigMapName, - Namespace: c.Namespace, - Annotations: map[string]string{}, + Name: EndpointConfigMapName, + Namespace: c.Namespace, }, } k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &configMap.ObjectMeta, &c.ownerRef) diff --git a/pkg/operator/ceph/cluster/mon/node_test.go b/pkg/operator/ceph/cluster/mon/node_test.go index b0cec23e8..765550003 100644 --- a/pkg/operator/ceph/cluster/mon/node_test.go +++ b/pkg/operator/ceph/cluster/mon/node_test.go @@ -138,8 +138,8 @@ func TestNodeAffinity(t *testing.T) { assert.Nil(t, err) assert.Equal(t, 3, len(nodes)) - c.spec.Placement = map[string]rookalpha.Placement{} - c.spec.Placement["mon"] = rookalpha.Placement{NodeAffinity: &v1.NodeAffinity{ + c.spec.Placement = map[rookalpha.KeyType]rookalpha.Placement{} + c.spec.Placement[cephv1.KeyMon] = rookalpha.Placement{NodeAffinity: &v1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{ NodeSelectorTerms: []v1.NodeSelectorTerm{ { diff --git a/pkg/operator/ceph/cluster/mon/spec.go b/pkg/operator/ceph/cluster/mon/spec.go index 44b46bcbb..efeeeafd6 100644 --- a/pkg/operator/ceph/cluster/mon/spec.go +++ b/pkg/operator/ceph/cluster/mon/spec.go @@ -57,6 +57,7 @@ func (c *Cluster) makeDeployment(monConfig *monConfig, hostname string) *apps.De }, } k8sutil.AddRookVersionLabelToDeployment(d) + cephv1.GetMonAnnotations(c.spec.Annotations).ApplyToObjectMeta(&d.ObjectMeta) k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &d.ObjectMeta, &c.ownerRef) pod := c.makeMonPod(monConfig, hostname) @@ -109,13 +110,13 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, hostname string) *v1.Pod { pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - Name: monConfig.ResourceName, - Namespace: c.Namespace, - Labels: c.getLabels(monConfig.DaemonName), - Annotations: map[string]string{}, + Name: monConfig.ResourceName, + Namespace: c.Namespace, + Labels: c.getLabels(monConfig.DaemonName), }, Spec: podSpec, } + cephv1.GetMonAnnotations(c.spec.Annotations).ApplyToObjectMeta(&pod.ObjectMeta) return pod } diff --git a/pkg/operator/ceph/cluster/osd/osd.go b/pkg/operator/ceph/cluster/osd/osd.go index 6d07fc8f2..a21f6fed4 100644 --- a/pkg/operator/ceph/cluster/osd/osd.go +++ b/pkg/operator/ceph/cluster/osd/osd.go @@ -63,6 +63,7 @@ type Cluster struct { context *clusterd.Context Namespace string placement rookalpha.Placement + annotations rookalpha.Annotations Keyring string rookVersion string cephVersion cephv1.CephVersionSpec @@ -85,16 +86,17 @@ func New( storageSpec rookalpha.StorageScopeSpec, dataDirHostPath string, placement rookalpha.Placement, + annotations rookalpha.Annotations, hostNetwork bool, resources v1.ResourceRequirements, ownerRef metav1.OwnerReference, ) *Cluster { - return &Cluster{ clusterInfo: clusterInfo, context: context, Namespace: namespace, placement: placement, + annotations: annotations, rookVersion: rookVersion, cephVersion: cephVersion, DesiredStorage: storageSpec, diff --git a/pkg/operator/ceph/cluster/osd/osd_test.go b/pkg/operator/ceph/cluster/osd/osd_test.go index b3e6faf4a..2023031aa 100644 --- a/pkg/operator/ceph/cluster/osd/osd_test.go +++ b/pkg/operator/ceph/cluster/osd/osd_test.go @@ -47,7 +47,7 @@ func TestStart(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "myversion", cephv1.CephVersionSpec{}, - rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) // Start the first time err := c.Start() @@ -125,7 +125,7 @@ func TestAddRemoveNode(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns-add-remove", "myversion", cephv1.CephVersionSpec{}, - storageSpec, "/foo", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "/foo", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) // kick off the start of the orchestration in a goroutine var startErr error @@ -210,7 +210,7 @@ func TestAddRemoveNode(t *testing.T) { // modify the storage spec to remove the node from the cluster storageSpec.Nodes = []rookalpha.Node{} c = New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: mockExec}, "ns-add-remove", "myversion", cephv1.CephVersionSpec{}, - storageSpec, "", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) // reset the orchestration status watcher statusMapWatcher = watch.NewFake() @@ -252,7 +252,7 @@ func TestDiscoverOSDs(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{}, "ns", "myversion", cephv1.CephVersionSpec{}, - rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) node1 := "n1" node2 := "n2" @@ -323,7 +323,7 @@ func TestAddNodeFailure(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns-add-remove", "myversion", cephv1.CephVersionSpec{}, - storageSpec, "/foo", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "/foo", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) // kick off the start of the orchestration in a goroutine var startErr error diff --git a/pkg/operator/ceph/cluster/osd/spec.go b/pkg/operator/ceph/cluster/osd/spec.go index 078047d72..9f4a525b1 100644 --- a/pkg/operator/ceph/cluster/osd/spec.go +++ b/pkg/operator/ceph/cluster/osd/spec.go @@ -268,7 +268,6 @@ func (c *Cluster) makeDeployment(nodeName string, selection rookalpha.Selection, k8sutil.ClusterAttr: c.Namespace, osdLabelKey: fmt.Sprintf("%d", osd.ID), }, - Annotations: map[string]string{}, }, Spec: v1.PodSpec{ NodeSelector: map[string]string{apis.LabelHostname: nodeName}, @@ -308,6 +307,8 @@ func (c *Cluster) makeDeployment(nodeName string, selection rookalpha.Selection, }, } k8sutil.AddRookVersionLabelToDeployment(deployment) + c.annotations.ApplyToObjectMeta(&deployment.ObjectMeta) + c.annotations.ApplyToObjectMeta(&deployment.Spec.Template.ObjectMeta) k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &deployment.ObjectMeta, &c.ownerRef) c.placement.ApplyToPodSpec(&deployment.Spec.Template.Spec) return deployment, nil @@ -377,20 +378,24 @@ func (c *Cluster) provisionPodTemplateSpec(devices []rookalpha.Device, selection } c.placement.ApplyToPodSpec(&podSpec) + podMeta := metav1.ObjectMeta{ + Name: appName, + Labels: map[string]string{ + k8sutil.AppAttr: prepareAppName, + k8sutil.ClusterAttr: c.Namespace, + }, + Annotations: map[string]string{}, + } + + c.annotations.ApplyToObjectMeta(&podMeta) + // ceph-volume --dmcrypt uses cryptsetup that synchronizes with udev on // host through semaphore podSpec.HostIPC = storeConfig.EncryptedDevice return &v1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Name: appName, - Labels: map[string]string{ - k8sutil.AppAttr: prepareAppName, - k8sutil.ClusterAttr: c.Namespace, - }, - Annotations: map[string]string{}, - }, - Spec: podSpec, + ObjectMeta: podMeta, + Spec: podSpec, }, nil } diff --git a/pkg/operator/ceph/cluster/osd/spec_test.go b/pkg/operator/ceph/cluster/osd/spec_test.go index 5ff2054f0..50b25d558 100644 --- a/pkg/operator/ceph/cluster/osd/spec_test.go +++ b/pkg/operator/ceph/cluster/osd/spec_test.go @@ -79,7 +79,7 @@ func testPodDevices(t *testing.T, dataDir, deviceName string, allDevices bool) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "rook/rook:myversion", cephVersion, - storageSpec, dataDir, rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, dataDir, rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) devMountNeeded := deviceName != "" || allDevices @@ -165,7 +165,7 @@ func TestStorageSpecDevicesAndDirectories(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "rook/rook:myversion", cephv1.CephVersionSpec{}, - storageSpec, "/var/lib/rook", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "/var/lib/rook", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) n := c.DesiredStorage.ResolveNode(storageSpec.Nodes[0].Name) osd := OSDInfo{ @@ -260,7 +260,7 @@ func TestStorageSpecConfig(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "rook/rook:myversion", cephv1.CephVersionSpec{}, - storageSpec, "", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) n := c.DesiredStorage.ResolveNode(storageSpec.Nodes[0].Name) storeConfig := config.ToStoreConfig(storageSpec.Nodes[0].Config) @@ -315,7 +315,7 @@ func TestHostNetwork(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "myversion", cephv1.CephVersionSpec{}, - storageSpec, "", rookalpha.Placement{}, true, v1.ResourceRequirements{}, metav1.OwnerReference{}) + storageSpec, "", rookalpha.Placement{}, rookalpha.Annotations{}, true, v1.ResourceRequirements{}, metav1.OwnerReference{}) n := c.DesiredStorage.ResolveNode(storageSpec.Nodes[0].Name) osd := OSDInfo{ diff --git a/pkg/operator/ceph/cluster/osd/status_test.go b/pkg/operator/ceph/cluster/osd/status_test.go index 43ea75ca1..1b0472968 100644 --- a/pkg/operator/ceph/cluster/osd/status_test.go +++ b/pkg/operator/ceph/cluster/osd/status_test.go @@ -42,7 +42,7 @@ func TestOrchestrationStatus(t *testing.T) { CephVersion: cephver.Nautilus, } c := New(clusterInfo, &clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "myversion", cephv1.CephVersionSpec{}, - rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) + rookalpha.StorageScopeSpec{}, "", rookalpha.Placement{}, rookalpha.Annotations{}, false, v1.ResourceRequirements{}, metav1.OwnerReference{}) kv := k8sutil.NewConfigMapKVStore(c.Namespace, clientset, metav1.OwnerReference{}) nodeName := "mynode" cmName := fmt.Sprintf(orchestrationStatusMapName, nodeName) diff --git a/pkg/operator/ceph/cluster/rbd/mirror.go b/pkg/operator/ceph/cluster/rbd/mirror.go index 85e95c89b..88948ad48 100644 --- a/pkg/operator/ceph/cluster/rbd/mirror.go +++ b/pkg/operator/ceph/cluster/rbd/mirror.go @@ -43,6 +43,7 @@ type Mirroring struct { ClusterInfo *cephconfig.ClusterInfo Namespace string placement rookalpha.Placement + annotations rookalpha.Annotations context *clusterd.Context resources v1.ResourceRequirements ownerRef metav1.OwnerReference @@ -60,6 +61,7 @@ func New( namespace, rookVersion string, cephVersion cephv1.CephVersionSpec, placement rookalpha.Placement, + annotations rookalpha.Annotations, hostNetwork bool, spec cephv1.RBDMirroringSpec, resources v1.ResourceRequirements, @@ -71,6 +73,7 @@ func New( context: context, Namespace: namespace, placement: placement, + annotations: annotations, rookVersion: rookVersion, cephVersion: cephVersion, spec: spec, diff --git a/pkg/operator/ceph/cluster/rbd/mirror_test.go b/pkg/operator/ceph/cluster/rbd/mirror_test.go index 1dc3de8e8..c236cb072 100644 --- a/pkg/operator/ceph/cluster/rbd/mirror_test.go +++ b/pkg/operator/ceph/cluster/rbd/mirror_test.go @@ -51,6 +51,7 @@ func TestRBDMirror(t *testing.T) { "rook/rook:myversion", cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"}, rookalpha.Placement{}, + rookalpha.Annotations{}, false, cephv1.RBDMirroringSpec{Workers: 2}, v1.ResourceRequirements{}, diff --git a/pkg/operator/ceph/cluster/rbd/spec.go b/pkg/operator/ceph/cluster/rbd/spec.go index a36691431..30e2929e2 100644 --- a/pkg/operator/ceph/cluster/rbd/spec.go +++ b/pkg/operator/ceph/cluster/rbd/spec.go @@ -49,9 +49,10 @@ func (m *Mirroring) makeDeployment(daemonConfig *daemonConfig) *apps.Deployment replicas := int32(1) d := &apps.Deployment{ ObjectMeta: metav1.ObjectMeta{ - Name: daemonConfig.ResourceName, - Namespace: m.Namespace, - Labels: opspec.PodLabels(appName, m.Namespace, string(config.RbdMirrorType), daemonConfig.DaemonID), + Name: daemonConfig.ResourceName, + Namespace: m.Namespace, + Annotations: m.annotations, + Labels: opspec.PodLabels(appName, m.Namespace, string(config.RbdMirrorType), daemonConfig.DaemonID), }, Spec: apps.DeploymentSpec{ Selector: &metav1.LabelSelector{ diff --git a/pkg/operator/ceph/cluster/rbd/spec_test.go b/pkg/operator/ceph/cluster/rbd/spec_test.go index 345cc7fa5..500531f4c 100644 --- a/pkg/operator/ceph/cluster/rbd/spec_test.go +++ b/pkg/operator/ceph/cluster/rbd/spec_test.go @@ -40,6 +40,7 @@ func TestPodSpec(t *testing.T) { "rook/rook:myversion", cephv1.CephVersionSpec{Image: "ceph/ceph:myceph"}, rookalpha.Placement{}, + rookalpha.Annotations{}, false, cephv1.RBDMirroringSpec{Workers: 2}, v1.ResourceRequirements{ diff --git a/pkg/operator/ceph/file/mds/spec.go b/pkg/operator/ceph/file/mds/spec.go index 562f770af..39b0ce889 100644 --- a/pkg/operator/ceph/file/mds/spec.go +++ b/pkg/operator/ceph/file/mds/spec.go @@ -40,9 +40,8 @@ const ( func (c *Cluster) makeDeployment(mdsConfig *mdsConfig) *apps.Deployment { podSpec := v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: mdsConfig.ResourceName, - Labels: c.podLabels(mdsConfig), - Annotations: map[string]string{}, + Name: mdsConfig.ResourceName, + Labels: c.podLabels(mdsConfig), }, Spec: v1.PodSpec{ InitContainers: []v1.Container{}, @@ -57,6 +56,7 @@ func (c *Cluster) makeDeployment(mdsConfig *mdsConfig) *apps.Deployment { if c.HostNetwork { podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet } + c.fs.Spec.MetadataServer.Annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) c.fs.Spec.MetadataServer.Placement.ApplyToPodSpec(&podSpec.Spec) replicas := int32(1) @@ -78,6 +78,7 @@ func (c *Cluster) makeDeployment(mdsConfig *mdsConfig) *apps.Deployment { }, } k8sutil.AddRookVersionLabelToDeployment(d) + c.fs.Spec.MetadataServer.Annotations.ApplyToObjectMeta(&d.ObjectMeta) k8sutil.SetOwnerRefs(c.context.Clientset, c.fs.Namespace, &d.ObjectMeta, c.ownerRefs) return d } diff --git a/pkg/operator/ceph/nfs/spec.go b/pkg/operator/ceph/nfs/spec.go index 27f56eae4..ded7523f8 100644 --- a/pkg/operator/ceph/nfs/spec.go +++ b/pkg/operator/ceph/nfs/spec.go @@ -85,6 +85,7 @@ func (c *CephNFSController) makeDeployment(n cephv1.CephNFS, name, configName st Namespace: n.Namespace, }, } + n.Spec.Server.Annotations.ApplyToObjectMeta(&deployment.ObjectMeta) k8sutil.SetOwnerRef(c.context.Clientset, n.Namespace, &deployment.ObjectMeta, &c.ownerRef) configMapSource := &v1.ConfigMapVolumeSource{ LocalObjectReference: v1.LocalObjectReference{Name: configName}, @@ -110,12 +111,12 @@ func (c *CephNFSController) makeDeployment(n cephv1.CephNFS, name, configName st podTemplateSpec := v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: instanceName(n, name), - Labels: getLabels(n, name), - Annotations: map[string]string{}, + Name: instanceName(n, name), + Labels: getLabels(n, name), }, Spec: podSpec, } + n.Spec.Server.Annotations.ApplyToObjectMeta(&podTemplateSpec.ObjectMeta) // Multiple replicas of the nfs service would be handled by creating a service and a new deployment for each one, rather than increasing the pod count here replicas := int32(1) diff --git a/pkg/operator/ceph/object/spec.go b/pkg/operator/ceph/object/spec.go index f6ea89530..7d2fd3ef1 100644 --- a/pkg/operator/ceph/object/spec.go +++ b/pkg/operator/ceph/object/spec.go @@ -48,6 +48,7 @@ func (c *clusterConfig) startDeployment() (*apps.Deployment, error) { }, } k8sutil.AddRookVersionLabelToDeployment(d) + c.store.Spec.Gateway.Annotations.ApplyToObjectMeta(&d.ObjectMeta) k8sutil.SetOwnerRefs(c.context.Clientset, c.store.Namespace, &d.ObjectMeta, c.ownerRefs) logger.Debugf("starting rgw deployment: %+v", d) @@ -147,17 +148,18 @@ func (c *clusterConfig) makeRGWPodSpec() v1.PodTemplateSpec { }}}} podSpec.Volumes = append(podSpec.Volumes, certVol) } - c.store.Spec.Gateway.Placement.ApplyToPodSpec(&podSpec) - return v1.PodTemplateSpec{ + podTemplateSpec := v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: c.instanceName(), - Labels: c.getLabels(), - Annotations: map[string]string{}, + Name: c.instanceName(), + Labels: c.getLabels(), }, Spec: podSpec, } + c.store.Spec.Gateway.Annotations.ApplyToObjectMeta(&podTemplateSpec.ObjectMeta) + + return podTemplateSpec } func (c *clusterConfig) makeDaemonContainer() v1.Container { diff --git a/pkg/operator/cockroachdb/controller.go b/pkg/operator/cockroachdb/controller.go index 350010bdf..42857c5dc 100644 --- a/pkg/operator/cockroachdb/controller.go +++ b/pkg/operator/cockroachdb/controller.go @@ -86,18 +86,20 @@ func NewClusterController(context *clusterd.Context, containerImage string) *Clu } type cluster struct { - context *clusterd.Context - namespace string - spec cockroachdbv1alpha1.ClusterSpec - ownerRef metav1.OwnerReference + context *clusterd.Context + namespace string + spec cockroachdbv1alpha1.ClusterSpec + annotations rookv1alpha2.Annotations + ownerRef metav1.OwnerReference } func newCluster(c *cockroachdbv1alpha1.Cluster, context *clusterd.Context) *cluster { return &cluster{ - context: context, - namespace: c.Namespace, - spec: c.Spec, - ownerRef: clusterOwnerRef(c.Namespace, string(c.UID)), + context: context, + namespace: c.Namespace, + spec: c.Spec, + annotations: c.Spec.Annotations, + ownerRef: clusterOwnerRef(c.Namespace, string(c.UID)), } } @@ -337,6 +339,8 @@ func (c *ClusterController) createStatefulSet(cluster *cluster) error { VolumeClaimTemplates: cluster.spec.Storage.VolumeClaimTemplates, }, } + cluster.annotations.ApplyToObjectMeta(&statefulSet.Spec.Template.ObjectMeta) + cluster.annotations.ApplyToObjectMeta(&statefulSet.ObjectMeta) k8sutil.SetOwnerRef(c.context.Clientset, cluster.namespace, &statefulSet.ObjectMeta, &cluster.ownerRef) if _, err := c.context.Clientset.AppsV1().StatefulSets(cluster.namespace).Create(statefulSet); err != nil { diff --git a/pkg/operator/edgefs/cluster/cluster.go b/pkg/operator/edgefs/cluster/cluster.go index f04037f69..b8209000a 100644 --- a/pkg/operator/edgefs/cluster/cluster.go +++ b/pkg/operator/edgefs/cluster/cluster.go @@ -134,18 +134,19 @@ func (c *cluster) createInstance(rookImage string) error { // c.targets = target.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, c.Spec.Storage, c.Spec.DataDirHostPath, c.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(c.Spec.Placement), c.Spec.Network, c.Spec.Resources, c.Spec.ResourceProfile, c.Spec.ChunkCacheSize, - c.ownerRef, deploymentConfig) + edgefsv1alpha1.GetTargetAnnotations(c.Spec.Annotations), edgefsv1alpha1.GetTargetPlacement(c.Spec.Placement), c.Spec.Network, c.Spec.Resources, + c.Spec.ResourceProfile, c.Spec.ChunkCacheSize, c.ownerRef, deploymentConfig) err = c.targets.Start(rookImage, clusterNodes, dro) if err != nil { return fmt.Errorf("failed to start the targets. %+v", err) } + // // Create and start EdgeFS manager Deployment (gRPC proxy, Prometheus metrics) // c.mgrs = mgr.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, c.Spec.DataDirHostPath, c.Spec.DataVolumeSize, - edgefsv1alpha1.GetMgrPlacement(c.Spec.Placement), c.Spec.Network, c.Spec.Dashboard, + edgefsv1alpha1.GetMgrAnnotations(c.Spec.Annotations), edgefsv1alpha1.GetMgrPlacement(c.Spec.Placement), c.Spec.Network, c.Spec.Dashboard, v1.ResourceRequirements{}, c.Spec.ResourceProfile, c.ownerRef) err = c.mgrs.Start(rookImage) if err != nil { @@ -158,7 +159,7 @@ func (c *cluster) createInstance(rookImage string) error { func (c *cluster) prepareHostNodes(rookImage string, deploymentConfig edgefsv1alpha1.ClusterDeploymentConfig) error { - prep := prepare.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, + prep := prepare.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, edgefsv1alpha1.GetPrepareAnnotations(c.Spec.Annotations), edgefsv1alpha1.GetTargetPlacement(c.Spec.Placement), v1.ResourceRequirements{}, c.ownerRef) for nodeName, devicesConfig := range deploymentConfig.DevConfig { diff --git a/pkg/operator/edgefs/cluster/mgr/mgr.go b/pkg/operator/edgefs/cluster/mgr/mgr.go index ee1d06dd5..0c14f1780 100644 --- a/pkg/operator/edgefs/cluster/mgr/mgr.go +++ b/pkg/operator/edgefs/cluster/mgr/mgr.go @@ -46,8 +46,8 @@ const ( defaultRestPort = 8080 defaultRestSPort = 4443 defaultMetricsPort = 8881 - defaultUiPort = 3000 - defaultUiSPort = 3443 + defaultUIPort = 3000 + defaultUISPort = 3443 /* Volumes definitions */ dataVolumeName = "edgefs-datadir" @@ -63,6 +63,7 @@ type Cluster struct { Replicas int dataDirHostPath string dataVolumeSize resource.Quantity + annotations rookalpha.Annotations placement rookalpha.Placement context *clusterd.Context hostNetworkSpec edgefsv1alpha1.NetworkSpec @@ -78,6 +79,7 @@ func New( serviceAccount string, dataDirHostPath string, dataVolumeSize resource.Quantity, + annotations rookalpha.Annotations, placement rookalpha.Placement, hostNetworkSpec edgefsv1alpha1.NetworkSpec, dashboardSpec edgefsv1alpha1.DashboardSpec, @@ -96,6 +98,7 @@ func New( context: context, Namespace: namespace, serviceAccount: serviceAccount, + annotations: annotations, placement: placement, Version: version, Replicas: 1, @@ -155,7 +158,7 @@ func (c *Cluster) Start(rookImage string) error { } // create the ui/dashboard service - uiService := c.makeUiService(uiSvcName) + uiService := c.makeUIService(uiSvcName) if _, err := c.context.Clientset.CoreV1().Services(c.Namespace).Create(uiService); err != nil { if !errors.IsAlreadyExists(err) { return fmt.Errorf("failed to create ui service. %+v", err) @@ -228,7 +231,7 @@ func (c *Cluster) makeRestapiService(name string) *v1.Service { return svc } -func (c *Cluster) makeUiService(name string) *v1.Service { +func (c *Cluster) makeUIService(name string) *v1.Service { labels := c.getLabels() svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -242,12 +245,12 @@ func (c *Cluster) makeUiService(name string) *v1.Service { Ports: []v1.ServicePort{ { Name: "http-ui", - Port: int32(defaultUiPort), + Port: int32(defaultUIPort), Protocol: v1.ProtocolTCP, }, { Name: "https-ui", - Port: int32(defaultUiSPort), + Port: int32(defaultUISPort), Protocol: v1.ProtocolTCP, }, }, @@ -310,8 +313,6 @@ func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas i ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: c.getDaemonLabels(clusterName), - Annotations: map[string]string{"prometheus.io/scrape": "true", - "prometheus.io/port": strconv.Itoa(defaultMetricsPort)}, }, Spec: v1.PodSpec{ ServiceAccountName: c.serviceAccount, @@ -327,6 +328,15 @@ func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas i if isHostNetworkDefined(c.hostNetworkSpec) { podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet } + // Add the prometheus.io scrape annoations by default when no annotations have been given. + if len(c.annotations) == 0 { + podSpec.ObjectMeta.Annotations = map[string]string{ + "prometheus.io/scrape": "true", + "prometheus.io/port": strconv.Itoa(defaultMetricsPort), + } + } else { + c.annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) + } c.placement.ApplyToPodSpec(&podSpec.Spec) d := &apps.Deployment{ @@ -343,6 +353,7 @@ func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas i }, } k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &d.ObjectMeta, &c.ownerRef) + c.annotations.ApplyToObjectMeta(&d.ObjectMeta) return d } @@ -383,12 +394,12 @@ func (c *Cluster) uiContainer(name string, containerImage string) v1.Container { Ports: []v1.ContainerPort{ { Name: "http-ui", - ContainerPort: int32(defaultUiPort), + ContainerPort: int32(defaultUIPort), Protocol: v1.ProtocolTCP, }, { Name: "https-ui", - ContainerPort: int32(defaultUiSPort), + ContainerPort: int32(defaultUISPort), Protocol: v1.ProtocolTCP, }, }, diff --git a/pkg/operator/edgefs/cluster/mgr/mgr_test.go b/pkg/operator/edgefs/cluster/mgr/mgr_test.go index 62a3f6767..57e84cc4f 100644 --- a/pkg/operator/edgefs/cluster/mgr/mgr_test.go +++ b/pkg/operator/edgefs/cluster/mgr/mgr_test.go @@ -46,7 +46,7 @@ func TestStartMGR(t *testing.T) { ConfigDir: configDir, Clientset: testop.New(3)} volSize := resource.NewQuantity(100000.0, resource.BinarySI) - c := New(context, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, + c := New(context, "ns", "myversion", "", "", *volSize, rookalpha.Annotations{}, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, "", metav1.OwnerReference{}) // start a basic service @@ -72,8 +72,8 @@ func validateStart(t *testing.T, c *Cluster) { func TestPodSpec(t *testing.T) { volSize := resource.NewQuantity(100000.0, resource.BinarySI) - c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "rook/rook:myversion", "", "", *volSize, rookalpha.Placement{}, - edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{ + c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "rook/rook:myversion", "", "", *volSize, rookalpha.Annotations{}, + rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{ Limits: v1.ResourceList{ v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI), }, @@ -114,9 +114,8 @@ func TestPodSpec(t *testing.T) { func TestServiceSpec(t *testing.T) { volSize := resource.NewQuantity(100000.0, resource.BinarySI) - c := New(&clusterd.Context{}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, - edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, - "", metav1.OwnerReference{}) + c := New(&clusterd.Context{}, "ns", "myversion", "", "", *volSize, rookalpha.Annotations{}, rookalpha.Placement{}, + edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, "", metav1.OwnerReference{}) s := c.makeMgrService("rook-edgefs-mgr") assert.NotNil(t, s) @@ -126,9 +125,8 @@ func TestServiceSpec(t *testing.T) { func TestHostNetwork(t *testing.T) { volSize := resource.NewQuantity(100000.0, resource.BinarySI) - c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, - edgefsv1alpha1.NetworkSpec{ServerIfName: "eth0"}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, - "", metav1.OwnerReference{}) + c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "myversion", "", "", *volSize, rookalpha.Annotations{}, rookalpha.Placement{}, + edgefsv1alpha1.NetworkSpec{ServerIfName: "eth0"}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, "", metav1.OwnerReference{}) d := c.makeDeployment("mgr-a", "a", "edgefs", 1) assert.NotNil(t, d) diff --git a/pkg/operator/edgefs/cluster/prepare/prepare.go b/pkg/operator/edgefs/cluster/prepare/prepare.go index dcc2c7dda..cb4797ffe 100644 --- a/pkg/operator/edgefs/cluster/prepare/prepare.go +++ b/pkg/operator/edgefs/cluster/prepare/prepare.go @@ -45,6 +45,7 @@ type Cluster struct { Namespace string Version string serviceAccount string + annotations rookalpha.Annotations placement rookalpha.Placement context *clusterd.Context resources v1.ResourceRequirements @@ -56,6 +57,7 @@ type Cluster struct { func New( context *clusterd.Context, namespace, version string, serviceAccount string, + annotations rookalpha.Annotations, placement rookalpha.Placement, resources v1.ResourceRequirements, ownerRef metav1.OwnerReference, @@ -71,6 +73,7 @@ func New( context: context, Namespace: namespace, serviceAccount: serviceAccount, + annotations: annotations, placement: placement, Version: version, resources: resources, diff --git a/pkg/operator/edgefs/cluster/target/pod.go b/pkg/operator/edgefs/cluster/target/pod.go index 8763d630e..f28e29df5 100644 --- a/pkg/operator/edgefs/cluster/target/pod.go +++ b/pkg/operator/edgefs/cluster/target/pod.go @@ -442,6 +442,8 @@ func (c *Cluster) makeStatefulSet(replicas int32, rookImage string, dro edgefsv1 } k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &statefulSet.ObjectMeta, &c.ownerRef) + c.annotations.ApplyToObjectMeta(&statefulSet.ObjectMeta) + c.annotations.ApplyToObjectMeta(&statefulSet.Spec.Template.ObjectMeta) c.placement.ApplyToPodSpec(&statefulSet.Spec.Template.Spec) return statefulSet, nil diff --git a/pkg/operator/edgefs/cluster/target/pod_test.go b/pkg/operator/edgefs/cluster/target/pod_test.go index ad8ac9e85..e6cefecbb 100644 --- a/pkg/operator/edgefs/cluster/target/pod_test.go +++ b/pkg/operator/edgefs/cluster/target/pod_test.go @@ -65,7 +65,7 @@ func TestStorageSpecConfig(t *testing.T) { clientset := fake.NewSimpleClientset() deploymentConfig := edgefsv1alpha1.ClusterDeploymentConfig{} c := New(&clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "rook/rook:myversion", "", - storageSpec, "", *resource.NewQuantity(100000.0, resource.BinarySI), + storageSpec, "", *resource.NewQuantity(100000.0, resource.BinarySI), rookalpha.Annotations{}, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, v1.ResourceRequirements{}, "", *resource.NewQuantity(0.0, resource.BinarySI), metav1.OwnerReference{}, deploymentConfig) diff --git a/pkg/operator/edgefs/cluster/target/target.go b/pkg/operator/edgefs/cluster/target/target.go index 6ec65e583..fd64ba02a 100644 --- a/pkg/operator/edgefs/cluster/target/target.go +++ b/pkg/operator/edgefs/cluster/target/target.go @@ -51,6 +51,7 @@ const ( type Cluster struct { context *clusterd.Context Namespace string + annotations rookalpha.Annotations placement rookalpha.Placement Version string Storage rookalpha.StorageScopeSpec @@ -75,6 +76,7 @@ func New( storageSpec rookalpha.StorageScopeSpec, dataDirHostPath string, dataVolumeSize resource.Quantity, + annotations rookalpha.Annotations, placement rookalpha.Placement, hostNetworkSpec edgefsv1alpha1.NetworkSpec, resources v1.ResourceRequirements, @@ -93,6 +95,7 @@ func New( context: context, Namespace: namespace, serviceAccount: serviceAccount, + annotations: annotations, placement: placement, Version: version, Storage: storageSpec, diff --git a/pkg/operator/edgefs/iscsi/controller.go b/pkg/operator/edgefs/iscsi/controller.go index 322cb2623..20f58edd6 100644 --- a/pkg/operator/edgefs/iscsi/controller.go +++ b/pkg/operator/edgefs/iscsi/controller.go @@ -58,6 +58,7 @@ type ISCSIController struct { dataDirHostPath string dataVolumeSize resource.Quantity placement rookalpha.Placement + annotations rookalpha.Annotations resources v1.ResourceRequirements resourceProfile string ownerRef metav1.OwnerReference diff --git a/pkg/operator/edgefs/iscsi/iscsi.go b/pkg/operator/edgefs/iscsi/iscsi.go index 8064c5e2c..86c055c58 100644 --- a/pkg/operator/edgefs/iscsi/iscsi.go +++ b/pkg/operator/edgefs/iscsi/iscsi.go @@ -169,6 +169,7 @@ func (c *ISCSIController) makeDeployment(svcname, namespace, rookImage string, i podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet } + iscsiSpec.Annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) // apply current ISCSI CRD options to pod's specification iscsiSpec.Placement.ApplyToPodSpec(&podSpec.Spec) @@ -187,6 +188,8 @@ func (c *ISCSIController) makeDeployment(svcname, namespace, rookImage string, i }, } k8sutil.SetOwnerRef(c.context.Clientset, namespace, &d.ObjectMeta, &c.ownerRef) + iscsiSpec.Annotations.ApplyToObjectMeta(&d.ObjectMeta) + return d } diff --git a/pkg/operator/edgefs/isgw/controller.go b/pkg/operator/edgefs/isgw/controller.go index 2aed3e3c4..c7c31b153 100644 --- a/pkg/operator/edgefs/isgw/controller.go +++ b/pkg/operator/edgefs/isgw/controller.go @@ -57,6 +57,7 @@ type ISGWController struct { hostNetwork bool dataDirHostPath string dataVolumeSize resource.Quantity + annotations rookalpha.Annotations placement rookalpha.Placement resources v1.ResourceRequirements resourceProfile string diff --git a/pkg/operator/edgefs/nfs/controller.go b/pkg/operator/edgefs/nfs/controller.go index 4c4aeeb7e..11fba4f57 100644 --- a/pkg/operator/edgefs/nfs/controller.go +++ b/pkg/operator/edgefs/nfs/controller.go @@ -57,6 +57,7 @@ type NFSController struct { hostNetwork bool dataDirHostPath string dataVolumeSize resource.Quantity + annotations rookalpha.Annotations placement rookalpha.Placement resources v1.ResourceRequirements resourceProfile string diff --git a/pkg/operator/edgefs/nfs/nfs.go b/pkg/operator/edgefs/nfs/nfs.go index 1601c1117..1f48fcfdd 100644 --- a/pkg/operator/edgefs/nfs/nfs.go +++ b/pkg/operator/edgefs/nfs/nfs.go @@ -171,6 +171,7 @@ func (c *NFSController) makeDeployment(svcname, namespace, rookImage string, nfs if c.hostNetwork { podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet } + nfsSpec.Annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) // apply current NFS CRD options to pod's specification nfsSpec.Placement.ApplyToPodSpec(&podSpec.Spec) @@ -189,6 +190,7 @@ func (c *NFSController) makeDeployment(svcname, namespace, rookImage string, nfs }, } k8sutil.SetOwnerRef(c.context.Clientset, namespace, &d.ObjectMeta, &c.ownerRef) + nfsSpec.Annotations.ApplyToObjectMeta(&d.ObjectMeta) return d } diff --git a/pkg/operator/edgefs/s3/controller.go b/pkg/operator/edgefs/s3/controller.go index f43ae27d9..878edfff5 100644 --- a/pkg/operator/edgefs/s3/controller.go +++ b/pkg/operator/edgefs/s3/controller.go @@ -57,6 +57,7 @@ type S3Controller struct { hostNetwork bool dataDirHostPath string dataVolumeSize resource.Quantity + annotations rookalpha.Annotations placement rookalpha.Placement resources v1.ResourceRequirements resourceProfile string diff --git a/pkg/operator/edgefs/s3/s3.go b/pkg/operator/edgefs/s3/s3.go index d23a708ad..bfdec8b5a 100644 --- a/pkg/operator/edgefs/s3/s3.go +++ b/pkg/operator/edgefs/s3/s3.go @@ -225,6 +225,7 @@ func (c *S3Controller) makeDeployment(svcname, namespace, rookImage, imageArgs s // apply current S3 CRD options to pod's specification s3Spec.Placement.ApplyToPodSpec(&podSpec.Spec) + s3Spec.Annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) d := &apps.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -240,6 +241,7 @@ func (c *S3Controller) makeDeployment(svcname, namespace, rookImage, imageArgs s }, } k8sutil.SetOwnerRef(c.context.Clientset, namespace, &d.ObjectMeta, &c.ownerRef) + s3Spec.Annotations.ApplyToObjectMeta(&d.ObjectMeta) return d } diff --git a/pkg/operator/edgefs/s3x/controller.go b/pkg/operator/edgefs/s3x/controller.go index e0e6e8e9b..dcfdcdb42 100644 --- a/pkg/operator/edgefs/s3x/controller.go +++ b/pkg/operator/edgefs/s3x/controller.go @@ -57,6 +57,7 @@ type S3XController struct { hostNetwork bool dataDirHostPath string dataVolumeSize resource.Quantity + annotations rookalpha.Annotations placement rookalpha.Placement resources v1.ResourceRequirements resourceProfile string diff --git a/pkg/operator/edgefs/s3x/s3x.go b/pkg/operator/edgefs/s3x/s3x.go index ba8edb6de..1e14c0c12 100644 --- a/pkg/operator/edgefs/s3x/s3x.go +++ b/pkg/operator/edgefs/s3x/s3x.go @@ -198,6 +198,7 @@ func (c *S3XController) makeDeployment(svcname, namespace, rookImage string, s3x } // apply current S3X CRD options to pod's specification + s3xSpec.Annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) s3xSpec.Placement.ApplyToPodSpec(&podSpec.Spec) d := &apps.Deployment{ @@ -214,6 +215,7 @@ func (c *S3XController) makeDeployment(svcname, namespace, rookImage string, s3x }, } k8sutil.SetOwnerRef(c.context.Clientset, namespace, &d.ObjectMeta, &c.ownerRef) + s3xSpec.Annotations.ApplyToObjectMeta(&d.ObjectMeta) return d } diff --git a/pkg/operator/minio/controller.go b/pkg/operator/minio/controller.go index a484e2bd4..644c3d621 100644 --- a/pkg/operator/minio/controller.go +++ b/pkg/operator/minio/controller.go @@ -24,6 +24,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" miniov1alpha1 "github.com/rook/rook/pkg/apis/minio.rook.io/v1alpha1" + rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -141,7 +142,17 @@ func makeServerAddress(statefulSetPrefix, headlessServiceName, namespace, cluste return fmt.Sprintf("http://%s-%d.%s.%s%s", statefulSetPrefix, serverNum, headlessServiceName, dnsSuffix, pvcDataDir) } -func (c *Controller) makeMinioPodSpec(name, namespace string, ctrName string, ctrImage string, clusterDomain string, envVars map[string]string, numServers int32, volumeClaims []v1.PersistentVolumeClaim) v1.PodTemplateSpec { +func (c *Controller) makeMinioPodSpec( + name string, + namespace string, + ctrName string, + ctrImage string, + clusterDomain string, + envVars map[string]string, + numServers int32, + volumeClaims []v1.PersistentVolumeClaim, + annotations rookalpha.Annotations, +) v1.PodTemplateSpec { var env []v1.EnvVar for k, v := range envVars { env = append(env, v1.EnvVar{Name: k, Value: v}) @@ -217,6 +228,7 @@ func (c *Controller) makeMinioPodSpec(name, namespace string, ctrName string, ct Volumes: volumes, }, } + annotations.ApplyToObjectMeta(&podSpec.ObjectMeta) return podSpec } @@ -243,7 +255,7 @@ func validateObjectStoreSpec(spec miniov1alpha1.ObjectStoreSpec) error { return nil } -func (c *Controller) makeMinioStatefulSet(name, namespace string, spec miniov1alpha1.ObjectStoreSpec, ownerRef meta_v1.OwnerReference) (*apps.StatefulSet, error) { +func (c *Controller) makeMinioStatefulSet(name, namespace string, spec miniov1alpha1.ObjectStoreSpec, ownerRef meta_v1.OwnerReference, annotations rookalpha.Annotations) (*apps.StatefulSet, error) { accessKey, secretKey, err := c.getAccessCredentials(spec.Credentials.Name, spec.Credentials.Namespace) if err != nil { return nil, err @@ -254,7 +266,17 @@ func (c *Controller) makeMinioStatefulSet(name, namespace string, spec miniov1al "MINIO_SECRET_KEY": secretKey, } - podSpec := c.makeMinioPodSpec(name, namespace, minioCtrName, c.rookImage, spec.ClusterDomain, envVars, int32(spec.Storage.NodeCount), spec.Storage.VolumeClaimTemplates) + podSpec := c.makeMinioPodSpec( + name, + namespace, + minioCtrName, + c.rookImage, + spec.ClusterDomain, + envVars, + int32(spec.Storage.NodeCount), + spec.Storage.VolumeClaimTemplates, + spec.Annotations, + ) nodeCount := int32(spec.Storage.NodeCount) sts := &apps.StatefulSet{ @@ -273,6 +295,7 @@ func (c *Controller) makeMinioStatefulSet(name, namespace string, spec miniov1al ServiceName: name, }, } + annotations.ApplyToObjectMeta(&sts.ObjectMeta) k8sutil.SetOwnerRef(c.context.Clientset, namespace, &sts.ObjectMeta, &ownerRef) sts, err = c.context.Clientset.AppsV1().StatefulSets(namespace).Create(sts) if err != nil && !k8serrors.IsAlreadyExists(err) { @@ -314,7 +337,7 @@ func (c *Controller) onAdd(obj interface{}) { // Create the stateful set. logger.Infof("Creating/Updating Minio stateful set %s.", objectstore.Name) - _, err = c.makeMinioStatefulSet(objectstore.Name, objectstore.Namespace, objectstore.Spec, ownerRef) + _, err = c.makeMinioStatefulSet(objectstore.Name, objectstore.Namespace, objectstore.Spec, ownerRef, objectstore.Annotations) if err != nil { logger.Errorf(err.Error()) return diff --git a/pkg/operator/minio/controller_test.go b/pkg/operator/minio/controller_test.go index e40302bb6..d11e4c6b5 100644 --- a/pkg/operator/minio/controller_test.go +++ b/pkg/operator/minio/controller_test.go @@ -148,6 +148,10 @@ func TestSpecVerification(t *testing.T) { Namespace: namespace, }, Spec: miniov.ObjectStoreSpec{ + Annotations: map[string]string{ + "test123": "this is a test", + "rook.io": "this is a test", + }, Storage: rookalpha.StorageScopeSpec{ NodeCount: 6, Selection: rookalpha.Selection{ diff --git a/pkg/operator/nfs/controller.go b/pkg/operator/nfs/controller.go index 8ab4d98be..3a9d75e9d 100644 --- a/pkg/operator/nfs/controller.go +++ b/pkg/operator/nfs/controller.go @@ -386,6 +386,8 @@ func (c *Controller) createNfsStatefulSet(nfsServer *nfsServer, replicas int32) ServiceName: nfsServer.name, }, } + nfsServer.spec.Annotations.ApplyToObjectMeta(&statefulSet.Spec.Template.ObjectMeta) + nfsServer.spec.Annotations.ApplyToObjectMeta(&statefulSet.ObjectMeta) if _, err := appsClient.StatefulSets(nfsServer.namespace).Create(&statefulSet); err != nil { if !errors.IsAlreadyExists(err) {