Skip to content

Profiles API

nyl.profiles.config

KubeconfigFromSsh dataclass

Represents how to obtain the Kubeconfig from an SSH connection.

context: str | None = None class-attribute instance-attribute

The context to use from the Kubeconfig file. If not specified, the current context is used.

host: str instance-attribute

The remote host to connect to.

identity_file: str | None = None class-attribute instance-attribute

An SSH private key file to use for authentication.

path: str instance-attribute

The path where the Kubeconfig can be retrieved from.

port: int = 22 class-attribute instance-attribute

SSH port to use.

replace_apiserver_hostname: str | None = None class-attribute instance-attribute

Replace the hostname in the apiserver configuration of the Kubeconfig. This is useful for example with K3s when reading reading the /etc/rancher/k3s/k3s.yaml file from a remote host, but the API server in that file is not reachable from that machine.

Note that if the host in the retrieve Kubeconfig is localhost, 0.0.0.0 or 127.0.0.1, it will be automatically replaced with the specified host that was also SSH-ed to, unless this option is set.

sudo: bool = False class-attribute instance-attribute

Use sudo cat to retrieve the file instead of ust cat.

user: str instance-attribute

The username to connect to the remote host with.

LocalKubeconfig dataclass

Use the local Kubeconfig file, either from the default location or a custom path specified in the environment.

context: str | None = None class-attribute instance-attribute

The context to use from the Kubeconfig file. If not specified, the current context is used.

path: str | None = None class-attribute instance-attribute

Path to the Kubernetes configuration file. Relative to the profile configuration file. If not specified, it falls back to the default location (per KUBECONFIG or otherwise ~/.kube/config).

Profile dataclass

Represents a Kubernetes connection profile.

kubeconfig: LocalKubeconfig | KubeconfigFromSsh = field(default_factory=lambda: LocalKubeconfig()) class-attribute instance-attribute

Describe how the Kubeconfig is to be obtained.

tunnel: SshTunnel | None = None class-attribute instance-attribute

Describe how to create an SSH tunnel to reach the Kubernetes cluster API.

ProfileConfig dataclass

load(file=None, /, *, cwd=None, required=True) staticmethod

Load the profiles configuration from the given file or the default file. If the configuration file does not exist, an error is raised unless required is set to False, in which case an empty configuration is returned.

SshTunnel dataclass

Configuration for an SSH tunnel.

host: str instance-attribute

The host to tunnel through.

identity_file: str | None = None class-attribute instance-attribute

An SSH private key file to use for authentication.

user: str instance-attribute

The username to connect to the remote host with.