Create the sa role rolebinding automately (#5)
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 @@
// +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 @@
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 @@
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 @@
// +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 @@
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 @@
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 @@
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 @@
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 @@
},
},
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 @@
},
},
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 @@
}
err = r.Create(ctx, sa)
+
if err != nil {
masterLogger.Error(err, "create service account error")
return err
@@ -492,6 +493,7 @@
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 @@
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 @@
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 @@
Spec: corev1.PodSpec{
Hostname: podName,
Subdomain: dsv1alpha1.DsServiceLabelValue,
- ServiceAccountName: cr.Spec.ServiceAccount,
+ ServiceAccountName: dsv1alpha1.DsServiceAccount,
Containers: []corev1.Container{
{
Name: cr.Name,