You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2022/09/27 12:15:56 UTC

[dolphinscheduler-operator] branch master updated: Create the sa role rolebinding automately (#5)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler-operator.git


The following commit(s) were added to refs/heads/master by this push:
     new 53a75e4  Create the sa role rolebinding automately (#5)
53a75e4 is described below

commit 53a75e477bcc4667712152bac4ddb0cf5cb60869
Author: nobolity <no...@users.noreply.github.com>
AuthorDate: Tue Sep 27 20:15:52 2022 +0800

    Create the sa role rolebinding automately (#5)
---
 api/v1alpha1/dsalert_types.go            | 2 --
 api/v1alpha1/dsapi_types.go              | 2 --
 api/v1alpha1/dsmaster_types.go           | 2 --
 api/v1alpha1/dsworker_types.go           | 2 --
 config/samples/ds_v1alpha1_dsalert.yaml  | 1 -
 config/samples/ds_v1alpha1_dsapi.yaml    | 1 -
 config/samples/ds_v1alpha1_dsmaster.yaml | 1 -
 config/samples/ds_v1alpha1_dsworker.yaml | 1 -
 controllers/alert_reconcile.go           | 2 +-
 controllers/api_reconcile.go             | 2 +-
 controllers/dsmaster_controller.go       | 4 ++++
 controllers/master_reconcile.go          | 2 +-
 controllers/worker_reconcile.go          | 2 +-
 13 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/api/v1alpha1/dsalert_types.go b/api/v1alpha1/dsalert_types.go
index acd27cc..a57fa1a 100644
--- a/api/v1alpha1/dsalert_types.go
+++ b/api/v1alpha1/dsalert_types.go
@@ -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.
diff --git a/api/v1alpha1/dsapi_types.go b/api/v1alpha1/dsapi_types.go
index bbcf1bc..ca70603 100644
--- a/api/v1alpha1/dsapi_types.go
+++ b/api/v1alpha1/dsapi_types.go
@@ -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`.
diff --git a/api/v1alpha1/dsmaster_types.go b/api/v1alpha1/dsmaster_types.go
index e3dcd42..f7971ca 100644
--- a/api/v1alpha1/dsmaster_types.go
+++ b/api/v1alpha1/dsmaster_types.go
@@ -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"`
diff --git a/api/v1alpha1/dsworker_types.go b/api/v1alpha1/dsworker_types.go
index 81ef041..e0dc9b0 100644
--- a/api/v1alpha1/dsworker_types.go
+++ b/api/v1alpha1/dsworker_types.go
@@ -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`.
diff --git a/config/samples/ds_v1alpha1_dsalert.yaml b/config/samples/ds_v1alpha1_dsalert.yaml
index 481f744..acc7bc0 100644
--- a/config/samples/ds_v1alpha1_dsalert.yaml
+++ b/config/samples/ds_v1alpha1_dsalert.yaml
@@ -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"
diff --git a/config/samples/ds_v1alpha1_dsapi.yaml b/config/samples/ds_v1alpha1_dsapi.yaml
index 7c646bf..7973715 100644
--- a/config/samples/ds_v1alpha1_dsapi.yaml
+++ b/config/samples/ds_v1alpha1_dsapi.yaml
@@ -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"
diff --git a/config/samples/ds_v1alpha1_dsmaster.yaml b/config/samples/ds_v1alpha1_dsmaster.yaml
index 59501ac..8544b81 100644
--- a/config/samples/ds_v1alpha1_dsmaster.yaml
+++ b/config/samples/ds_v1alpha1_dsmaster.yaml
@@ -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"
diff --git a/config/samples/ds_v1alpha1_dsworker.yaml b/config/samples/ds_v1alpha1_dsworker.yaml
index 48a3299..ea58716 100644
--- a/config/samples/ds_v1alpha1_dsworker.yaml
+++ b/config/samples/ds_v1alpha1_dsworker.yaml
@@ -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"
diff --git a/controllers/alert_reconcile.go b/controllers/alert_reconcile.go
index 878e9ce..85fc283 100644
--- a/controllers/alert_reconcile.go
+++ b/controllers/alert_reconcile.go
@@ -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),
diff --git a/controllers/api_reconcile.go b/controllers/api_reconcile.go
index 01ad35c..06e873f 100644
--- a/controllers/api_reconcile.go
+++ b/controllers/api_reconcile.go
@@ -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),
diff --git a/controllers/dsmaster_controller.go b/controllers/dsmaster_controller.go
index c239ac7..8bda945 100644
--- a/controllers/dsmaster_controller.go
+++ b/controllers/dsmaster_controller.go
@@ -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
@@ -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
 			}
@@ -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
 			}
diff --git a/controllers/master_reconcile.go b/controllers/master_reconcile.go
index 1cab854..1a9f45c 100644
--- a/controllers/master_reconcile.go
+++ b/controllers/master_reconcile.go
@@ -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,
diff --git a/controllers/worker_reconcile.go b/controllers/worker_reconcile.go
index f786d6d..b51710b 100644
--- a/controllers/worker_reconcile.go
+++ b/controllers/worker_reconcile.go
@@ -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,