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>就可以访问服务了。