Class KubernetesClientConfiguration
Represents a set of kubernetes client configuration settings
Inherited Members
Namespace: k8s
Assembly: KubernetesClient.dll
Syntax
public class KubernetesClientConfiguration
Constructors
View SourceKubernetesClientConfiguration()
Declaration
public KubernetesClientConfiguration()
Fields
View SourceKubeConfigDefaultLocation
kubeconfig Default Location
Declaration
public static readonly string KubeConfigDefaultLocation
Field Value
| Type | Description |
|---|---|
| string |
Properties
View SourceAccessToken
Gets or sets the access token for OAuth2 authentication.
Declaration
public string AccessToken { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The access token. |
ClientCertificateData
Gets ClientCertificateData
Declaration
public string ClientCertificateData { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ClientCertificateFilePath
Gets ClientCertificate filename
Declaration
public string ClientCertificateFilePath { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ClientCertificateKeyData
Gets ClientCertificate Key
Declaration
public string ClientCertificateKeyData { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
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? |
ClientKeyFilePath
Gets ClientCertificate Key filename
Declaration
public string ClientKeyFilePath { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
CurrentContext
Gets CurrentContext
Declaration
public string CurrentContext { get; }
Property Value
| Type | Description |
|---|---|
| string |
DisableHttp2
Do not use http2 even it is available
Declaration
public bool DisableHttp2 { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ExecTimeout
Exec process timeout
Declaration
public static TimeSpan ExecTimeout { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
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.
Host
Gets Host
Declaration
public string Host { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
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 |
JsonSerializerOptions
Options for the JsonSerializer to override the default ones.
Declaration
public JsonSerializerOptions JsonSerializerOptions { get; }
Property Value
| Type | Description |
|---|---|
| JsonSerializerOptions |
Namespace
Gets current namespace
Declaration
public string Namespace { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Password
Gets or sets the password (HTTP basic authentication).
Declaration
public string Password { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The password. |
SkipTlsVerify
Gets a value indicating whether to skip ssl server cert validation
Declaration
public bool SkipTlsVerify { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
SslCaCerts
Gets SslCaCerts
Declaration
public X509Certificate2Collection SslCaCerts { get; set; }
Property Value
| Type | Description |
|---|---|
| X509Certificate2Collection |
TlsServerName
Option to override the TLS server name
Declaration
public string TlsServerName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
TokenProvider
Gets or sets the TokenProvider for authentication.
Declaration
public ITokenProvider TokenProvider { get; set; }
Property Value
| Type | Description |
|---|---|
| ITokenProvider | The access token. |
UserAgent
Gets or sets the HTTP user agent.
Declaration
public string UserAgent { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Http user agent. |
Username
Gets or sets the username (HTTP basic authentication).
Declaration
public string Username { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The username. |
Methods
View SourceAddJsonOptions(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. |
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 |
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 |
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 |
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 |
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 |
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 |
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.
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 |
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 |
InClusterConfig()
Declaration
public static KubernetesClientConfiguration InClusterConfig()
Returns
| Type | Description |
|---|---|
| KubernetesClientConfiguration |
IsInCluster()
Declaration
public static bool IsInCluster()
Returns
| Type | Description |
|---|---|
| bool |
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 |
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 |
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 |
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 |
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 |
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 SourceExecStdError
Exec process Standard Errors
Declaration
public static event EventHandler<DataReceivedEventArgs> ExecStdError
Event Type
| Type | Description |
|---|---|
| EventHandler<DataReceivedEventArgs> |