Configuration


Overview

K9s leverages XDG to keep its configuration files under $XDG_CONFIG_HOME/k9s. The default configuration will vary across operating system so be sure to read up on the default location if you choose not to set that environment variable. The main configuration file is named config.yaml and stores various K9s specific bits.

For information on the default locations for your OS please see this link. If you are still confused a quick k9s info will reveal where k9s is loading its configurations from.

Unix macOS Windows
~/.config/k9s ~/Library/Application Support/k9s %LOCALAPPDATA%\k9s

Alternatively, you can set K9S_CONFIG_DIR to tell K9s the directory location to pull its configurations from.


This is still in flux and will change while in pre-release stage!


K9s CLI Configuration

# $XDG_HOME/k9s/config.yaml
# File will be autogenerated with all the default fixins if not found in the config specification.
k9s:
  # Enable periodic refresh of resource browser windows. Default false
  liveViewAutoRefresh: false
  # Represents ui poll intervals. Default 2secs
  refreshRate: 2
  # Number of retries once the connection to the api-server is lost. Default 15.
  maxConnRetry: 5
  # Specifies if modification commands like delete/kill/edit are disabled. Default is false
  readOnly: false
  # Toggles whether k9s should exit when CTRL-C is pressed. When set to true, you will need to exist k9s via the :quit command. Default is false.
  noExitOnCtrlC: false
  ui: # NOTE! [K9s v0.30.0]
    # Enable mouse support. Default false
    enableMouse: false
    # Set to true to hide K9s header. Default false
    headless: false
    # Set to true to hide K9s logo. Default false
    logoless: false
    # Set to true to hide K9s crumbs. Default false
    crumbsless: false
    # Toggles reactive UI. This option provide for watching on disk artifacts changes and update the UI live  Defaults to false.
    reactive: false
    # Toggles icons display as not all terminal support these chars.
    noIcons: false
  # Toggles whether k9s should check for the latest revision from the Github repository releases. Default is false.
  skipLatestRevCheck: false
  # Disable count pods while in node view. Default is false.
  disablePodCounting: false
  # ShellPod configuration applies to all your clusters
  shellPod:
    # The shell pod image to use.
    image: busybox:1.35.0
    # The namespace to launch to shell pod into.
    namespace: default
    # The resource limit to set on the shell pod.
    limits:
      cpu: 100m
      memory: 100Mi
    # Enable TTY
    tty: true
  # ImageScan config changed from v0.29.0!
  imageScans:
    enable: false
    # Exclusions excludes namespaces or specific workload labels
    exclusions:
      # Exclude the following namespaces for image vulscans!
      namespaces:
        - kube-system
        - fred
      # Exclude pods with the following labels from image vulscans!
      labels:
        k8s-app:
          - kindnet
          - bozo
        env:
          - dev
  # Logs configuration
  logger:
    # Defines the number of lines to return. Default 100
    tail: 100
    # Defines the total number of log lines to allow in the view. Default 1000
    buffer: 5000
    # Represents how far to go back in the log timeline in seconds. Setting to -1 will tail logs. Default is -1.
    sinceSeconds: 300
    # Go full screen while displaying logs. Default false
    fullScreen: false
    # Toggles log line wrap. Default false
    textWrap: false
    # Toggles log line timestamp info. Default false
    showTime: false
  # Global memory/cpu thresholds. When set will alert when thresholds are met.
  thresholds:
    cpu:
      critical: 90
      warn: 70
    memory:
      critical: 90
      warn: 70

Now looking at a given context configuration i.e cluster-1/context-1/config.yaml

# $XDG_DATA_HOME/k9s/clusters/bumblebeetuna/blee/config.yaml
k9s:
  # The name of the context parent cluster
  cluster: bumblebeetuna
  readOnly: false          # [NEW!] you can now single out a given context and make it readonly. Woof!
  skin: in_the_navy        # [NEW!] you can also skin individual contexts. Woof Woof!
  # Tracks namespace configuration
  namespace:
    # Active namespace
    active: default
    # Disable k9s favorites ns updates.
    lockFavorites: false
    # Favorite namespaces.
    favorites:
    - all
    - kube-system
    - default
  # Active view
  view:
    active: dp
  # Feature gates toggle k9s features
  featureGates:
    # Enable/Disable nodeShell
    nodeShell: false
  # Default port forward host
  portForwardAddress: localhost

Env variables

You can now override the context portForward default address configuration by setting an env variable that will override all clusters portForward local address using K9S_DEFAULT_PF_ADDRESS=a.b.c.d

You can also globally override the context configuration by setting an env variable that will override all clusters node shell gate using K9S_FEATURE_GATE_NODE_SHELL=true|false


 Back



© 2024 Imhotep Software LLC. All materials licensed under Apache v2.0