Argo(https://argoproj.github.io/projects/argo) 項目是一組 Kubernetes 原生工具集合,用於運行和管理 Kubernetes 上的作業和應用程序。Argo 提供了一種在 Kubernetes 上創建工作和應用程序的三種計算模式 – 服務模式、工作流模式和基於事件的模式 – 的簡單組合方式。所有的 Argo 工具都實現爲控制器和自定義資源。
快速安裝
Linux
下載客戶端,通過 curl,如下:
# Download the binary curl -LO https://github.com/argoproj/argo/releases/download/v3.0.0-rc3/argo-linux-amd64.gz # Unzip gunzip argo-linux-amd64.gz # Make binary executable chmod +x argo-linux-amd64 # Move binary to path mv ./argo-linux-amd64 /usr/local/bin/argo # Test installation argo version
Argo Controller服務安裝
kubectl create namespace argo kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/v3.0.0-rc3/manifests/install.yaml
開啓節點部署pod:
安裝完後,使用 kubectl get pod -n argo發現始終處於pending狀態,需要開啓master節點的任務部署。
kubectl taint nodes --all node-role.kubernetes.io/master-
運行測試
運行示例的workflow:
argo submit -n argo --watch https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml
argo list -n argo
argo get -n argo @latest
argo logs -n argo @latest
查看UI:
- 使用 port-forward 來轉發端口:
kubectl -n argo port-forward deployment/argo-server 2746:2746
用戶界面可訪問 http://localhost:2746
- 使用NodePort:
使用kubectl edit deployment/argo-server -n argo,參照如下nginx-service.yaml,將type改爲NodePort,並添加nodePort端口。
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
sessionAffinity: ClientIP
selector:
app: nginx
ports:
- port: 80
nodePort: 30080
- kind:Service代表是一個服務
- type:NodePort k8s將會在每個Node上打開一個端口並且每個Node的端口都是一樣的,通過<NodeIP>:NodePort的方式Kubernetes集羣外部的程序可以訪問Service。
- selector:哪個服務需要暴露
- port:service暴露的端口
- TargetPort:pod的端口
- nodePort:對外暴露的端口,不設置會默認分配,範圍:30000-32767
- 轉發邏輯是:
<NodeIP>:<nodeport> => <ServiceVIP>:<port>=> <PodIP>:<targetport>
在相應節點上使用http://<NodeIP>:<nodeport>就可以訪問服務了。