コンテンツへスキップ

kn のカスタマイズ

config.yaml 設定ファイルを作成することで、kn CLI のセットアップをカスタマイズできます。この設定は、--config フラグを使用するか、デフォルトの場所から取得することで指定できます。デフォルトの設定場所は、XDG ベースディレクトリ仕様に準拠しており、Unix システムと Windows システムで異なります。

  • XDG_CONFIG_HOME 環境変数が設定されている場合、kn が検索するデフォルトの設定場所は $XDG_CONFIG_HOME/kn です。
  • XDG_CONFIG_HOME 環境変数が設定されていない場合、kn はユーザーのホームディレクトリにある $HOME/.config/kn/config.yaml で設定を検索します。
  • Windows システムの場合、デフォルトの kn 設定場所は %APPDATA%\kn です。

構成ファイルの例

# Plugins related configuration
plugins:
  # Whether to lookup configuration in the execution path (default: true). This option is deprecated and will be removed in a future version where path lookup will be enabled unconditionally
  path-lookup: true
  # Directory from where plugins with the prefix "kn-" are looked up. (default: "$base_dir/plugins"
  # where "$base_dir" is the directory where this configuration file is stored)
  directory: ~/.config/kn/plugins
# Eventing related configuration
eventing:
  # List of sink mappings that allow custom prefixes wherever a sink
  # specification is used (like for the --sink option of a broker)
  sink-mappings:
    # Prefix as used in the command (e.g. "--sink svc:myservice")
  - prefix: svc
    # Api group of the mapped resource
    group: core
    # Api version of the mapped resource
    version: v1
    # Resource name (lowercased plural form of the 'kind')
    resource: services
  # Channel mappings that you can use in --channel options
  channel-type-mappings:
    # Alias that can be used as a type for a channel option (e.g. "kn create channel mychannel --type Kafka")
  - alias: Kafka
    # Api group of the mapped resource
    group: messaging.knative.dev
    # Api version of the mapped resource
    version: v1beta1
    # Kind of the resource
    kind: KafkaChannel

ここで

  • path-lookup は、knPATH 環境変数でプラグインを検索するかどうかを指定します。これはブール値の設定オプションです(デフォルト:true)。注:path-lookup オプションは非推奨になり、パス検索が無条件に有効になる将来のバージョンで削除される予定です。
  • directory は、kn がプラグインを検索するディレクトリを指定します。デフォルトパスは、前述のようにオペレーティングシステムによって異なります。これは、ユーザーから見える任意のディレクトリにできます(デフォルト:$base_dir/plugins、ここで $base_dir はこの設定ファイルが保存されているディレクトリです)。
  • sink-mappings は、kn CLI コマンドで --sink フラグを使用するときに使用される Kubernetes Addressable リソースを定義します。
    • prefix:シンクを記述するために使用するプレフィックス。Service、svcchannel、および broker は、kn で事前定義されたプレフィックスです。
    • group:Kubernetes リソースの API グループ。
    • version:Kubernetes リソースのバージョン。
    • resource:Kubernetes リソースタイプの小文字の複数形名。たとえば、servicesbrokers など。
  • channel-type-mappings は、チャネルタイプが必要な場所(kn channel create --type など)で使用できるカスタムチャネルタイプのエイリアスを定義するために使用できます。この構成セクションでは、次のフィールドを持つエントリの配列を定義します。
  • alias:タイプとして使用できる名前
  • group:チャネル CRD の APIGroup。
  • version:チャネル CRD のバージョン。
  • kind:チャネル CRD の種類(例:KafkaChannel

サイトトラフィックを理解するために、分析と Cookie を使用します。当サイトの利用に関する情報は、その目的のために Google と共有されます。詳細はこちら。