ArgoCD 快速入门(Windows)

ArgoCD 是一款基于 Kubernetes 的持续部署工具。根据其官方的快速入门,这两天在 Win10 上体验了一下。

具体步骤如下:

  1. 创建命名空间( argocd ),之后应用官方提供的部署文件。

    kubectl create namespace argocd
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
    

    如果第二条命令下载失败,可以多尝试几次。如果实在下载不下来,可以试一下我这边下载的 install.yaml 文件并修改 -f 后的文件地址为本地地址,或者直接使用本站的地址:

    kubectl apply -n argocd -f https://www.liujiajia.me/files/2022/5/29/argocd/install.yaml
    
  2. 下载 Argo CD 客户端(可选)

    如果只是通过 Argo CD 的 UI 界面维护的话,可以不用安装客户端。

    Windows 下需要在 PowerShell 中执行如下命令:

    $version = (Invoke-RestMethod https://api.github.com/repos/argoproj/argo-cd/releases/latest).tag_name
    
    $url = "https://github.com/argoproj/argo-cd/releases/download/" + $version + "/argocd-windows-amd64.exe"
    $output = "argocd.exe"
    
    Invoke-WebRequest -Uri $url -OutFile $output
    
  3. 转发本地端口 8080 到 argocd-server 服务的 443 端口

    kubectl port-forward svc/argocd-server -n argocd 8080:443
    
  4. 访问 https://localhost:8080/

    默认账户是 admin
    密码需要查看 argocd 命名空间下的机密文件 argocd-initial-admin-secret,机密文件中默认保存的是 base64 格式,可以直接在 minikube dashboard 中查看到解码后的明文。

  5. 添加应用

    官方示例仓库 https://github.com/argoproj/argocd-example-apps 比较难访问,这里克隆到了 Gitee 以方便使用。

    添加时,可以点击右上角的 EDIT AS YAMLyaml 格式添加:

    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: guestbook
    spec:
      destination:
        name: ''
        namespace: default
        server: 'https://kubernetes.default.svc'
      source:
        path: guestbook
        repoURL: 'https://gitee.com/ryukaka/argocd-example-apps'
        targetRevision: HEAD
      project: default
    
  6. 同步应用

    点击上一步创建的应用的 SYNC 按钮和之后弹窗的 SYNCHRONIZE 按钮,就会应用仓库中的部署文件到集群了。

  7. 转发本地 8081 端口到 guestbook-ui 服务

    kubectl port-forward svc/guestbook-ui -n default 8081:80
    
  8. 访问 gusetbook 页面 http://localhost:8081/

  9. 清理 gusetbook 资源

    本机测试完成后,为了释放空间,需要释放占用的资源。

    在 Argo CD UI 中点击 gusetbook 应用上的 DELETE 按钮,之后输入 gusetbook 然后点击 OK 就可以清理 guestbook 占用的资源了。

  10. 清理 Argo CD 占用的资源

    因为网络问题,这里仍然使用了本站的清单文件地址。

    kubectl delete -n argocd -f https://www.liujiajia.me/files/2022/5/29/argocd/install.yaml
    kubectl delete namespace argocd