Skip to content

Commit

Permalink
Create the sa role rolebinding automately (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobolity authored Sep 27, 2022
1 parent 6e811fa commit 53a75e4
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 16 deletions.
2 changes: 0 additions & 2 deletions api/v1alpha1/dsalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ type DSAlertSpec struct {
// +kubebuilder:default=apache/dolphinscheduler-master
Repository string `json:"repository,omitempty"`

ServiceAccount string `json:"service_account,omitempty"`

// Replicas is the expected size of the ms-master.
// The ds-master-operator will eventually make the size of the running
// equal to the expected size.
Expand Down
2 changes: 0 additions & 2 deletions api/v1alpha1/dsapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ type DSApiSpec struct {

ZookeeperConnect string `json:"zookeeper_connect,omitempty"`

ServiceAccount string `json:"service_account,omitempty"`

// Repository is the name of the repository that hosts
// ds container images. It should be direct clone of the repository in official
// By default, it is `apache/dolphinscheduler-master`.
Expand Down
2 changes: 0 additions & 2 deletions api/v1alpha1/dsmaster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ type DSMasterSpec struct {

HpaPolicy *HpaPolicy `json:"hpa,omitempty"`

ServiceAccount string `json:"service_account,omitempty"`

// Paused is to pause the control of the operator for the ds-master .
// +kubebuilder:default=false
Paused bool `json:"paused,omitempty"`
Expand Down
2 changes: 0 additions & 2 deletions api/v1alpha1/dsworker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type DSWorkerSpec struct {
// +kubebuilder:default="3.0.0-alpha"
Version string `json:"version,omitempty"`

ServiceAccount string `json:"service_account,omitempty"`

// Repository is the name of the repository that hosts
// ds container images. It should be direct clone of the repository in official
// By default, it is `apache/dolphinscheduler-worker`.
Expand Down
1 change: 0 additions & 1 deletion config/samples/ds_v1alpha1_dsalert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ spec:
replicas: 1
version: latest
repository: ghcr.io/apache/dolphinscheduler/dolphinscheduler-alert-server
service_account: "ds-service-account"
datasource:
drive_name: "org.postgresql.Driver"
url: "jdbc:postgresql://postgres-service:5432/dolphinscheduler"
Expand Down
1 change: 0 additions & 1 deletion config/samples/ds_v1alpha1_dsapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ spec:
zookeeper_connect: "zookeeper-service:2181"
repository: ghcr.io/apache/dolphinscheduler/dolphinscheduler-api
node_port: 30002
service_account: "ds-service-account"
datasource:
drive_name: "org.postgresql.Driver"
url: "jdbc:postgresql://postgres-service:5432/dolphinscheduler"
Expand Down
1 change: 0 additions & 1 deletion config/samples/ds_v1alpha1_dsmaster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spec:
zookeeper_connect: "zookeeper-service:2181"
version: latest
repository: ghcr.io/apache/dolphinscheduler/dolphinscheduler-master
service_account: "ds-service-account"
datasource:
drive_name: "org.postgresql.Driver"
url: "jdbc:postgresql://postgres-service:5432/dolphinscheduler"
Expand Down
1 change: 0 additions & 1 deletion config/samples/ds_v1alpha1_dsworker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spec:
zookeeper_connect: "zookeeper-service:2181"
version: latest
repository: ghcr.io/apache/dolphinscheduler/dolphinscheduler-worker
service_account: "ds-service-account"
datasource:
drive_name: "org.postgresql.Driver"
url: "jdbc:postgresql://postgres-service:5432/dolphinscheduler"
Expand Down
2 changes: 1 addition & 1 deletion controllers/alert_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func createAlertDeployment(cluster *dsv1alpha1.DSAlert) *v1.Deployment {
},
},
Spec: corev1.PodSpec{
ServiceAccountName: cluster.Spec.ServiceAccount,
ServiceAccountName: dsv1alpha1.DsServiceAccount,
Containers: []corev1.Container{{
Name: dsv1alpha1.DsAlert,
Image: ImageName(cluster.Spec.Repository, cluster.Spec.Version),
Expand Down
2 changes: 1 addition & 1 deletion controllers/api_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func createApiDeployment(cluster *dsv1alpha1.DSApi) *v1.Deployment {
},
},
Spec: corev1.PodSpec{
ServiceAccountName: cluster.Spec.ServiceAccount,
ServiceAccountName: dsv1alpha1.DsServiceAccount,
Containers: []corev1.Container{{
Name: dsv1alpha1.DsApi,
Image: ImageName(cluster.Spec.Repository, cluster.Spec.Version),
Expand Down
4 changes: 4 additions & 0 deletions controllers/dsmaster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ func (r *DSMasterReconciler) createServiceAccountIfNotExists(ctx context.Context
}

err = r.Create(ctx, sa)

if err != nil {
masterLogger.Error(err, "create service account error")
return err
Expand All @@ -492,6 +493,7 @@ func (r *DSMasterReconciler) createServiceAccountIfNotExists(ctx context.Context
masterLogger.Info("set controller role error")
return err
}
masterLogger.Info("set role begin")
if err := r.Client.Create(ctx, ro); err != nil {
return err
}
Expand All @@ -507,6 +509,8 @@ func (r *DSMasterReconciler) createServiceAccountIfNotExists(ctx context.Context
masterLogger.Info("set controller rolebinding error")
return err
}

masterLogger.Info("set rolebinding begin")
if err := r.Client.Create(ctx, rb); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/master_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newDSMasterPod(cr *dsv1alpha1.DSMaster) *corev1.Pod {
Hostname: podName,
Subdomain: dsv1alpha1.DsServiceLabelValue,
SetHostnameAsFQDN: &isSetHostnameAsFQDN,
ServiceAccountName: cr.Spec.ServiceAccount,
ServiceAccountName: dsv1alpha1.DsServiceAccount,
Containers: []corev1.Container{
{
Name: cr.Name,
Expand Down
2 changes: 1 addition & 1 deletion controllers/worker_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func newDSWorkerPod(cr *dsv1alpha1.DSWorker) *corev1.Pod {
Spec: corev1.PodSpec{
Hostname: podName,
Subdomain: dsv1alpha1.DsServiceLabelValue,
ServiceAccountName: cr.Spec.ServiceAccount,
ServiceAccountName: dsv1alpha1.DsServiceAccount,
Containers: []corev1.Container{
{
Name: cr.Name,
Expand Down

0 comments on commit 53a75e4

Please sign in to comment.