deepwzh的技术笔记
  • Golang
  • Python
  • Cpp
杂项
前端开发
  • 计算机网络
  • 操作系统
  • 数据库
云原生
Devops
AIGC
关于作者
  • Golang
  • Python
  • Cpp
杂项
前端开发
  • 计算机网络
  • 操作系统
  • 数据库
云原生
Devops
AIGC
关于作者
  • 云原生
  • Helm
  • Etcd
  • harbor
  • 学习资料
  • Fass
  • argo

    • argo
    • Argo cli 用法
  • Docker

    • Docker
    • docker 镜像打包
    • docker 镜像加速
    • 常用命令
    • 进阶 docker 资料
    • distribution/distribution
    • Docker
    • dockerfile 与镜像构建
  • K8s

    • K8s
    • 日志收集
    • 服务网格
    • 常用命令
    • 污点与容忍度
    • Kubectl
    • 应用发布
    • 存储
    • Cert-Manager
    • K8s Pod 生命周期与健康检查
    • 负载均衡器
    • 压力节点驱逐
    • Helm chart
    • 准入控制器

Argo cli 用法

安装

https://argo-cd.readthedocs.io/en/stable/cli_installation/

curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64

授权

添加用户权限

以 admin 为例,新增 apiKey 权限

apiVersion: v1
 data:
   accounts.admin: apiKey, login
 kind: ConfigMap
 metadata:
   labels:
     app.kubernetes.io/name: argocd-cm
     app.kubernetes.io/part-of: argocd
   name: argocd-cm
   namespace: argocd

生成 token

argocd account generate-token --account admin

这样每个命令都可以用如下格式使用

argocd app list --auth-token xxx --server argocd-server.argocd.svc.cluster.local --insecure

配置 token

上述每次都要携带参数太麻烦,可以把 token 填写到配置文件中

  1. 确保配置文件正确设置:
  2. 确保你的 ~/.config/argocd/config 文件中包含正确的 auth-token 字段。例如:
contexts:
- name: default
  server: https://argocd.example.com
  user: admin
current-context: default
users:
- name: admin
  server: https://argocd.example.com
  auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

然后使用 argo 命令就可以采用 token 登录了,适合 cicd 使用

集群管理

添加集群

argocd cluster add my-cluster-context

如果需要指定特定的 kubeconfig 文件,可以通过 --kubeconfig 参数

argocd cluster add my-cluster-context --kubeconfig path/to/extra-kubeconfig.yaml

查看集群列表

argocd cluster list

修改集群名字和命名空间范围

默认的名字是 context 的名字,这个名字可能会不够直观,我们可以通过 set 命令进一步修改名字

同时可以通过—namespace 指定集群可用的命名空间

argocd cluster set cls-rnibyt9z-100040427493-context-default --name app-prod --namespace '*'

或者添加命名空间 A 和 B

argocd cluster argocd cluster set cls-rnibyt9z-100040427493-context-default --name app-prod --namespace 'A' --namespace 'B'
Prev
argo