登录github,打开: https://github.com/brentley/ecsdemo-nodejs.git 并进行fork
然后获取对应的仓库URL:
使用Argo CLI连接到当前context下的K8s集群:
CONTEXT_NAME=`kubectl config view -o jsonpath='{.current-context}'`
argocd cluster add $CONTEXT_NAME
ArgoCD提供多集群部署的能力,但本节只会在一个集群上部署。
使用刚才fork的代码库部署应用 (替换GITHUB_USERNAME部分):
kubectl create namespace ecsdemo-nodejs
argocd app create ecsdemo-nodejs --repo https://github.com/GITHUB_USERNAME/ecsdemo-nodejs.git --path kubernetes --dest-server https://kubernetes.default.svc --dest-namespace ecsdemo-nodejs
使用下面的命令查看状态:
argocd app get ecsdemo-nodejs
输出如下:
Health Status: Missing
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
_ Service ecsdemo-nodejs ecsdemo-nodejs OutOfSync Missing
apps Deployment default ecsdemo-nodejs OutOfSync Missing
可以看到应用是OutOfSync
状态,因为应用还没有被部署上去。现在进行sync
操作:
argocd app sync ecsdemo-nodejs
经过几秒后,应用状态变为Synced
:
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
_ Service ecsdemo-nodejs ecsdemo-nodejs Synced Healthy service/ecsdemo-nodejs created
apps Deployment default ecsdemo-nodejs Synced Healthy deployment.apps/ecsdemo-nodejs created