點擊上方
藍字關注我們
Kubernetes 是一個基於容器技術、實現容器編排、提供微服務和總線的集群系統,涉及到大量的知識體系。
本文從作者的實際工作經歷出發,向我們展示了海豚調度在實際場景種的使用與技術分享,希望這篇文章能夠給有着相同經歷的人一些啟發。
我們為什麼使用海豚調度,
帶來了什麼價值,遇到了什麼問題
海豚調度是當前非常優秀的分布式易擴展的可視化工作流任務調度平台。從筆者的行業出發,海豚調度的應用快速解決了企業對數據開發方面十大痛點:多源數據連接和接入,技術領域絕大多數常見的數據源都可以接入,加入新的數據源也無需太多的改動;多元化+專業化+海量數據任務管理,真正地圍繞大數據(hadoop family,flink 等)的任務調度,與傳統調度器有顯著的不同;圖形化任務編排,超級的用戶體驗,可以和商用產品直接對標,並且多數國外的開源產品並不能直接拖拉拽生成數據任務;任務明細,原子任務豐富的查看、日誌查看,時間運行軸顯示,滿足開發人員對數據任務的精細化管理,快速定位慢sql,性能瓶頸;多種分布式文件系統的支持,豐富用戶對非結構化數據的選擇;天然的多租戶管理,滿足大型組織下數據任務管理和隔離要求;自帶集群監控功能,監控 cpu,內存,連接數,zookeeper 狀態,適合中小企業一站式運維;強大的社區化運營,傾聽客戶真正的聲音,不斷新增功能,持續優化客戶體驗;在筆者上線各類海豚調度參與的項目中,也遇到了很多新的挑戰:如何用更少的人力資源去部署海豚調度,是否可以實現全自動的集群化安裝部署模式?網絡安全管控要求下,如何實現air-gap模式的安裝和更新?基於以上的挑戰,我們將海豚調度重複融入現有的 kubernetes 雲原生體系,解決痛點,讓海豚技術變的更加強大。Kubernetes 技術體系
給海豚調度帶來的技術新特性
在使用 kubernetes 管理海豚後,整體技術方案很快具備了豐富高效的技術特性,也解決了上述實際的挑戰:各類獨立部署項目,快速建立開發環境和生產環境,全部實現了一鍵部署,一鍵升級的實施模式;儘可能統一的安裝配置的信息,減少多個項目配置的異常,所有的配置項,可以基於不同的項目通過企業內部git管理;便捷的監控體系,與現有 prometheus 監控體系集成;快速的自愈能力,自動異常重啟,以及基於探針模式的重啟;首先,我們介紹基於官網提供的 helm 的安裝方式。helm 是查找、分享和使用軟件構建 kubernetes 的最優方式。也是雲原生cncf的畢業項目之一。海豚的官網和 github 上有非常詳細的配置文件和案例。這裡我們重點介紹一些社區中經常出現的諮詢和問題。https://dolphinscheduler.apache.org/zh-cn/docs/1.3.9/user_doc/kubernetes-deployment.htmlhttps://github.com/apache/dolphinscheduler/tree/1.3.9-release/docker/kubernetes/dolphinscheduler在 value.yaml 文件中修改鏡像,以實現離線安裝(air-gap install);image: repository: "apache/dolphinscheduler" tag: "1.3.9" pullPolicy: "IfNotPresent"針對公司內部安裝好的 harbor,或者其他公有雲的私倉,進行 pull,tag,以及push。這裡我們假定私倉地址是 harbor.abc.com,所在構建鏡像的主機已經進行了 docker login harbor.abc.com, 且已經建立和授權私倉下面新建 apache項目。docker pull apache/dolphinscheduler:1.3.9dock tag apache/dolphinscheduler:1.3.9 harbor.abc.com/apache/dolphinscheduler:1.3.9docker push apache/dolphinscheduler:1.3.9再替換 value 文件中的鏡像信息,這裡我們推薦使用 Always 的方式拉取鏡像,生產環境中儘量每次去檢查是否是最新的鏡像內容,保證軟件製品的正確性。此外,很多同學會把 tag 寫成 latest,製作鏡像不寫 tag 信息,這樣在生產環境非常危險,任何人 push 了鏡像,就相當於改變了 latest 的鏡像,而且也無法判斷latest 是什麼版本,所以建議要明確每次發版的 tag,並且使用 Always。image: repository: "harbor.abc.com/apache/dolphinscheduler" tag: "1.3.9" pullPolicy: "Always"把 https://github.com/apache/dolphinscheduler/tree/1.3.9-release/docker/kubernetes/dolphinscheduler 整個目錄 copy 到可以執行 helm 命令的主機,然後按照官網執行kubectl create ns ds139helm install dolphinscheduler . -n ds139集成 datax、mysql、oracle 客戶端組件,首先下載以下組件https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jarhttps://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc8/https://github.com/alibaba/DataX/blob/master/userGuid.md 根據提示進行編譯構建,文件包位於 {DataX_source_code_home}/target/datax/datax/基於以上 plugin 組件新建 dockerfile,基礎鏡像可以使用已經 push 到私倉的鏡像。FROM harbor.abc.com/apache/dolphinscheduler:1.3.9COPY *.jar /opt/dolphinscheduler/lib/RUN mkdir -p /opt/soft/dataxCOPY datax /opt/soft/datax保存 dockerfile,執行 shell 命令docker build -t harbor.abc.com/apache/dolphinscheduler:1.3.9-mysql-oracle-datax . #不要忘記最後一個點docker push harbor.abc.com/apache/dolphinscheduler:1.3.9-mysql-oracle-dataximage: repository: "harbor.abc.com/apache/dolphinscheduler" tag: "1.3.9-mysql-oracle-datax" pullPolicy: "Always"執行 helm install dolphinscheduler . -n ds139,或者執行 helm upgrade dolphinscheduler -n ds139,也可以先 helm uninstall dolphinscheduler -n ds139,再執行 helm install dolphinscheduler . -n ds139。通常生產環境建議使用獨立外置 postgresql 作為管理數據庫,並且使用獨立安裝的 zookeeper 環境(本案例使用了zookeeper operator https://github.com/pravega/zookeeper-operator,與海豚調度在同一個 kubernetes 集群中)。我們發現,使用外置數據庫後,對海豚調度在 kubernetes 中進行完全刪除操作,然後重新部署海豚調度後,任務數據、租戶數據、用戶數據等等都有保留,這再次驗證了系統的高可用性和數據完整性。(如果刪除了 pvc ,會丟失歷史的作業日誌)## If not exists external database, by default, Dolphinscheduler's database will use it.postgresql: enabled: false postgresqlUsername: "root" postgresqlPassword: "root" postgresqlDatabase: "dolphinscheduler" persistence: enabled: false size: "20Gi" storageClass: "-"## If exists external database, and set postgresql.enable value to false.## external database will be used, otherwise Dolphinscheduler's database will be used.externalDatabase: type: "postgresql" driver: "org.postgresql.Driver" host: "192.168.1.100" port: "5432" username: "admin" password: "password" database: "dolphinscheduler" params: "characterEncoding=utf8" ## If not exists external zookeeper, by default, Dolphinscheduler's zookeeper will use it.zookeeper: enabled: false fourlwCommandsWhitelist: "srvr,ruok,wchs,cons" persistence: enabled: false size: "20Gi" storageClass: "storage-nfs" zookeeperRoot: "/dolphinscheduler"## If exists external zookeeper, and set zookeeper.enable value to false.## If zookeeper.enable is false, Dolphinscheduler's zookeeper will use it.externalZookeeper: zookeeperQuorum: "zookeeper-0.zookeeper-headless.zookeeper.svc.cluster.local:2181,zookeeper-1.zookeeper-headless.zookeeper.svc.cluster.local:2181,zookeeper-2.zookeeper-headless.zookeeper.svc.cluster.local:2181" zookeeperRoot: "/dolphinscheduler"argo-cd 是基於 Kubernetes 的聲明式 gitops 持續交付工具。argo-cd 是 cncf的孵化項目,gitops 的最佳實踐工具。關於 gitops 的解釋可以參考https://about.gitlab.com/topics/gitops/從github 上下載海豚調度源碼,修改 value 文件,參考上個章節 helm 安裝需要修改的內容;把修改後的源碼目錄新建git項目,並且 push 到公司內部的 gitlab 中,github源碼的目錄名為docker/kubernetes/dolphinscheduler;在 argo-cd 中配置 gitlab 信息,我們使用 https 的模式;對git中的部署信息進行刷新和拉取,實現最後的部署工作。可以看到 pod,configmap,secret,service,ingress 等等資源全自動拉起,並且 argo-cd 顯示了之前 git push 使用的 commit 信息和提交人用戶名,這樣就完整記錄了所有的發版事件信息。同時也可以一鍵回滾到歷史版本。
[root@tpk8s-master01 ~]# kubectl get po -n ds139NAME READY STATUS RESTARTS AGEdolphinscheduler-alert-96c74dc84-72cc9 1/1 Running 0 22mdolphinscheduler-api-78db664b7b-gsltq 1/1 Running 0 22mdolphinscheduler-master-0 1/1 Running 0 22mdolphinscheduler-master-1 1/1 Running 0 22mdolphinscheduler-master-2 1/1 Running 0 22mdolphinscheduler-worker-0 1/1 Running 0 22mdolphinscheduler-worker-1 1/1 Running 0 22mdolphinscheduler-worker-2 1/1 Running 0 22m[root@tpk8s-master01 ~]# kubectl get statefulset -n ds139NAME READY AGEdolphinscheduler-master 3/3 22mdolphinscheduler-worker 3/3 22m[root@tpk8s-master01 ~]# kubectl get cm -n ds139NAME DATA AGEdolphinscheduler-alert 15 23mdolphinscheduler-api 1 23mdolphinscheduler-common 29 23mdolphinscheduler-master 10 23mdolphinscheduler-worker 7 23m[root@tpk8s-master01 ~]# kubectl get service -n ds139NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEdolphinscheduler-api ClusterIP 10.43.238.5 <none> 12345/TCP 23mdolphinscheduler-master-headless ClusterIP None <none> 5678/TCP 23mdolphinscheduler-worker-headless ClusterIP None <none> 1234/TCP,50051/TCP 23m[root@tpk8s-master01 ~]# kubectl get ingress -n ds139NAME CLASS HOSTS ADDRESSdolphinscheduler <none> ds139.abc.com 可以看到所有的 pod 都分散在 kubernetes 集群中不同的 host 上,例如worker 1 和 2 都在不同的節點上。我們配置了 ingress,公司內部配置了泛域名就可以方便的使用域名進行訪問;ingress: enabled: true host: "ds139.abc.com" path: "/dolphinscheduler" tls: enabled: false secretName: "dolphinscheduler-tls"對部署好的系統進行檢查,3個 master,3個 worker,zookeeper 都配置正常;使用 argo-cd 可以非常方便的進行修改 master,worker,api,alert 等組件的副本數量,海豚的 helm 配置也預留了 cpu 和內存的設置信息。這裡我們修改 value 中的副本值。修改後,git pish 到公司內部 gitlab。master: ## PodManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. podManagementPolicy: "Parallel" ## Replicas is the desired number of replicas of the given Template. replicas: "5" worker: ## PodManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. podManagementPolicy: "Parallel" ## Replicas is the desired number of replicas of the given Template. replicas: "5" alert: ## Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1. replicas: "3" api: ## Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1. replicas: "3"只需要在 argo-cd 點擊 sync 同步,對應的 pods 都按照需求進行了增加


