本文介绍在OpenShift群集上安装ArgoCD的方法,请按照以下步骤将ArgoCD安装到您的OpenShift容器平台上。
一、创建项目名称空间 ArgoCD将需要在其命名空间上运行,创建它。 使用oc命令: $ oc create namespace argocd 用kubectl命令: $ kubectl create namespace argocd 您需要配置kubectl才能运行命令,可参考安装及使用kubectl、kubectx和kubens轻松管理多个Kubernetes集群。
二、在OpenShift上应用ArgoCD Manifest 接下来,我们可以通过运行安装Manifest在OpenShift上执行ArgoCD的实际安装。 使用oc命令: mkdir argocd cd argocd wget https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml oc apply -n argocd -f ./install.yaml 用kubectl命令: mkdir argocd cd argocd wget https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml kubectl apply -n argocd -f ./install.yaml 执行输出,如下信息: customresourcedefinition.apiextensions.k8s.io/applications.argoproj.io created customresourcedefinition.apiextensions.k8s.io/appprojects.argoproj.io created serviceaccount/argocd-application-controller created serviceaccount/argocd-dex-server created serviceaccount/argocd-server created role.rbac.authorization.k8s.io/argocd-application-controller created role.rbac.authorization.k8s.io/argocd-dex-server created role.rbac.authorization.k8s.io/argocd-server created clusterrole.rbac.authorization.k8s.io/argocd-application-controller created clusterrole.rbac.authorization.k8s.io/argocd-server created rolebinding.rbac.authorization.k8s.io/argocd-application-controller created rolebinding.rbac.authorization.k8s.io/argocd-dex-server created rolebinding.rbac.authorization.k8s.io/argocd-server created clusterrolebinding.rbac.authorization.k8s.io/argocd-application-controller created clusterrolebinding.rbac.authorization.k8s.io/argocd-server created configmap/argocd-cm created configmap/argocd-rbac-cm created configmap/argocd-ssh-known-hosts-cm created configmap/argocd-tls-certs-cm created secret/argocd-secret created service/argocd-dex-server created service/argocd-metrics created service/argocd-redis created service/argocd-repo-server created service/argocd-server-metrics created service/argocd-server created deployment.apps/argocd-application-controller created deployment.apps/argocd-dex-server created deployment.apps/argocd-redis created deployment.apps/argocd-repo-server created deployment.apps/argocd-server created pods将在几秒钟或几分钟内启动: $ oc get pods -n argocd
用包含OpenShift连接器的图像替换Dex正在使用的图像: oc -n argocd patch deployment argocd-dex-server -p '{"spec": {"template": {"spec": {"containers": [{"name": "dex","image": "quay.io/redhat-cop/dex:v2.22.0-openshift"}]}}}}' 通过执行以下命令来确认更新的Dex Pod正在运行: oc get pods -l=app.kubernetes.io/name=argocd-dex-server
三、取得ArgoCD伺服器密码 确认所有Pod正在运行后,获取自动生成的ArgoCD Server初始密码: ARGOCD_SERVER_PASSWORD=$(oc -n argocd get pod -l "app.kubernetes.io/name=argocd-server" -o jsonpath='{.items[*].metadata.name}') 确认密码已保存: $ echo $ARGOCD_SERVER_PASSWORD argocd-server-7696cd5f99-v86rn
四、使用OpenShift Route公开ArgoCD服务器 我们需要在OpenShift上修补ArgoCD Server部署,以使服务通过OpenShift路由公开: oc -n argocd patch deployment argocd-server -p '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"argocd-server"}],"containers":[{"command":["argocd-server","--insecure","--staticassets","/shared/app"],"name":"argocd-server"}]}}}}' 如果成功,您应该在输出中打补丁: deployment.apps/argocd-server patched 然后,您可以继续公开ArgoCD服务器: oc -n argocd create route edge argocd-server --service=argocd-server --port=http --insecure-policy=Redirect 确认路由已创建: $ oc get route -n argocd
通过导航到执行以下命令提供的位置,确认可访问Web控制台: echo https://$(oc get routes argocd -o=jsonpath='{ .spec.host }') 您可以通过动态编辑yaml配置来更新路由中使用的主机名: $ oc edit route -n argocd
五、下载Argo CD CLI 从发布页面下载新的Argo CD版本: VERSION=$(curl --silent "https://api.github.com/repos/argoproj/argo-cd/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/$VERSION/argocd-linux-amd64 使argocd CLI可执行: sudo chmod +x /usr/local/bin/argocd 检查客户端版本,如下信息: $ argocd version --client argocd: v1.5.5+0fdef48 BuildDate: 2020-05-16T04:02:57Z GitCommit: 0fdef4861e12026e133224f7c9413072340e2983 GitTreeState: clean GoVersion: go1.14.1 Compiler: gc Platform: linux/amd64 使用用户名admin和密码登录Argo CD的IP或主机名。 获取路线: ARGOCD_ROUTE=$(oc -n argocd get route argocd-server -o jsonpath='{.spec.host}') 获取管理员密码: ARGOCD_SERVER_PASSWORD=$(oc -n argocd get pod -l "app.kubernetes.io/name=argocd-server" -o jsonpath='{.items[*].metadata.name}') 登录ArgoCD API: argocd --insecure --grpc-web login ${ARGOCD_ROUTE}:443 --username admin --password ${ARGOCD_SERVER_PASSWORD} 使用以下命令更改密码: argocd --insecure --grpc-web --server ${ARGOCD_ROUTE}:443 account update-password --current-password ${ARGOCD_SERVER_PASSWORD} --new-password
六、访问ArgoCD仪表板 然后,您可以使用路由URL访问ArgoCD控制台:
登录用户名是admin,即Username:admin。 初始密码可以通过以下方式获得: kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2 登录后将显示ArgoCD仪表板,如下图:
至此,安装ArgoCD完成了。
相关主题 |