CLI リファレンス
kubetail CLI は、デスクトップ環境で Kubetail を使うための主要なエントリーポイントです。Web ダッシュボードの起動、ターミナルへのログのストリーミング、クラスタ内の Kubetail リソース管理に利用できます。
グローバルフラグ
Section titled “グローバルフラグ”これらのフラグはすべてのコマンドで利用できます。
| Flag | Default | Description |
|---|---|---|
--kubeconfig | kubeconfig ファイルへのパス | |
--in-cluster | false | In-Cluster Kubernetes 設定を使用 |
-c, --config | ~/.kubetail/config.yaml | 設定ファイルへのパス |
kubetail serve
Section titled “kubetail serve”dashboard server を起動し、標準ブラウザーで Web UI を開きます。
kubetail serve [flags]フラグ
| Flag | Default | Description |
|---|---|---|
-p, --port | 7500 | 待ち受けポート番号 |
--host | localhost | バインドするホストアドレス |
-l, --log-level | info | ログレベル (debug, info, warn, error, disabled) |
--skip-open | false | ブラウザーを開かない |
例
# dashboard を起動する(http://localhost:7500 で開く)kubetail serve
# カスタムポートを使うkubetail serve --port 8080
# ブラウザーを開かずに起動するkubetail serve --skip-openkubetail logs
Section titled “kubetail logs”コンテナ、または複数の workload container のログを取得します。
kubetail logs [source1] [source2] ... [flags]ソース
ソースは、どの Pod やコンテナからログをストリーミングするかを指定します。ソースは次の構文を使用します。
[namespace:]<resource>[/name[/container]]| Example | Description |
|---|---|
web-abc123 | default namespace にある web-abc123 という Pod |
deployments/web | default namespace にある web Deployment |
deployments/* | default namespace にあるすべての Deployment |
deployments/web/container1 | Deployment 内の特定コンテナ |
deployments/web/* | Deployment 内のすべてのコンテナ |
frontend:web-abc123 | frontend namespace にある Pod |
frontend:deployments/web | frontend namespace にある Deployment |
複数のソースを指定できます。
kubetail logs <source1> <source2>フラグ
| Flag | Default | Description |
|---|---|---|
--kube-context | 使用する kubeconfig context | |
-h, --head[=N] | 10 | 先頭 N 件のレコードを返す |
-t, --tail[=N] | 10 | 末尾 N 件のレコードを返す |
--all | false | すべてのレコードを返す |
-f, --follow | false | 新しいレコードをストリーミングする |
--since | 指定した時点以降のレコードを含める(含む) | |
--until | 指定した時点までのレコードを含める(含む) | |
--after | 指定した時点より後のレコードのみを含める | |
--before | 指定した時点より前のレコードのみを含める | |
-g, --grep | 正規表現でレコードを絞り込む(--force が必要) | |
--region | region でソース Pod を絞り込む(カンマ区切り) | |
--zone | zone でソース Pod を絞り込む(カンマ区切り) | |
--os | OS でソース Pod を絞り込む(カンマ区切り) | |
--arch | CPU アーキテクチャでソース Pod を絞り込む(カンマ区切り) | |
--node | node 名でソース Pod を絞り込む(カンマ区切り) | |
--raw | false | メタデータなしで生ログメッセージのみを出力 |
--columns | 出力列を設定する(既定値を上書き) | |
--add-columns | 既定の出力列に追加する | |
--remove-columns | 既定の出力列から削除する | |
--with-cursors | false | ページングカーソルを表示する |
--hide-header | false | テーブルヘッダーを隠す |
--all-containers | false | Pod 内のすべてのコンテナのログを表示する |
--force | false | コマンドを強制実行する(--grep 使用時に必須) |
--columns、--add-columns、--remove-columns は、カンマ区切りの列名リストを受け付けます: timestamp, dot, node, region, zone, os, arch, namespace, pod, container。
--head、--tail、--all は相互排他的です。--since と --after、--until と --before もそれぞれ相互排他的です。
--since、--until、--after、--before は次を受け付けます。
- ISO 8601 タイムスタンプ(例:
2006-01-02T15:04:05Z07:00) - 現在時刻からの ISO 8601 duration(例: 30 分前を表す
PT30M)---sinceと--untilのみ
既定の動作: --since が指定されていない場合は tail モード(直近 10 件)。--since が指定された場合は head モードになります。
例
# Pod の直近 10 件を表示するkubetail logs nginx
# Deployment を tail するkubetail logs deployments/web
# 新しいレコードを追跡するkubetail logs deployments/web --follow
# すべてのレコードを返し、そのまま追跡するkubetail logs deployments/web --all --follow
# 最初の 100 件を返すkubetail logs nginx --head=100
# 過去 30 分間のレコードを返すkubetail logs nginx --since PT30M --all
# 2 つのタイムスタンプの間のレコードを返すkubetail logs nginx --since 2006-01-02T15:04:05Z --until 2007-01-02T15:04:05Z --all
# 正規表現でフィルターする(--force が必要)kubetail logs nginx --grep "GET /about" --force
# region で Pod を絞り込むkubetail logs deployments/web --region=us-east-1
# 生ログメッセージのみを出力するkubetail logs nginx --rawkubetail cluster
Section titled “kubetail cluster”Helm を内部的に使用して Kubetail のクラスタリソースを管理します(Helm を別途インストールする必要はありません)。
kubetail cluster <subcommand> [flags]kubetail cluster install
Section titled “kubetail cluster install”クラスタ内に新しい Kubetail release を作成します。
kubetail cluster install [flags]フラグ
| Flag | Default | Description |
|---|---|---|
--kube-context | 使用する kubeconfig context 名 |
例
kubetail cluster installkubetail cluster upgrade
Section titled “kubetail cluster upgrade”既存の Kubetail release を、ローカルで利用可能な最新の chart version にアップグレードします。
kubetail cluster upgrade [flags]フラグ
| Flag | Default | Description |
|---|---|---|
--kube-context | 使用する kubeconfig context 名 |
例
kubetail cluster upgradekubetail cluster uninstall
Section titled “kubetail cluster uninstall”既存の Kubetail release をクラスタから削除します。
kubetail cluster uninstall [flags]フラグ
| Flag | Default | Description |
|---|---|---|
--kube-context | 使用する kubeconfig context 名 |
例
kubetail cluster uninstallkubetail cluster list
Section titled “kubetail cluster list”現在インストールされている Kubetail release を一覧表示します。
kubetail cluster list [flags]フラグ
| Flag | Default | Description |
|---|---|---|
--kube-context | 使用する kubeconfig context 名 |
例
kubetail cluster listkubetail cluster repo
Section titled “kubetail cluster repo”Kubetail の Helm chart リポジトリを管理します (https://kubetail-org.github.io/helm-charts/)。
kubetail cluster repo <subcommand>| Subcommand | Description |
|---|---|
add | Kubetail chart repository を Helm に追加する |
update | Kubetail chart repository を Helm で更新する |
remove | Kubetail chart repository を Helm から削除する |
例
kubetail cluster repo addkubetail cluster repo updatekubetail cluster repo removekubetail config
Section titled “kubetail config”Kubetail CLI の設定を管理します。
kubetail config <subcommand>kubetail config init
Section titled “kubetail config init”既定の設定ファイルを作成します。
kubetail config init [flags]フラグ
| Flag | Default | Description |
|---|---|---|
--path | ~/.kubetail/config.yaml | 設定ファイルの出力先パス |
--format | yaml | 設定ファイル形式 (yaml, json, toml) |
--force | false | 既存の設定ファイルを上書きする |
例
# ~/.kubetail/config.yaml に既定設定を作成するkubetail config init
# JSON 形式で設定を作成するkubetail config init --format json
# 既存の設定ファイルを上書きするkubetail config init --force
# カスタムパスに設定を書き出すkubetail config init --path /etc/kubetail/config.yamlCLI は YAML(または JSON/TOML)の設定ファイルで構成できます。既定では ~/.kubetail/config.yaml から読み込まれます。kubetail config init で既定の設定ファイルを生成するか、グローバルフラグ -c / --config でカスタムパスを指定してください。
## Kubetail CLI Configuration File## This file defines the behavior for the kubetail CLI tool,# including logs command defaults and dashboard server settings.#
## version #### Schema version for the configuration file#version: 1
## general ###general:
## kubeconfig ## # # Path to the kubeconfig file to use for CLI requests. # If empty, the default path (~/.kube/config) or KUBECONFIG env var is used. # # Default value: "" # kubeconfig: ""
## commands ###commands:
## logs ## # # Settings specific to the 'logs' subcommand # logs:
## kube-context ## # # The specific Kubernetes context to use. # If empty, the current active context is used. # # Default value: "" # kube-context: ""
## head ## # # The number of lines to show from the beginning of the log buffer # # Default value: 10 # head: 10
## tail ## # # The number of lines to show from the end of the log buffer # # Default value: 10 # tail: 10
## columns ## # # Full set of output columns for 'logs' records. # Allowed values: timestamp,dot,node,region,zone,os,arch,namespace,pod, container # # Default value: ["timestamp", "dot"] # columns: - timestamp - dot
## serve ## # # Settings for the dashboard server # serve:
## host ## # # The network interface the server should bind to. # # Default value: localhost # host: localhost
## port ## # # The TCP port the server will listen on. # # Default value: 7500 # port: 7500
## skip-open ## # # If true, the CLI will not automatically open the browser # when the server starts. # # Default value: false # skip-open: false
## dashboard #### Settings for the web dashboard UI#dashboard:
## columns ## # # The default columns to show when displaying log records. # # Default value: ["timestamp", "dot"] # columns: - timestamp - dot# Kubetail CLI Configuration File## Defines behavior for the kubetail CLI tool, including# logs command defaults and dashboard server settings.
# Schema version for the configuration fileversion = 1
[general]# Path to kubeconfig. If empty, uses ~/.kube/config or KUBECONFIG env var.kubeconfig = ""
[commands.logs]# Specific Kubernetes context to use. If empty, uses active context.kube-context = ""
# Number of lines to show from the beginning of the log bufferhead = 10
# Number of lines to show from the end of the log buffertail = 10
# Full set of output columns for 'logs' records.# Allowed values: timestamp,dot,node,region,zone,os,arch,namespace,pod,containercolumns = ["timestamp", "dot"]
[commands.serve]# Network interface the server binds tohost = "localhost"
# TCP port the server listens onport = 7500
# If true, don't automatically open browser when server startsskip-open = false
[dashboard]# The default columns to show when displaying log records.columns = ["timestamp", "dot"]{ "version": 1, "general": { "kubeconfig": "" }, "commands": { "logs": { "kube-context": "", "head": 10, "tail": 10, "columns": ["timestamp", "dot"] }, "serve": { "host": "localhost", "port": 7500, "skip-open": false } }, "dashboard": { "columns": ["timestamp", "dot"] }}