Skip to content

Commit

Permalink
fix(operator) Update JivaVolumePolicy parameter(monitor, enableBufio …
Browse files Browse the repository at this point in the history
…and autoScaling) (#130)

* Update port name for exporter
* Add pvc label in JivaVolume and jiva controller volume pod
* Update monitor to disableMonitor and removed unused enableBufio and autoScaling fields
* Generated manifests

Signed-off-by: Sahil Raja <sahilraja242@gmail.com>
  • Loading branch information
rajaSahil authored and kmova committed Aug 31, 2021
1 parent 1671ba5 commit 7239624
Show file tree
Hide file tree
Showing 10 changed files with 3,475 additions and 3,125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ cscope*
jiva-discussion
build/bin/*
vendor/*
*.idea
14 changes: 3 additions & 11 deletions deploy/crds/openebs.io_jivavolumepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ spec:
spec:
description: JivaVolumePolicySpec defines the desired state of JivaVolumePolicy
properties:
autoScaling:
description: AutoScaling ...
type: boolean
enableBufio:
description: EnableBufio ...
type: boolean
priorityClassName:
description: PriorityClassName if specified applies to the pod If
left empty, no priority class is applied.
Expand Down Expand Up @@ -1403,8 +1397,9 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
monitor:
description: Monitor enables or disables the target exporter sidecar
disableMonitor:
description: DisableMonitor will not attach prometheus exporter
sidecar to jiva volume target.
type: boolean
nodeSelector:
additionalProperties:
Expand Down Expand Up @@ -1485,9 +1480,6 @@ spec:
type: object
type: array
type: object
required:
- autoScaling
- enableBufio
type: object
status:
description: JivaVolumePolicyStatus is for handling status of JivaVolumePolicy
Expand Down
15 changes: 3 additions & 12 deletions deploy/crds/openebs.io_jivavolumes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ spec:
and replica pods during volume provisioning
nullable: true
properties:
autoScaling:
description: AutoScaling ...
type: boolean
enableBufio:
description: EnableBufio ...
type: boolean
priorityClassName:
description: PriorityClassName if specified applies to the pod
If left empty, no priority class is applied.
Expand Down Expand Up @@ -1503,9 +1497,9 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
monitor:
description: Monitor enables or disables the target exporter
sidecar
disableMonitor:
description: DisableMonitor will not attach prometheus exporter
sidecar to jiva volume target.
type: boolean
nodeSelector:
additionalProperties:
Expand Down Expand Up @@ -1588,9 +1582,6 @@ spec:
type: object
type: array
type: object
required:
- autoScaling
- enableBufio
type: object
pv:
type: string
Expand Down
6 changes: 2 additions & 4 deletions deploy/crds/openebs.io_v1alpha1_jivavolumepolicy_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ metadata:
namespace: openebs
spec:
replicaSC: openebs-hostpath
enableBufio: false
autoScaling: false
target:
# monitor: false
# disableMonitor: true
replicationFactor: 1
# auxResources:
# tolerations:
Expand All @@ -23,4 +21,4 @@ spec:
# nodeSelector:
# priorityClassName:
# status:
# phase:
# phase:
6,514 changes: 3,441 additions & 3,073 deletions deploy/operator.yaml

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ openebs-jiva-csi-node-h2unk 2/2 Running 0 6m20
namespace: openebs
spec:
replicaSC: openebs-hostpath
enableBufio: false
autoScaling: false
target:
replicationFactor: 1
# monitor: false
# disableMonitor: false
# auxResources:
# tolerations:
# resources:
Expand Down
8 changes: 2 additions & 6 deletions pkg/apis/openebs/v1alpha1/jivavolumepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ type JivaVolumePolicySpec struct {
// ReplicaSC represents the storage class used for
// creating the pvc for the replicas (provisioned by localpv provisioner)
ReplicaSC string `json:"replicaSC,omitempty"`
// EnableBufio ...
EnableBufio bool `json:"enableBufio"`
// AutoScaling ...
AutoScaling bool `json:"autoScaling"`
// ServiceAccountName can be provided to enable PSP
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// PriorityClassName if specified applies to the pod
Expand All @@ -48,8 +44,8 @@ type JivaVolumePolicySpec struct {

// TargetSpec represents configuration related to jiva target deployment
type TargetSpec struct {
// Monitor enables or disables the target exporter sidecar
Monitor bool `json:"monitor,omitempty"`
// DisableMonitor will not attach prometheus exporter sidecar to jiva volume target.
DisableMonitor bool `json:"disableMonitor,omitempty"`

// ReplicationFactor represents maximum number of replicas
// that are allowed to connect to the target
Expand Down
20 changes: 12 additions & 8 deletions pkg/controllers/jivavolume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const (
defaultStorageClass = "openebs-hostpath"
replicaAntiAffinityKey = "openebs.io/replica-anti-affinity"
defaultReplicationFactor = 3
defaultDisableMonitor = false
openebsPVC = "openebs.io/persistent-volume-claim"
)

type policyOptFuncs func(*openebsiov1alpha1.JivaVolumePolicySpec, openebsiov1alpha1.JivaVolumePolicySpec)
Expand Down Expand Up @@ -573,14 +575,14 @@ func createControllerDeployment(r *JivaVolumeReconciler, cr *openebsiov1alpha1.J

dep, err := deploy.NewBuilder().WithName(cr.Name + "-jiva-ctrl").
WithNamespace(cr.Namespace).
WithLabels(defaultControllerLabels(cr.Spec.PV)).
WithLabels(defaultControllerLabels(cr.Spec.PV, cr.GetLabels()[openebsPVC])).
WithReplicas(&reps).
WithStrategyType(appsv1.RecreateDeploymentStrategyType).
WithSelectorMatchLabelsNew(defaultControllerMatchLabels(cr.Spec.PV)).
WithSelectorMatchLabelsNew(defaultControllerMatchLabels(cr.Spec.PV, cr.GetLabels()[openebsPVC])).
WithPodTemplateSpecBuilder(
func() *pts.Builder {
ptsBuilder := pts.NewBuilder().
WithLabels(defaultControllerLabels(cr.Spec.PV)).
WithLabels(defaultControllerLabels(cr.Spec.PV, cr.GetLabels()[openebsPVC])).
WithServiceAccountName(defaultServiceAccountName).
WithAnnotations(defaultAnnotations()).
WithTolerations(cr.Spec.Policy.Target.Tolerations...).
Expand Down Expand Up @@ -610,7 +612,7 @@ func createControllerDeployment(r *JivaVolumeReconciler, cr *openebsiov1alpha1.J
WithResources(cr.Spec.Policy.Target.Resources).
WithImagePullPolicy(corev1.PullIfNotPresent),
)
if cr.Spec.Policy.Target.Monitor {
if !cr.Spec.Policy.Target.DisableMonitor {
ptsBuilder = ptsBuilder.WithContainerBuilders(
container.NewBuilder().
WithImage(getImage("OPENEBS_IO_MAYA_EXPORTER_IMAGE",
Expand Down Expand Up @@ -697,17 +699,18 @@ func defaultReplicaMatchLabels(pv string) map[string]string {
}
}

func defaultControllerLabels(pv string) map[string]string {
labels := defaultControllerMatchLabels(pv)
func defaultControllerLabels(pv string, pvc string) map[string]string {
labels := defaultControllerMatchLabels(pv, pvc)
labels["openebs.io/version"] = version.Version
return labels
}

func defaultControllerMatchLabels(pv string) map[string]string {
func defaultControllerMatchLabels(pv string, pvc string) map[string]string {
return map[string]string{
"openebs.io/cas-type": "jiva",
"openebs.io/component": "jiva-controller",
"openebs.io/persistent-volume": pv,
openebsPVC: pvc,
}
}

Expand Down Expand Up @@ -746,7 +749,7 @@ func defaultControllerSVCPorts() []corev1.ServicePort {
TargetPort: intstr.IntOrString{IntVal: 9501},
},
{
Name: "m-exporter",
Name: "exporter",
Port: 9500,
Protocol: "TCP",
TargetPort: intstr.IntOrString{IntVal: 9500},
Expand Down Expand Up @@ -1088,6 +1091,7 @@ func getDefaultPolicySpec() openebsiov1alpha1.JivaVolumePolicySpec {
},
},
ReplicationFactor: defaultReplicationFactor,
DisableMonitor: defaultDisableMonitor,
},
Replica: openebsiov1alpha1.ReplicaSpec{
PodTemplateResources: openebsiov1alpha1.PodTemplateResources{
Expand Down
14 changes: 9 additions & 5 deletions pkg/kubernetes/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ func (cl *Client) UpdateJivaVolume(cr *jv.JivaVolume) (bool, error) {
return false, nil
}

func getDefaultLabels(pv string) map[string]string {
return map[string]string{
func getDefaultLabels(pv string, pvc string) map[string]string {
defaultLabels := map[string]string{
"openebs.io/persistent-volume": pv,
"openebs.io/component": "jiva-volume",
}
if pvc != "" {
defaultLabels["openebs.io/persistent-volume-claim"] = pvc
}
return defaultLabels
}

func getdefaultAnnotations(policy string) map[string]string {
Expand Down Expand Up @@ -183,7 +187,7 @@ func (cl *Client) CreateJivaVolume(req *csi.CreateVolumeRequest) (string, error)
jiva := jivavolume.New().WithKindAndAPIVersion("JivaVolume", "openebs.io/v1alpha1").
WithNameAndNamespace(name, ns).
WithAnnotations(getdefaultAnnotations(policyName)).
WithLabels(getDefaultLabels(name)).
WithLabels(getDefaultLabels(name, pvcName)).
WithPV(name).
WithCapacity(capacity).
WithAccessType(accessType).
Expand Down Expand Up @@ -220,7 +224,7 @@ func (cl *Client) ListJivaVolume(volumeID string) (*jv.JivaVolumeList, error) {
volumeID = utils.StripName(volumeID)
obj := &jv.JivaVolumeList{}
opts := []client.ListOption{
client.MatchingLabels(getDefaultLabels(volumeID)),
client.MatchingLabels(getDefaultLabels(volumeID, "")),
}

if err := cl.client.List(context.TODO(), obj, opts...); err != nil {
Expand Down Expand Up @@ -296,7 +300,7 @@ func GetOpenEBSNamespace() string {
return openebsNamespace
}

// sendEventOrIgnore sends anonymous cstor provision/delete events
// sendEventOrIgnore sends anonymous jiva provision/delete events
func SendEventOrIgnore(pvcName, pvName, capacity, replicaCount, stgType, method string) {
if env.Truthy(analytics.OpenEBSEnableAnalytics) {
analytics.New().Build().ApplicationBuilder().
Expand Down
4 changes: 1 addition & 3 deletions tests/yamls.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ metadata:
namespace: openebs
spec:
replicaSC: openebs-hostpath
enableBufio: false
autoScaling: false
target:
# monitor: false
# disableMonitor: true
replicationFactor: 1
# auxResources:
# tolerations:
Expand Down

0 comments on commit 7239624

Please sign in to comment.