Show / Hide Table of Contents

Class KubernetesClientConfiguration

Represents a set of kubernetes client configuration settings

Inheritance
object
KubernetesClientConfiguration
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: k8s
Assembly: KubernetesClient.dll
Syntax
public class KubernetesClientConfiguration

Constructors

View Source

KubernetesClientConfiguration()

Declaration
public KubernetesClientConfiguration()

Fields

View Source

KubeConfigDefaultLocation

kubeconfig Default Location

Declaration
public static readonly string KubeConfigDefaultLocation
Field Value
Type Description
string

Properties

View Source

AccessToken

Gets or sets the access token for OAuth2 authentication.

Declaration
public string AccessToken { get; set; }
Property Value
Type Description
string

The access token.

View Source

ClientCertificateData

Gets ClientCertificateData

Declaration
public string ClientCertificateData { get; set; }
Property Value
Type Description
string
View Source

ClientCertificateFilePath

Gets ClientCertificate filename

Declaration
public string ClientCertificateFilePath { get; set; }
Property Value
Type Description
string
View Source

ClientCertificateKeyData

Gets ClientCertificate Key

Declaration
public string ClientCertificateKeyData { get; set; }
Property Value
Type Description
string
View Source

ClientCertificateKeyStoreFlags

Gets or sets the ClientCertificate KeyStoreFlags to specify where and how to import the certificate private key

Declaration
public X509KeyStorageFlags? ClientCertificateKeyStoreFlags { get; set; }
Property Value
Type Description
X509KeyStorageFlags?
View Source

ClientKeyFilePath

Gets ClientCertificate Key filename

Declaration
public string ClientKeyFilePath { get; set; }
Property Value
Type Description
string
View Source

CurrentContext

Gets CurrentContext

Declaration
public string CurrentContext { get; }
Property Value
Type Description
string
View Source

DisableHttp2

Do not use http2 even it is available

Declaration
public bool DisableHttp2 { get; set; }
Property Value
Type Description
bool
View Source

ExecTimeout

Exec process timeout

Declaration
public static TimeSpan ExecTimeout { get; set; }
Property Value
Type Description
TimeSpan
View Source

FirstMessageHandlerSetup

Gets or sets the FirstMessageHandler setup callback.

Declaration
public Action<SocketsHttpHandler> FirstMessageHandlerSetup { get; set; }
Property Value
Type Description
Action<SocketsHttpHandler>

The FirstMessageHandler factory.

Remarks

Allow custom configuration of the first http handler.

View Source

Host

Gets Host

Declaration
public string Host { get; set; }
Property Value
Type Description
string
View Source

HttpClientTimeout

Timeout of REST calls to Kubernetes server Does not apply to watch related api

Declaration
public TimeSpan HttpClientTimeout { get; set; }
Property Value
Type Description
TimeSpan

timeout

View Source

JsonSerializerOptions

Options for the JsonSerializer to override the default ones.

Declaration
public JsonSerializerOptions JsonSerializerOptions { get; }
Property Value
Type Description
JsonSerializerOptions
View Source

Namespace

Gets current namespace

Declaration
public string Namespace { get; set; }
Property Value
Type Description
string
View Source

Password

Gets or sets the password (HTTP basic authentication).

Declaration
public string Password { get; set; }
Property Value
Type Description
string

The password.

View Source

SkipTlsVerify

Gets a value indicating whether to skip ssl server cert validation

Declaration
public bool SkipTlsVerify { get; set; }
Property Value
Type Description
bool
View Source

SslCaCerts

Gets SslCaCerts

Declaration
public X509Certificate2Collection SslCaCerts { get; set; }
Property Value
Type Description
X509Certificate2Collection
View Source

TlsServerName

Option to override the TLS server name

Declaration
public string TlsServerName { get; set; }
Property Value
Type Description
string
View Source

TokenProvider

Gets or sets the TokenProvider for authentication.

Declaration
public ITokenProvider TokenProvider { get; set; }
Property Value
Type Description
ITokenProvider

The access token.

View Source

UserAgent

Gets or sets the HTTP user agent.

Declaration
public string UserAgent { get; set; }
Property Value
Type Description
string

Http user agent.

View Source

Username

Gets or sets the username (HTTP basic authentication).

Declaration
public string Username { get; set; }
Property Value
Type Description
string

The username.

Methods

View Source

AddJsonOptions(Action<JsonSerializerOptions>)