[root@tpk8s-master01 ~]# kubectl get po -n ds139NAME READY STATUS RESTARTS AGEdolphinscheduler-alert-96c74dc84-72cc9 1/1 Running 0 43mdolphinscheduler-alert-96c74dc84-j6zdh 1/1 Running 0 2m27sdolphinscheduler-alert-96c74dc84-rn9wb 1/1 Running 0 2m27sdolphinscheduler-api-78db664b7b-6j8rj 1/1 Running 0 2m27sdolphinscheduler-api-78db664b7b-bsdgv 1/1 Running 0 2m27sdolphinscheduler-api-78db664b7b-gsltq 1/1 Running 0 43mdolphinscheduler-master-0 1/1 Running 0 43mdolphinscheduler-master-1 1/1 Running 0 43mdolphinscheduler-master-2 1/1 Running 0 43mdolphinscheduler-master-3 1/1 Running 0 2m27sdolphinscheduler-master-4 1/1 Running 0 2m27sdolphinscheduler-worker-0 1/1 Running 0 43mdolphinscheduler-worker-1 1/1 Running 0 43mdolphinscheduler-worker-2 1/1 Running 0 43mdolphinscheduler-worker-3 1/1 Running 0 2m27sdolphinscheduler-worker-4 1/1 Running 0 2m27s許多同學在海豚的社區中提問,如何配置 s3 minio 的集成。這裡給出基於kubernetes 的 helm 配置。修改 value 中 s3 的部分,建議使用 ip+端口指向 minio 服務器。common: ## Configmap configmap: DOLPHINSCHEDULER_OPTS: "" DATA_BASEDIR_PATH: "/tmp/dolphinscheduler" RESOURCE_STORAGE_TYPE: "S3" RESOURCE_UPLOAD_PATH: "/dolphinscheduler" FS_DEFAULT_FS: "s3a://dfs" FS_S3A_ENDPOINT: "http://192.168.1.100:9000" FS_S3A_ACCESS_KEY: "admin" FS_S3A_SECRET_KEY: "password"minio 中存放海豚文件的 bucket 名字是 dolphinscheduler,這裡新建文件夾和文件進行測試。minio 的目錄在上傳操作的租戶下。
海豚調度與 Kube-prometheus 的技術集成
我們在 kubernetes 使用 kube-prometheus operator技術,在部署海豚後,自動實現了對海豚各個組件的資源監控。請注意 kube-prometheus 的版本,需要對應 kubernetes 主版本。https://github.com/prometheus-operator/kube-prometheus
通過 service mesh 技術可以實現對海豚內部的服務調用,以及海豚 api 外部調用的可觀測性分析,以實現海豚調度產品的自身服務優化。我們使用 linkerd 作為 service mesh 的產品進行集成,linkerd 也是 cncf 優秀的畢業項目之一。
只需要在海豚 helm 的 value 文件中修改 annotations,重新部署,就可以快速實現 mesh proxy sidecar 的注入。可以對 master,worker,api,alert 等組件都注入。 annotations: #{} linkerd.io/inject: enabled
可以觀察組件之間的服務通信質量,每秒請求的次數等等。
海豚調度作為面向新一代雲原生大數據工具,未來可以在 kubernetes 生態集成更多的優秀工具和特性,滿足更多的用戶群體和場景。和 argo-workflow 的集成,可以通過 api,cli 等方式在海豚調度中調用argo-workflow 單個作業,dag 作業,以及周期性作業;使用 hpa 的方式,自動擴縮容 worker,實現無人干預的水平擴展方式;集成 kubernetes 的 spark operator 和 flink operator 工具,全面的雲原生化;實現多雲和多集群的分布式作業調度,強化 serverless+faas 類的架構屬性;採用 sidecar 實現定期刪除 worker 作業日誌,進一步實現無憂運維;最後,強力推薦大家使用slack進行海豚社區交流,官方推薦!
隨着國內開源的迅猛崛起,Apache DolphinScheduler 社區迎來蓬勃發展,為了做更好用、易用的調度,真誠歡迎熱愛開源的夥伴加入到開源社區中來,為中國開源崛起獻上一份自己的力量,讓本土開源走向全球。
參與 DolphinScheduler 社區有非常多的參與貢獻的方式,包括:
貢獻第一個PR(文檔、代碼)我們也希望是簡單的,第一個PR用於熟悉提交的流程和社區協作以及感受社區的友好度。
社區匯總了以下適合新手的問題列表:https://github.com/apache/dolphinscheduler/issues/5689
非新手問題列表:https://github.com/apache/dolphinscheduler/issues?q=is%3Aopen+is%3Aissue+label%3A%22volunteer+wanted%22
如何參與貢獻鏈接:https://dolphinscheduler.apache.org/zh-cn/docs/development/contribute.html
來吧,DolphinScheduler開源社區需要您的參與,為中國開源崛起添磚加瓦吧,哪怕只是小小的一塊瓦,匯聚起來的力量也是巨大的。
參與開源可以近距離與各路高手切磋,迅速提升自己的技能,如果您想參與貢獻,我們有個貢獻者種子孵化群,可以添加社區小助手
微信(Leonard-ds)手把手教會您( 貢獻者不分水平高低,有問必答,關鍵是有一顆願意貢獻的心 )。添加小助手微信時請說明想參與貢獻。
來吧,開源社區非常期待您的參與。
社區官網https://dolphinscheduler.apache.org/代碼倉地址https://github.com/apache/dolphinscheduler
您的Star,是Apache DolphinScheduler為愛發電的動力❤️~
☞直播報名火熱啟動 | 2022 年 Apache DolphinScheduler Meetup 首秀!☞DolphinScheduler E2E 自動化測試教程來了!歡迎更多人加入共同完成☞Apache 基金會中國項目活躍度分析 Top20 發布,DolphinScheduler 位列第四☞數據遷移 | Apache Dolphinscheduler 調度 DataX 從 MySQL 全量導入 Hive☞Apache DolphinScheduler 2.0.3 發布,支持釘釘告警簽名校驗,數據源可從多個會話獲取鏈接☞Apache DolphinScheduler 董事會報告:社區健康運行,Commit 增長 123%☞☞一文給你整明白多租戶在 Apache DolphinScheduler 中的作用☞開源並不是大牛的專屬,普通人也能有屬於自己的一畝三分地☞在 Apache DolphinScheduler 上調試 LDAP 登錄,親測有效!