Skip to content

Commit

Permalink
fix(operator): use configurable serviceAccount (#88)
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
  • Loading branch information
shubham14bajpai authored May 11, 2021
1 parent ab5dc61 commit 6347ad5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Jiva-Operator helm chart for Kubernetes
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 2.8.1
version: 2.8.2
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 2.8.0
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/charts/templates/jiva-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPENEBS_SERVICEACCOUNT_NAME
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
- name: OPERATOR_NAME
value: "jiva-operator"
- name: OPENEBS_SERVICEACCOUNT_NAME
Expand Down
4 changes: 4 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3302,6 +3302,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPENEBS_SERVICEACCOUNT_NAME
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
- name: OPERATOR_NAME
value: "jiva-operator"
- name: OPENEBS_IO_JIVA_CONTROLLER_IMAGE
Expand Down
7 changes: 4 additions & 3 deletions pkg/controllers/jivavolume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const (
pdbAPIVersion = "policyv1beta1"
defaultStorageClass = "openebs-hostpath"
defaultReplicationFactor = 3
jivaOperator = "jiva-operator"
)

type policyOptFuncs func(*openebsiov1alpha1.JivaVolumePolicySpec, openebsiov1alpha1.JivaVolumePolicySpec)
Expand All @@ -94,6 +93,8 @@ var (
}

updateErrMsg = "Failed to update JivaVolume with service info"

defaultServiceAccountName = os.Getenv("OPENEBS_SERVICEACCOUNT_NAME")
)

// +kubebuilder:rbac:groups=openebs.io.openebs.io,resources=jivavolumes,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -352,7 +353,7 @@ func createControllerDeployment(r *JivaVolumeReconciler, cr *openebsiov1alpha1.J
func() *pts.Builder {
ptsBuilder := pts.NewBuilder().
WithLabels(defaultControllerLabels(cr.Spec.PV)).
WithServiceAccountName(jivaOperator).
WithServiceAccountName(defaultServiceAccountName).
WithAnnotations(defaultAnnotations()).
WithTolerations(cr.Spec.Policy.Target.Tolerations...).
WithContainerBuilders(
Expand Down Expand Up @@ -583,7 +584,7 @@ func createReplicaStatefulSet(r *JivaVolumeReconciler, cr *openebsiov1alpha1.Jiv
func() *pts.Builder {
ptsBuilder := pts.NewBuilder().
WithLabels(defaultReplicaLabels(cr.Spec.PV)).
WithServiceAccountName(jivaOperator).
WithServiceAccountName(defaultServiceAccountName).
WithAffinity(&corev1.Affinity{
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
Expand Down

0 comments on commit 6347ad5

Please sign in to comment.