Configures k8s.KubernetesJson.JsonSerializerOptions for the JsonSerializer. To override existing converters, add them to the top of the Converters list e.g. as follows:

options.Converters.Insert(index: 0, new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
Declaration
public void AddJsonOptions(Action<JsonSerializerOptions> configure)
Parameters
Type Name Description
Action<JsonSerializerOptions> configure

An Action to configure the k8s.KubernetesJson.JsonSerializerOptions.

View Source

BuildConfigFromConfigFile(FileInfo, string, string, bool)

Initializes a new instance of the KubernetesClientConfiguration from config file

Declaration
public static KubernetesClientConfiguration BuildConfigFromConfigFile(FileInfo kubeconfig, string currentContext = null, string masterUrl = null, bool useRelativePaths = true)
Parameters
Type Name Description
FileInfo kubeconfig

Fileinfo of the kubeconfig, cannot be null

string currentContext

override the context in config file, set null if do not want to override

string masterUrl

override the kube api server endpoint, set null if do not want to override

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
KubernetesClientConfiguration

Instance of theKubernetesClientConfiguration class

View Source

BuildConfigFromConfigFile(Stream, string, string)

Initializes a new instance of the KubernetesClientConfiguration from config file

Declaration
public static KubernetesClientConfiguration BuildConfigFromConfigFile(Stream kubeconfig, string currentContext = null, string masterUrl = null)
Parameters
Type Name Description
Stream kubeconfig

Stream of the kubeconfig, cannot be null

string currentContext

Override the current context in config, set null if do not want to override

string masterUrl

Override the Kubernetes API server endpoint, set null if do not want to override

Returns
Type Description
KubernetesClientConfiguration

Instance of theKubernetesClientConfiguration class

View Source

BuildConfigFromConfigFile(string, string, string, bool)

Initializes a new instance of the KubernetesClientConfiguration from config file

Declaration
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfigPath = null, string currentContext = null, string masterUrl = null, bool useRelativePaths = true)
Parameters
Type Name Description
string kubeconfigPath

Explicit file path to kubeconfig. Set to null to use the default file path

string currentContext

override the context in config file, set null if do not want to override

string masterUrl

kube api server endpoint

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
KubernetesClientConfiguration

Instance of theKubernetesClientConfiguration class

View Source

BuildConfigFromConfigFileAsync(FileInfo, string, string, bool)

Initializes a new instance of the KubernetesClientConfiguration from config file

Declaration
public static Task<KubernetesClientConfiguration> BuildConfigFromConfigFileAsync(FileInfo kubeconfig, string currentContext = null, string masterUrl = null, bool useRelativePaths = true)
Parameters
Type Name Description
FileInfo kubeconfig

Fileinfo of the kubeconfig, cannot be null

string currentContext

override the context in config file, set null if do not want to override

string masterUrl

override the kube api server endpoint, set null if do not want to override

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
Task<KubernetesClientConfiguration>

Instance of theKubernetesClientConfiguration class

View Source

BuildConfigFromConfigFileAsync(Stream, string, string)

Initializes a new instance of the KubernetesClientConfiguration from config file

Declaration
public static Task<KubernetesClientConfiguration> BuildConfigFromConfigFileAsync(Stream kubeconfig, string currentContext = null, string masterUrl = null)
Parameters
Type Name Description
Stream kubeconfig

Stream of the kubeconfig, cannot be null

string currentContext

Override the current context in config, set null if do not want to override

string masterUrl

Override the Kubernetes API server endpoint, set null if do not want to override

Returns
Type Description
Task<KubernetesClientConfiguration>

Instance of theKubernetesClientConfiguration class

View Source

BuildConfigFromConfigObject(K8SConfiguration, string, string)

Initializes a new instance of KubernetesClientConfiguration from pre-loaded config object.

Declaration
public static KubernetesClientConfiguration BuildConfigFromConfigObject(K8SConfiguration k8SConfig, string currentContext = null, string masterUrl = null)
Parameters
Type Name Description
K8SConfiguration k8SConfig

A K8SConfiguration, for example loaded from LoadKubeConfigAsync(string, bool)

string currentContext

Override the current context in config, set null if do not want to override

string masterUrl

Override the Kubernetes API server endpoint, set null if do not want to override

Returns
Type Description
KubernetesClientConfiguration

Instance of theKubernetesClientConfiguration class

View Source

BuildDefaultConfig()

