Skip to content

Commit

Permalink
fix(operator): use configurable serviceAccount (#89)
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubham14bajpai committed May 11, 2021
1 parent 57a9410 commit 8cc80b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 @@ -80,7 +80,6 @@ const (
pdbAPIVersion = "policyv1beta1"
defaultStorageClass = "openebs-hostpath"
defaultReplicationFactor = 3
jivaOperator = "jiva-operator"
)

type policyOptFuncs func(*openebsiov1alpha1.JivaVolumePolicySpec, openebsiov1alpha1.JivaVolumePolicySpec)
Expand All @@ -95,6 +94,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 @@ -353,7 +354,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 @@ -584,7 +585,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 8cc80b5

Please sign in to comment.