Skip to content

Commit

Permalink
ceph: make provisioner replicas configurable
Browse files Browse the repository at this point in the history
added new option to set the provisioner replicas.
with this new option the user/admin can choose
how many replicas he want for provisioner pod if
number of nodes is greater than 1.

fixes #8153

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Sep 22, 2021
1 parent 6bcb569 commit ed5f281
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions Documentation/helm-operator.md
Expand Up @@ -108,6 +108,7 @@ The following tables lists the configurable parameters of the rook-operator char
| `csi.rbdFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the RBD PVC is being mounted | ReadWriteOnceWithFSType |
| `csi.cephFSFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the CephFS PVC is being mounted | `None` |
| `csi.logLevel` | Set logging level for csi containers. Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. | `0` |
| `csi.provisionerReplicas` | Set replicas for csi provisioner deployment. | `2` |
| `csi.enableGrpcMetrics` | Enable Ceph CSI GRPC Metrics. | `false` |
| `csi.enableCSIHostNetwork` | Enable Host Networking for Ceph CSI nodeplugins. | `false` |
| `csi.provisionerTolerations` | Array of tolerations in YAML format which will be added to CSI provisioner deployment. | <none> |
Expand Down
4 changes: 4 additions & 0 deletions cluster/charts/rook-ceph/templates/deployment.yaml
Expand Up @@ -275,6 +275,10 @@ spec:
- name: CSI_LOG_LEVEL
value: {{ .Values.csi.logLevel | quote }}
{{- end }}
{{- if .Values.csi.provisionerReplicas }}
- name: CSI_PROVISIONER_REPLICAS
value: {{ .Values.csi.provisionerReplicas | quote }}
{{- end }}
{{- if .Values.csi.csiRBDProvisionerResource }}
- name: CSI_RBD_PROVISIONER_RESOURCE
value: {{ .Values.csi.csiRBDProvisionerResource | quote }}
Expand Down
3 changes: 3 additions & 0 deletions cluster/charts/rook-ceph/values.yaml
Expand Up @@ -87,6 +87,9 @@ csi:
# sidecar with CSI provisioner pod, to enable set it to true.
enableOMAPGenerator: false

# Set replicas for csi provisioner deployment.
provisionerReplicas: 2

# Set logging level for csi containers.
# Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity.
#logLevel: 0
Expand Down
3 changes: 3 additions & 0 deletions cluster/examples/kubernetes/ceph/operator-openshift.yaml
Expand Up @@ -120,6 +120,9 @@ data:
# Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity.
# CSI_LOG_LEVEL: "0"

# Set replicas for csi provisioner deployment.
CSI_PROVISIONER_REPLICAS: "2"

# OMAP generator generates the omap mapping between the PV name and the RBD image
# which helps CSI to identify the rbd images for CSI operations.
# CSI_ENABLE_OMAP_GENERATOR need to be enabled when we are using rbd mirroring feature.
Expand Down
3 changes: 3 additions & 0 deletions cluster/examples/kubernetes/ceph/operator.yaml
Expand Up @@ -41,6 +41,9 @@ data:
# Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity.
# CSI_LOG_LEVEL: "0"

# Set replicas for csi provisioner deployment.
CSI_PROVISIONER_REPLICAS: "2"

# OMAP generator will generate the omap mapping between the PV name and the RBD image.
# CSI_ENABLE_OMAP_GENERATOR need to be enabled when we are using rbd mirroring feature.
# By default OMAP generator sidecar is deployed with CSI provisioner pod, to disable
Expand Down
17 changes: 14 additions & 3 deletions pkg/operator/ceph/csi/spec.go
Expand Up @@ -61,7 +61,7 @@ type Param struct {
CephFSLivenessMetricsPort uint16
RBDGRPCMetricsPort uint16
RBDLivenessMetricsPort uint16
ProvisionerReplicas uint8
ProvisionerReplicas int32
CSICephFSPodLabels map[string]string
CSIRBDPodLabels map[string]string
}
Expand Down Expand Up @@ -169,6 +169,9 @@ const (
// default log level for csi containers
defaultLogLevel uint8 = 0

// default provisioner replicas
defaultProvisionerReplicas int32 = 2

// update strategy
rollingUpdate = "RollingUpdate"
onDelete = "OnDelete"
Expand Down Expand Up @@ -345,14 +348,22 @@ func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerI
}
}

tp.ProvisionerReplicas = 2
tp.ProvisionerReplicas = defaultProvisionerReplicas
nodes, err := r.context.Clientset.CoreV1().Nodes().List(r.opManagerContext, metav1.ListOptions{})
if err == nil {
if len(nodes.Items) == 1 {
tp.ProvisionerReplicas = 1
} else {
replicas := k8sutil.GetValue(r.opConfig.Parameters, "CSI_PROVISIONER_REPLICAS", "2")
r, err := strconv.ParseInt(replicas, 10, 32)
if err != nil {
logger.Errorf("failed to parse CSI_PROVISIONER_REPLICAS. Defaulting to %d. %v", defaultProvisionerReplicas, err)
} else {
tp.ProvisionerReplicas = int32(r)
}
}
} else {
logger.Errorf("failed to get nodes. Defaulting the number of replicas of provisioner pods to 2. %v", err)
logger.Errorf("failed to get nodes. Defaulting the number of replicas of provisioner pods to %d. %v", tp.ProvisionerReplicas, err)
}

if EnableRBD {
Expand Down

0 comments on commit ed5f281

Please sign in to comment.