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

[dolphinscheduler-operator] 19/44: fix(CRD): run in aws

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

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

commit e6f5109a005b2d40d6dede3f5c2b7516fa1020a8
Author: nobolity <no...@gmail.com>
AuthorDate: Fri Jun 3 15:59:09 2022 +0800

    fix(CRD): run in  aws
---
 .gitignore                                         |  1 +
 api/v1alpha1/dsapi_types.go                        |  5 ++--
 .../ds.apache.dolphinscheduler.dev_dsapis.yaml     |  5 ++--
 config/ds/api/ds-api-deployment.yaml               | 32 ----------------------
 config/ds/api/ds-api-service.yaml                  | 18 ------------
 config/ds/postgreSQL/postgres-service.yaml         |  3 +-
 config/samples/ds_v1alpha1_dsalert.yaml            |  2 +-
 config/samples/ds_v1alpha1_dsapi.yaml              |  5 ++--
 config/samples/ds_v1alpha1_dsmaster.yaml           |  6 ++--
 config/samples/ds_v1alpha1_dsworker.yaml           |  6 ++--
 controllers/api_reconcile.go                       |  8 ++++--
 11 files changed, 21 insertions(+), 70 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1299c19..f6c8ec4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,4 @@ testbin/*
 
 /vendor/
 /dolphinscheduler-operator.iml
+/config/test/
diff --git a/api/v1alpha1/dsapi_types.go b/api/v1alpha1/dsapi_types.go
index 91db86f..08a7319 100644
--- a/api/v1alpha1/dsapi_types.go
+++ b/api/v1alpha1/dsapi_types.go
@@ -64,9 +64,8 @@ type DSApiSpec struct {
 	//LogPvcName defines the  log capacity of application ,the position is /opt/dolphinscheduler/logs eg 20Gi
 	LogPvcName string `json:"log_pvc_name,omitempty"`
 
-	//NodePort is the port node exposed
-	// +kubebuilder:default=30001
-	NodePort int32 `json:"node_port"`
+	//NodePort is the port node exposed if no nodePort it will be lb type
+	NodePort int32 `json:"node_port,omitempty"`
 }
 
 // DSApiStatus defines the observed state of DSApi
diff --git a/config/crd/bases/ds.apache.dolphinscheduler.dev_dsapis.yaml b/config/crd/bases/ds.apache.dolphinscheduler.dev_dsapis.yaml
index 2753d6e..7b665f8 100644
--- a/config/crd/bases/ds.apache.dolphinscheduler.dev_dsapis.yaml
+++ b/config/crd/bases/ds.apache.dolphinscheduler.dev_dsapis.yaml
@@ -1111,8 +1111,8 @@ spec:
                   position is /opt/dolphinscheduler/logs eg 20Gi
                 type: string
               node_port:
-                default: 30001
-                description: NodePort is the port node exposed
+                description: NodePort is the port node exposed if no nodePort it will
+                  be lb type
                 format: int32
                 type: integer
               paused:
@@ -1145,7 +1145,6 @@ spec:
                 type: string
             required:
             - datasource
-            - node_port
             - replicas
             type: object
           status:
diff --git a/config/ds/api/ds-api-deployment.yaml b/config/ds/api/ds-api-deployment.yaml
deleted file mode 100644
index 9264c94..0000000
--- a/config/ds/api/ds-api-deployment.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  name: ds-api-deployment
-  namespace: ds
-spec:
-  replicas: 1
-  selector:
-    matchLabels:
-      app: ds-api
-  template:
-    metadata:
-      labels:
-        app: ds-api
-    spec:
-      containers:
-        - name: ds-api
-          image: apache/dolphinscheduler-api:3.0.0-alpha
-          imagePullPolicy: "IfNotPresent"
-          env:
-            - name: REGISTRY_ZOOKEEPER_CONNECT_STRING
-              value: 172.17.0.5:2181
-            - name: SPRING_DATASOURCE_DRIVER_CLASS_NAME
-              value: org.postgresql.Driver
-            - name: SPRING_DATASOURCE_URL
-              value: "jdbc:postgresql://172.17.0.4:5432/dolphinscheduler"
-            - name: SPRING_DATASOURCE_USERNAME
-              value: "postgresadmin"
-            - name: SPRING_DATASOURCE_PASSWORD
-              value: "admin12345"
-          ports:
-            - containerPort: 12345
\ No newline at end of file
diff --git a/config/ds/api/ds-api-service.yaml b/config/ds/api/ds-api-service.yaml
deleted file mode 100644
index 58c2fe5..0000000
--- a/config/ds/api/ds-api-service.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
-  name: ds-api-service
-  namespace: ds
-spec:
-  type: NodePort
-  ports:
-    - protocol: TCP
-      port: 12345
-      targetPort: 12345
-      nodePort: 30001
-  selector:
-    app: ds-api
-
-
-
-
diff --git a/config/ds/postgreSQL/postgres-service.yaml b/config/ds/postgreSQL/postgres-service.yaml
index 0ec5c0a..ab7a73b 100644
--- a/config/ds/postgreSQL/postgres-service.yaml
+++ b/config/ds/postgreSQL/postgres-service.yaml
@@ -6,11 +6,10 @@ metadata:
     app: postgres
   namespace: ds
 spec:
-  type: NodePort
+  type: LoadBalancer
   ports:
     - port: 5432
       targetPort: 5432
-      nodePort: 30022
       protocol: TCP
   selector:
     app: postgres
\ No newline at end of file
diff --git a/config/samples/ds_v1alpha1_dsalert.yaml b/config/samples/ds_v1alpha1_dsalert.yaml
index 56c5647..487d026 100644
--- a/config/samples/ds_v1alpha1_dsalert.yaml
+++ b/config/samples/ds_v1alpha1_dsalert.yaml
@@ -11,6 +11,6 @@ spec:
   repository: apache/dolphinscheduler-alert-server
   datasource:
     drive_name: "org.postgresql.Driver"
-    url: "jdbc:postgresql://172.17.0.4:5432/dolphinscheduler"
+    url: "jdbc:postgresql://172.31.24.57:5432/dolphinscheduler"
     username: "postgresadmin"
     password: "admin12345"
diff --git a/config/samples/ds_v1alpha1_dsapi.yaml b/config/samples/ds_v1alpha1_dsapi.yaml
index fef6f69..a330949 100644
--- a/config/samples/ds_v1alpha1_dsapi.yaml
+++ b/config/samples/ds_v1alpha1_dsapi.yaml
@@ -8,11 +8,10 @@ metadata:
 spec:
   replicas: 1
   version: 3.0.0-alpha
-  zookeeper_connect: "172.17.0.5:2181"
+  zookeeper_connect: "172.31.29.53:2181"
   repository: apache/dolphinscheduler-api
-  node_port: 30002
   datasource:
     drive_name: "org.postgresql.Driver"
-    url: "jdbc:postgresql://172.17.0.4:5432/dolphinscheduler"
+    url: "jdbc:postgresql://172.31.24.57:5432/dolphinscheduler"
     username: "postgresadmin"
     password: "admin12345"
\ No newline at end of file
diff --git a/config/samples/ds_v1alpha1_dsmaster.yaml b/config/samples/ds_v1alpha1_dsmaster.yaml
index 8f2a2a3..f4be4fb 100644
--- a/config/samples/ds_v1alpha1_dsmaster.yaml
+++ b/config/samples/ds_v1alpha1_dsmaster.yaml
@@ -6,13 +6,13 @@ metadata:
   labels:
     app: ds-master
 spec:
-  replicas: 1
-  zookeeper_connect: "172.17.0.5:2181"
+  replicas: 2
+  zookeeper_connect: "172.31.29.53:2181"
   version: 3.0.0-alpha
   repository: apache/dolphinscheduler-master
   datasource:
     drive_name: "org.postgresql.Driver"
-    url: "jdbc:postgresql://172.17.0.4:5432/dolphinscheduler"
+    url: "jdbc:postgresql://172.31.24.57:5432/dolphinscheduler"
     username: "postgresadmin"
     password: "admin12345"
 
diff --git a/config/samples/ds_v1alpha1_dsworker.yaml b/config/samples/ds_v1alpha1_dsworker.yaml
index c1f1097..7f818b2 100644
--- a/config/samples/ds_v1alpha1_dsworker.yaml
+++ b/config/samples/ds_v1alpha1_dsworker.yaml
@@ -6,12 +6,12 @@ metadata:
   labels:
     app: ds-worker
 spec:
-  replicas: 1
-  zookeeper_connect: "172.17.0.5:2181"
+  replicas: 3
+  zookeeper_connect: "172.31.29.53:2181"
   version: 3.0.0-alpha
   repository: apache/dolphinscheduler-worker
   datasource:
     drive_name: "org.postgresql.Driver"
-    url: "jdbc:postgresql://172.17.0.4:5432/dolphinscheduler"
+    url: "jdbc:postgresql://172.31.24.57:5432/dolphinscheduler"
     username: "postgresadmin"
     password: "admin12345"
\ No newline at end of file
diff --git a/controllers/api_reconcile.go b/controllers/api_reconcile.go
index f8bc647..a4d9551 100644
--- a/controllers/api_reconcile.go
+++ b/controllers/api_reconcile.go
@@ -32,7 +32,7 @@ func createApiService(cluster *dsv1alpha1.DSApi) *corev1.Service {
 			Labels:    map[string]string{dsv1alpha1.DsAppName: dsv1alpha1.DsApiServiceValue},
 		},
 		Spec: corev1.ServiceSpec{
-			Type:     corev1.ServiceTypeNodePort,
+			Type:     corev1.ServiceTypeLoadBalancer,
 			Selector: map[string]string{dsv1alpha1.DsAppName: dsv1alpha1.DsApi},
 			Ports: []corev1.ServicePort{
 				{
@@ -41,11 +41,15 @@ func createApiService(cluster *dsv1alpha1.DSApi) *corev1.Service {
 					TargetPort: intstr.IntOrString{
 						IntVal: dsv1alpha1.DsApiPort,
 					},
-					NodePort: cluster.Spec.NodePort,
 				},
 			},
 		},
 	}
+	if cluster.Spec.NodePort > 0 {
+		apiLogger.Info("the nodePort is not nil", "nodePort", cluster.Spec.NodePort)
+		service.Spec.Type = corev1.ServiceTypeNodePort
+		service.Spec.Ports[0].NodePort = cluster.Spec.NodePort
+	}
 	return &service
 }