0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

argocdへCLIでログインする

Posted at

背景

argocdへGUIではログイン出来たのにCLIでの方法がいまいちピンときていなかったので、備忘録として記す。

ログイン方法

公式にもCLIでのログイン方法を出していたが、対象となるサーバをどのように確認すれば良いのか、は書かれていないので記載する。

①argocdコマンドをインストール

argocdへログインするには、argocdコマンドをインストールする必要があるのでインストールする

# brew tap argoproj/tap
# brew install argoproj/tap/argocd

②argocdへのログインコマンドを確認

-hでログインコマンド自体の使い方を参照

# argocd login -h
Log in to Argo CD

Usage:
  argocd login SERVER [flags]

Examples:
# Login to Argo CD using a username and password
argocd login cd.argoproj.io

# Login to Argo CD using SSO
argocd login cd.argoproj.io --sso

# Configure direct access using Kubernetes API server
argocd login cd.argoproj.io --core

Flags:
  -h, --help              help for login
      --name string       name to use for the context
      --password string   the password of an account to authenticate
      --sso               perform SSO login
      --sso-port int      port to run local OAuth2 login application (default 8085)
      --username string   the username of an account to authenticate

Global Flags:
      --auth-token string               Authentication token
      --client-crt string               Client certificate file
      --client-crt-key string           Client certificate key file
      --config string                   Path to Argo CD config (default "/Users/arisa_ookawa/.argocd/config")
      --core                            If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
      --grpc-web                        Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
      --grpc-web-root-path string       Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
  -H, --header strings                  Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
      --http-retry-max int              Maximum number of retries to establish http connection to Argo CD server
      --insecure                        Skip server certificate and domain verification
      --logformat string                Set the logging format. One of: text|json (default "text")
      --loglevel string                 Set the logging level. One of: debug|info|warn|error (default "info")
      --plaintext                       Disable TLS
      --port-forward                    Connect to a random argocd-server port using port forwarding
      --port-forward-namespace string   Namespace name which should be used for port forwarding
      --server string                   Argo CD server address
      --server-crt string               Server certificate file

③ログインコマンドを使ってログイン

以下コマンドを使ってログインする。
ログインに成功すると、表示のようにsuccessfullyと表示されるので、確認する

# argocd login --insecure localhost:8080
Username: admin
Password:
'admin:login' logged in successfully
Context 'localhost:8080' updated

尚、ログイン時のパスワードが上手くいかない場合は、argocdにログイン出来なかった時の対処法を参照すると良い。

おまけ

CLIログインした後、パスワードをCLIで変更したい時は、以下コマンドを使う

# argocd account update-password

尚、パスワードを新たに設定する上で文字制限があるらしく、失敗すると以下のような表示に..成功verとの比較を載せておく

# -----失敗した場合-----#
# argocd account update-password
 *** Enter current password:
 *** Enter new password:
 *** Confirm new password:
 FATA[0039] rpc error: code = Unknown desc = New password does not match the following expression: ^.{8,32}$.

# -----成功した場合-----#
# argocd account update-password
 *** Enter current password:
 *** Enter new password:
 *** Confirm new password:
 Password updated
 Context 'localhost:8080' updated

まとめ

これでCLIログインはバッチリ。

参考資料

EKSでArgo CDのチュートリアルを試してみた
4.Login Using The CLI

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?