Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(operator): make openebs service account configurable for pool and volume deployments #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions deploy/cstor-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: OPENEBS_SERVICEACCOUNT_NAME
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
- name: CSPC_OPERATOR_POD_NAME
valueFrom:
fieldRef:
Expand Down Expand Up @@ -100,10 +104,54 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: OPENEBS_SERVICEACCOUNT_NAME
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
- name: OPENEBS_IO_CSTOR_TARGET_IMAGE
value: "openebs/cstor-istgt:ci"
- name: OPENEBS_IO_CSTOR_VOLUME_MGMT_IMAGE
value: "openebs/cstor-volume-manager:ci"
- name: OPENEBS_IO_VOLUME_MONITOR_IMAGE
value: "openebs/m-exporter:ci"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: openebs-admission-server
namespace: openebs
labels:
app: admission-webhook
openebs.io/component-name: admission-webhook
openebs.io/version: dev
spec:
replicas: 1
strategy:
type: Recreate
rollingUpdate: null
selector:
matchLabels:
app: admission-webhook
template:
metadata:
labels:
app: admission-webhook
openebs.io/component-name: admission-webhook
openebs.io/version: dev
spec:
serviceAccountName: openebs-cstor-operator
containers:
- name: admission-webhook
image: openebs/cstor-webhook:ci
imagePullPolicy: IfNotPresent
args:
- -alsologtostderr
- -v=2
- 2>&1
env:
- name: OPENEBS_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: ADMISSION_WEBHOOK_NAME
value: "openebs-admission-server"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/openebs/api v0.0.0-20200323064123-2d2469b66b89
github.com/openebs/api v0.0.0-20200326054827-2ee96e0c8a89
github.com/openebs/maya v0.0.0-20200226142318-6daf5f0486e8
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ github.com/openebs/api v0.0.0-20200319173602-da787ed9fcbf h1:QGAdLxow+WVfxTOxeli
github.com/openebs/api v0.0.0-20200319173602-da787ed9fcbf/go.mod h1:Mj6izkLZT0jNKLs9u1CnbgNoP9BEgY/mgVI7Mc3/Hwc=
github.com/openebs/api v0.0.0-20200323064123-2d2469b66b89 h1:pSg7KAxeRvDuWZpUCIkuKBYpV2z75eSGzU/YXwGyo8U=
github.com/openebs/api v0.0.0-20200323064123-2d2469b66b89/go.mod h1:Mj6izkLZT0jNKLs9u1CnbgNoP9BEgY/mgVI7Mc3/Hwc=
github.com/openebs/api v0.0.0-20200326054827-2ee96e0c8a89 h1:h2JDrM+wq9nEXeK9kACN3zjUyVxmfcCvLfWnfo1I6+E=
github.com/openebs/api v0.0.0-20200326054827-2ee96e0c8a89/go.mod h1:Mj6izkLZT0jNKLs9u1CnbgNoP9BEgY/mgVI7Mc3/Hwc=
github.com/openebs/maya v0.0.0-20200226142318-6daf5f0486e8 h1:ud86nr1TRU9fB3IeBzymBqYjaha/GjgjHCTeFTKeT8A=
github.com/openebs/maya v0.0.0-20200226142318-6daf5f0486e8/go.mod h1:QQY9cOHKQwZ73qbv6O//UYUBLNV2S0MRDIfG7t5KOCk=
github.com/openebs/maya v0.0.0-20200305100821-7118ad163bb4 h1:beXxZA3gQlP+r1mtNKfmdVjhs6NA5O3IXpNMoMoQXSY=
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"testing"
"time"

"github.com/openebs/cstor-operators/pkg/pool"
apis "github.com/openebs/api/pkg/apis/cstor/v1"
"k8s.io/klog"
openebsFakeClientset "github.com/openebs/api/pkg/client/clientset/versioned/fake"
"github.com/openebs/cstor-operators/pkg/pool"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
)

// TestCheckForCStorVolumeReplicaCRD validates if CStorVolumeReplica CRD
Expand Down
20 changes: 10 additions & 10 deletions pkg/controllers/cspc-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
types "github.com/openebs/api/pkg/apis/types"
clientset "github.com/openebs/api/pkg/client/clientset/versioned"
openebsScheme "github.com/openebs/api/pkg/client/clientset/versioned/scheme"
cstorstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/cstor/v1"
openebsstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/openebs.io/v1alpha1"
informers "github.com/openebs/api/pkg/client/informers/externalversions"
listers "github.com/openebs/api/pkg/client/listers/cstor/v1"
v1interface "github.com/openebs/api/pkg/client/informers/externalversions/cstor/v1"
listers "github.com/openebs/api/pkg/client/listers/cstor/v1"
corev1 "k8s.io/api/core/v1"
cstorstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/cstor/v1"
openebsstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/openebs.io/v1alpha1"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -165,9 +165,9 @@ func (cb *ControllerBuilder) WithEventHandler(InformerFactory informers.SharedIn
return cb
}

