Skip to content

Commit

Permalink
refact(cvc): add pvc label in volume target deployments (#125)
Browse files Browse the repository at this point in the history
commit add the persistentvolumeclaim label
"openebs.io/persistent-volume-claim" in volume target
deployments while volume provisioning

Signed-off-by: prateekpandey14 <[email protected]>
(cherry picked from commit 82435a2)

Co-authored-by: prateekpandey14 <[email protected]>
  • Loading branch information
kmova and prateekpandey14 authored Jul 11, 2020
1 parent 50d3396 commit 2a83528
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/controllers/cstorvolumeconfig/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ var (
MgmtContainerName = "cstor-volume-mgmt"
)

func getDeployLabels(pvName string) map[string]string {
func getDeployLabels(pvName, pvcName string) map[string]string {
return map[string]string{
"app": "cstor-volume-manager",
"openebs.io/target": "cstor-target",
"openebs.io/storage-engine-type": "cstor",
"openebs.io/cas-type": "cstor",
"openebs.io/persistent-volume": pvName,
openebsPVC: pvcName,
"openebs.io/version": version.GetVersion(),
}
}
Expand All @@ -102,12 +103,13 @@ func getDeployMatchLabels(pvName string) map[string]string {
}
}

func getDeployTemplateLabels(pvName string) map[string]string {
func getDeployTemplateLabels(pvName, pvcName string) map[string]string {
return map[string]string{
"monitoring": "volume_exporter_prometheus",
"app": "cstor-volume-manager",
"openebs.io/target": "cstor-target",
"openebs.io/persistent-volume": pvName,
openebsPVC: pvcName,
"openebs.io/version": version.GetVersion(),
}
}
Expand Down Expand Up @@ -374,7 +376,7 @@ func (c *CVCController) BuildTargetDeployment(

deployObj := deploy.NewDeployment().
WithName(vol.Name + "-target").
WithLabelsNew(getDeployLabels(vol.Name)).
WithLabelsNew(getDeployLabels(vol.Name, vol.GetLabels()[openebsPVC])).
WithAnnotationsNew(getDeployAnnotation()).
WithOwnerReferenceNew(getDeployOwnerReference(vol)).
WithReplicas(&deployreplicas).
Expand All @@ -384,7 +386,7 @@ func (c *CVCController) BuildTargetDeployment(
WithSelectorMatchLabelsNew(getDeployMatchLabels(vol.Name)).
WithPodTemplateSpec(
apicore.NewPodTemplateSpec().
WithLabelsNew(getDeployTemplateLabels(vol.Name)).
WithLabelsNew(getDeployTemplateLabels(vol.Name, vol.GetLabels()[openebsPVC])).
WithAnnotationsNew(getDeployTemplateAnnotations()).
WithServiceAccountName(util.GetServiceAccountName()).
WithAffinity(getTargetTemplateAffinity(policySpec)).
Expand Down
3 changes: 3 additions & 0 deletions pkg/controllers/cstorvolumeconfig/volume_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const (
// pvSelector is the selector key for cstorvolumereplica belongs to a cstor
// volume
pvSelector = "openebs.io/persistent-volume"
// openebsPVC represents the persistentvoolumeclaim name
openebsPVC = "openebs.io/persistent-volume-claim"
// minHAReplicaCount is minimum no.of replicas are required to decide
// HighAvailable volume
minHAReplicaCount = 3
Expand Down Expand Up @@ -168,6 +170,7 @@ func getCVLabels(claim *apis.CStorVolumeConfig) map[string]string {
return map[string]string{
"openebs.io/persistent-volume": claim.Name,
"openebs.io/version": version.GetVersion(),
openebsPVC: claim.GetAnnotations()[openebsPVC],
}
}

Expand Down

0 comments on commit 2a83528

Please sign in to comment.