Initializes a new instance of the KubernetesClientConfiguration from default locations If the KUBECONFIG environment variable is set, then that will be used. Next, it looks for a config file at KubeConfigDefaultLocation. Then, it checks whether it is executing inside a cluster and will use InClusterConfig(). Finally, if nothing else exists, it creates a default config with localhost:8080 as host.

Declaration
public static KubernetesClientConfiguration BuildDefaultConfig()
Returns
Type Description
KubernetesClientConfiguration

Instance of theKubernetesClientConfiguration class

Remarks

If multiple kubeconfig files are specified in the KUBECONFIG environment variable, merges the files, where first occurrence wins. See https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files.

View Source

CreateRunnableExternalProcess(ExternalExecution, EventHandler<DataReceivedEventArgs>)

Declaration
public static Process CreateRunnableExternalProcess(ExternalExecution config, EventHandler<DataReceivedEventArgs> captureStdError = null)
Parameters
Type Name Description
ExternalExecution config
EventHandler<DataReceivedEventArgs> captureStdError
Returns
Type Description
Process
View Source

ExecuteExternalCommand(ExternalExecution)

Implementation of the proposal for out-of-tree client authentication providers as described here -- https://github.com/kubernetes/community/blob/master/contributors/design-proposals/auth/kubectl-exec-plugins.md Took inspiration from python exec_provider.py -- https://github.com/kubernetes-client/python-base/blob/master/config/exec_provider.py

Declaration
public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution config)
Parameters
Type Name Description
ExternalExecution config

The external command execution configuration

Returns
Type Description
ExecCredentialResponse

The token, client certificate data, and the client key data received from the external command execution

View Source

InClusterConfig()

Declaration
public static KubernetesClientConfiguration InClusterConfig()
Returns
Type Description
KubernetesClientConfiguration
View Source

IsInCluster()

Declaration
public static bool IsInCluster()
Returns
Type Description
bool
View Source

LoadKubeConfig(FileInfo, bool)

Loads Kube Config

Declaration
public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig, bool useRelativePaths = true)
Parameters
Type Name Description
FileInfo kubeconfig

Kube config file contents

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
K8SConfiguration

Instance of the K8SConfiguration class

View Source

LoadKubeConfig(Stream)

Loads Kube Config

Declaration
public static K8SConfiguration LoadKubeConfig(Stream kubeconfigStream)
Parameters
Type Name Description
Stream kubeconfigStream

Kube config file contents stream

Returns
Type Description
K8SConfiguration

Instance of the K8SConfiguration class

View Source

LoadKubeConfig(string, bool)

Loads entire Kube Config from default or explicit file path

Declaration
public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null, bool useRelativePaths = true)
Parameters
Type Name Description
string kubeconfigPath

Explicit file path to kubeconfig. Set to null to use the default file path

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
K8SConfiguration

Instance of the K8SConfiguration class

View Source

LoadKubeConfigAsync(FileInfo, bool)

Loads Kube Config

Declaration
public static Task<K8SConfiguration> LoadKubeConfigAsync(FileInfo kubeconfig, bool useRelativePaths = true)
Parameters
Type Name Description
FileInfo kubeconfig

Kube config file contents

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
Task<K8SConfiguration>

Instance of the K8SConfiguration class

View Source

LoadKubeConfigAsync(Stream)

Loads Kube Config

Declaration
public static Task<K8SConfiguration> LoadKubeConfigAsync(Stream kubeconfigStream)
Parameters
Type Name Description
Stream kubeconfigStream

Kube config file contents stream

Returns
Type Description
Task<K8SConfiguration>

Instance of the K8SConfiguration class

View Source

LoadKubeConfigAsync(string, bool)

Loads entire Kube Config from default or explicit file path

Declaration
public static Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null, bool useRelativePaths = true)
Parameters
Type Name Description
string kubeconfigPath

Explicit file path to kubeconfig. Set to null to use the default file path

bool useRelativePaths

When true, the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig file is located. When false, the paths will be considered to be relative to the current working directory.

Returns
Type Description
Task<K8SConfiguration>

Instance of the K8SConfiguration class

Events

View Source

ExecStdError

Exec process Standard Errors

Declaration
public static event EventHandler<DataReceivedEventArgs> ExecStdError
Event Type
Type Description
EventHandler<DataReceivedEventArgs>
  • View Source
In this article
Back to top Generated by DocFX