func (cb *ControllerBuilder)withDefaults() {
cb.Controller.syncHandler=cb.Controller.syncCSPC
cb.Controller.enqueueCSPC=cb.Controller.enqueue
func (cb *ControllerBuilder) withDefaults() {
cb.Controller.syncHandler = cb.Controller.syncCSPC
cb.Controller.enqueueCSPC = cb.Controller.enqueue
}

// Build returns a controller instance.
Expand Down Expand Up @@ -235,18 +235,18 @@ func (c *Controller) deleteCSPC(obj interface{}) {
c.enqueueCSPC(cspc)
}

func GetVersionedCSPCInterface(cspcInformerFactory informers.SharedInformerFactory) v1interface.Interface{
func GetVersionedCSPCInterface(cspcInformerFactory informers.SharedInformerFactory) v1interface.Interface {
return cspcInformerFactory.Cstor().V1()
}

func GetStoredCSPIVersionInterface(cspiInformerFactory informers.SharedInformerFactory) v1interface.Interface{
func GetStoredCSPIVersionInterface(cspiInformerFactory informers.SharedInformerFactory) v1interface.Interface {
return cspiInformerFactory.Cstor().V1()
}

func (c *Controller)GetStoredCStorVersionClient() cstorstoredversion.CstorV1Interface {
func (c *Controller) GetStoredCStorVersionClient() cstorstoredversion.CstorV1Interface {
return c.clientset.CstorV1()
}

func (c *Controller)GetStoredOpenebsVersionClient() openebsstoredversion.OpenebsV1alpha1Interface {
func (c *Controller) GetStoredOpenebsVersionClient() openebsstoredversion.OpenebsV1alpha1Interface {
return c.clientset.OpenebsV1alpha1()
}
2 changes: 1 addition & 1 deletion pkg/controllers/cspc-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (c *Controller) GetCSPIListForCSPC(cspc *cstor.CStorPoolCluster) (*cstor.CS
return c.clientset.CstorV1().
CStorPoolInstances(cspc.Namespace).
List(metav1.
ListOptions{
ListOptions{
LabelSelector: types.CStorPoolClusterLabelKey + "=" + cspc.Name,
})
}
5 changes: 1 addition & 4 deletions pkg/controllers/cstorvolumeclaim/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ var (
MountPath: "/var/openebs/cstor-target",
},
}
// OpenEBSServiceAccount name of the openebs service accout with required
// permissions
OpenEBSServiceAccount = "openebs-maya-operator"
// TargetContainerName is the name of cstor target container name
TargetContainerName = "cstor-istgt"
// MonitorContainerName is the name of monitor container name
Expand Down Expand Up @@ -343,7 +340,7 @@ func (c *CVCController) getOrCreateCStorTargetDeployment(
apicore.NewPodTemplateSpec().
WithLabelsNew(getDeployTemplateLabels(vol.Name)).
WithAnnotationsNew(getDeployTemplateAnnotations()).
WithServiceAccountName(OpenEBSServiceAccount).
WithServiceAccountName(util.GetServiceAccountName()).
// TODO use of affinity
//WithAffinity(getDeployTemplateAffinity()).
WithPriorityClassName(getPriorityClass(policy)).
Expand Down
7 changes: 2 additions & 5 deletions pkg/cspc/algorithm/build_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// OpenEBSServiceAccount name of the openebs service accout with required
// permissions
const (
OpenEBSServiceAccount = "openebs-maya-operator"
// PoolMgmtContainerName is the name of cstor target container name
PoolMgmtContainerName = "cstor-pool-mgmt"

Expand Down Expand Up @@ -94,7 +91,7 @@ func (c *Config) GetPoolDeploySpec(cspi *cstor.CStorPoolInstance) *appsv1.Deploy
WithPriorityClassName(getPriorityClass(cspi)).
WithNodeSelector(cspi.Spec.NodeSelector).
WithAnnotationsNew(getPodAnnotations()).
WithServiceAccountName(OpenEBSServiceAccount).
WithServiceAccountName(util.GetServiceAccountName()).
WithTolerations(getPoolPodToleration(cspi)...).
WithContainers(
coreapi.NewContainer().
Expand Down Expand Up @@ -399,7 +396,7 @@ func getPoolPodToleration(cspi *cstor.CStorPoolInstance) []corev1.Toleration {
}

func getPriorityClass(cspi *cstor.CStorPoolInstance) string {
if cspi.Spec.PoolConfig.PriorityClassName==nil{
if cspi.Spec.PoolConfig.PriorityClassName == nil {
return ""
}
return *cspi.Spec.PoolConfig.PriorityClassName
Expand Down
16 changes: 8 additions & 8 deletions pkg/cspc/algorithm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package algorithm

import (
"github.com/pkg/errors"
cstor "github.com/openebs/api/pkg/apis/cstor/v1"
clientset "github.com/openebs/api/pkg/client/clientset/versioned"
openebsstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/openebs.io/v1alpha1"
cstorstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/cstor/v1"
cstor "github.com/openebs/api/pkg/apis/cstor/v1"
openebsstoredversion "github.com/openebs/api/pkg/client/clientset/versioned/typed/openebs.io/v1alpha1"
"github.com/pkg/errors"
"k8s.io/client-go/kubernetes"
)

Expand Down Expand Up @@ -57,7 +57,7 @@ type Builder struct {
}

// NewBuilder returns an empty instance of Builder object
// ToDo: Add openebs and kube client set
// ToDo: Add openebs and kube client set
func NewBuilder() *Builder {
return &Builder{
ConfigObj: &Config{
Expand Down Expand Up @@ -93,7 +93,7 @@ func (b *Builder) WithOpenEBSClient(oc clientset.Interface) *Builder {

// WithKubeClient sets the kubeclientset field of config object with provided value.
func (b *Builder) WithKubeClient(kc kubernetes.Interface) *Builder {
b.ConfigObj.kubeclientset=kc
b.ConfigObj.kubeclientset = kc
return b
}

Expand All @@ -115,10 +115,10 @@ func (b *Builder) Build() (*Config, error) {
return b.ConfigObj, nil
}

func (ac *Config)GetStoredOpenEBSVersionClient() openebsstoredversion.OpenebsV1alpha1Interface {
func (ac *Config) GetStoredOpenEBSVersionClient() openebsstoredversion.OpenebsV1alpha1Interface {
return ac.clientset.OpenebsV1alpha1()
}

func (ac *Config)GetStoredCStorVersionClient() cstorstoredversion.CstorV1Interface {
func (ac *Config) GetStoredCStorVersionClient() cstorstoredversion.CstorV1Interface {
return ac.clientset.CstorV1()
}
}
2 changes: 1 addition & 1 deletion pkg/pool/operations/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha2

import (
clientset "github.com/openebs/api/pkg/client/clientset/versioned"
clientset "github.com/openebs/api/pkg/client/clientset/versioned"
"k8s.io/client-go/kubernetes"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/pool/operations/pool_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"strings"
"testing"

ndmapis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1"
cstor "github.com/openebs/api/pkg/apis/cstor/v1"
ndmapis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1"
zpool "github.com/openebs/api/pkg/internalapis/apis/cstor"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/zcmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
vsnapshotsend "github.com/openebs/cstor-operators/pkg/zcmd/zfs/send"
vset "github.com/openebs/cstor-operators/pkg/zcmd/zfs/set"
vsnapshot "github.com/openebs/cstor-operators/pkg/zcmd/zfs/snapshot"

padd "github.com/openebs/cstor-operators/pkg/zcmd/zpool/add"
pattach "github.com/openebs/cstor-operators/pkg/zcmd/zpool/attach"
pclear "github.com/openebs/cstor-operators/pkg/zcmd/zpool/clear"
Expand Down
6 changes: 3 additions & 3 deletions pkg/zcmd/zpool/dump/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package pstatus
import (
"encoding/json"
"fmt"
vdump "github.com/openebs/api/pkg/internalapis/apis/cstor"
"github.com/openebs/cstor-operators/pkg/zcmd/bin"
"github.com/pkg/errors"
"os/exec"
"reflect"
"runtime"
"strings"
vdump "github.com/openebs/api/pkg/internalapis/apis/cstor"
"github.com/openebs/cstor-operators/pkg/zcmd/bin"
"github.com/pkg/errors"
)

const (
Expand Down