ArgoCD 使用示例

发布时间: 更新时间: 总字数:223 阅读时间:1m 作者: IP上海 分享 网址

ArgoCD 使用示例

示例

  • argocd 检测 git 频率:timeout.reconciliation: 180s参考

权限

AppProject

  • 创建一个 Project 并指定 role
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: abc
  namespace: argocd
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  clusterResourceWhitelist:
  - group: '*'
    kind: '*'
  namespaceResourceWhitelist:
  - group: '*'
    kind: '*'
  description: abc Team AppProject
  destinations:
  - name: in-cluster
    namespace: argocd
    server: https://kubernetes.default.svc
  - name: in-cluster
    namespace: abc
    server: https://kubernetes.default.svc
  roles:
  - name: admin
    description: admin privileges to abc
    groups:
    - <some-group>
    policies:
    - p, proj:abc:admin, applications, *, abc/*, allow
  - name: readonly
    description: Read-only privileges to abc
    groups:
    - <some-group>
    policies:
    - p, proj:abc:readonly, applications, get, abc/*, allow
  sourceRepos:
  - https://github.com/xiexianbin/k8s-manifests.git

json 格式问题

  • 当 workflows 参数为 json 时,会出现 workflow.parameters.json 非标准字符串(双引号问题),可参考解决
from base64 import b64decode
from json import loads
from json.decoder import JSONDecodeError

parameters_json = b64decode(r"{{=sprig.b64enc(workflow.parameters.json)}}".encode()).decode()
try:
  parameters = loads(parameters_json)
except JSONDecodeError as e:
  print(f"JSON not ok: {e}")
  raise e
except Exception as e:
  print(f"Something not ok: {e}")
  raise e
else:
  print(parameters)
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数