CLI

install argocd cli

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

# macos
brew install argocd

# linux latest
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x /usr/local/bin/argocd

# linux version
VERSION=<TAG> # Select desired TAG from https://github.com/argoproj/argo-cd/releases
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/$VERSION/argocd-linux-amd64
chmod +x /usr/local/bin/argocd

https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd/

port forwarding

kubectl port-forward svc/argocd-server -n argocd 8080:443

์ ‘์† ํ™•์ธ

https://localhost:8080

get password

k -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d && echo

login

argocd login localhost:8080
>admin

password ๋ณ€๊ฒฝ

# argocd account update-password --account <new-username> --new-password <new-password>
argocd account update-password
argocd account update-password --account admin --new-password xxxx

add user

create configmap

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
  namespace: argocd
  labels:
    app.kubernetes.io/name: argocd-cm
    app.kubernetes.io/part-of: argocd
data:
  # add an additional local user with apiKey and login capabilities
  #   apiKey - allows generating API keys
  #   login - allows to login using UI
  accounts.dev: login
  # disables user. User is enabled by default
  accounts.dev.enabled: 'false'
  # add an additional local user with apiKey and login capabilities
  # admin
  accounts.admin: apiKey #token์„ ๋งŒ๋“ค๊ธฐ์œ„ํ•ด์„œ ๋„ฃ์–ด์คŒ.
k apply -f argocd-cm.yml

create token

argocd account generate-token --account dev

--account๊ฐ€ ์—†์œผ๋ฉด ํ˜„์žฌ ๋กœ๊ทธ์ธ๋œ ์œ ์ €

์–ด๋“œ๋ฏผ์˜ ๊ฒฝ์šฐ ์œ„์˜ ์˜ˆ์ œ์ฒ˜๋Ÿผ ์ถ”๊ฐ€๋กœ ๋„ฃ์–ด์ค˜์•ผํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ปค๋งจ๋“œ๋กœ ์ƒ์„ฑ์‹œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋Š”๊ฒฝ์šฐ๋„ ์žˆ๋‹ค. ์ด๋•Œ๋Š” ์›น์—์„œ ์ƒ์„ฑํ•˜๋ฉด๋œ๋‹ค.

role ์ถ”๊ฐ€

์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด๋„ ๊ถŒํ•œ์„ ์•ˆ์ฃผ๋ฉด ์•„๋ฌด๊ฒƒ๋„ ๋ณด์ด์ง€ ์•Š๋Š”๋‹ค.

์—…๋ฐ์ดํŠธํ•ด๋ณด์ž.

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-rbac-cm
  namespace: argocd
data:
  policy.default: role:readonly
  policy.csv: |
    p, role:dev, applications, get, */*, allow
    p, role:dev, applications, sync, */*, allow
    p, role:dev, repositories, get, *, allow
    g, dev, role:dev

# https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/
k apply -f argocd-rbac-cm.yml

dev๋ผ๋Š” ์œ ์ €๋ฅผ ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ–ˆ๊ณ  sync๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ–‡๋‹ค.

add repo

argocd repo add git@github.com:YOUR/argocd.git \
--ssh-private-key-path ~/.ssh/argocd

add app

# Create a directory app
argocd app create guestbook \
  --repo https://github.com/argoproj/argocd-example-apps.git \
  --path guestbook \
  --dest-namespace default \
  --dest-server https://kubernetes.default.svc \
  --directory-recurse

# Create a Kustomize app
argocd app create kustomize-guestbook \
  --repo https://github.com/argoproj/argocd-example-apps.git \
  --path kustomize-guestbook \
  --dest-namespace default \
  --dest-server https://kubernetes.default.svc \
  --kustomize-image gcr.io/heptio-images/ks-guestbook-demo:0.1

get app

argocd app get APPNAME

app sync

NAME=default
argocd app sync ${NAME} --prune --force
argocd app wait ${NAME} --timeout 1200

app delete

argocd app delete homesecurity-hms
argocd app delete homesecurity-hms --cascade=false

how to use token

export ARGOCD_SERVER=argocd.mycompany.com
export ARGOCD_AUTH_TOKEN=<JWT token generated from project>
argocd app sync guestbook
argocd app wait guestbook

refernce

Last updated