Class Kubernetes
Implements
Inherited Members
Namespace: k8s
Assembly: KubernetesClient.dll
Syntax
public class Kubernetes : AbstractKubernetes, ICoreOperations, ICoreV1Operations, IApisOperations, IAdmissionregistrationOperations, IAdmissionregistrationV1Operations, IAdmissionregistrationV1alpha1Operations, IAdmissionregistrationV1beta1Operations, IApiextensionsOperations, IApiextensionsV1Operations, IApiregistrationOperations, IApiregistrationV1Operations, IAppsOperations, IAppsV1Operations, IAuthenticationOperations, IAuthenticationV1Operations, IAuthorizationOperations, IAuthorizationV1Operations, IAutoscalingOperations, IAutoscalingV1Operations, IAutoscalingV2Operations, IBatchOperations, IBatchV1Operations, ICertificatesOperations, ICertificatesV1Operations, ICertificatesV1alpha1Operations, ICertificatesV1beta1Operations, ICoordinationOperations, ICoordinationV1Operations, ICoordinationV1alpha2Operations, ICoordinationV1beta1Operations, IDiscoveryOperations, IDiscoveryV1Operations, IEventsOperations, IEventsV1Operations, IFlowcontrolApiserverOperations, IFlowcontrolApiserverV1Operations, IInternalApiserverOperations, IInternalApiserverV1alpha1Operations, INetworkingOperations, INetworkingV1Operations, INetworkingV1beta1Operations, INodeOperations, INodeV1Operations, IPolicyOperations, IPolicyV1Operations, IRbacAuthorizationOperations, IRbacAuthorizationV1Operations, IResourceOperations, IResourceV1Operations, IResourceV1alpha3Operations, IResourceV1beta1Operations, IResourceV1beta2Operations, ISchedulingOperations, ISchedulingV1Operations, IStorageOperations, IStorageV1Operations, IStorageV1alpha1Operations, IStorageV1beta1Operations, IStoragemigrationOperations, IStoragemigrationV1alpha1Operations, ILogsOperations, IVersionOperations, ICustomObjectsOperations, IWellKnownOperations, IOpenidOperations, IKubernetes, IDisposable
Constructors
View SourceKubernetes(KubernetesClientConfiguration, params DelegatingHandler[])
Initializes a new instance of the Kubernetes class.
Declaration
public Kubernetes(KubernetesClientConfiguration config, params DelegatingHandler[] handlers)
Parameters
| Type | Name | Description |
|---|---|---|
| KubernetesClientConfiguration | config | The kube config to use. |
| DelegatingHandler[] | handlers | Optional. The delegating handlers to add to the http client pipeline. |
Properties
View SourceBaseUri
The base URI of the service.
Declaration
public Uri BaseUri { get; set; }
Property Value
| Type | Description |
|---|---|
| Uri |
CreateWebSocketBuilder
Gets a function which returns a WebSocketBuilder which Kubernetes will use to create a new WebSocket connection to the Kubernetes cluster.
Declaration
public Func<WebSocketBuilder> CreateWebSocketBuilder { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<WebSocketBuilder> |
Credentials
Subscription credentials which uniquely identify client subscription.
Declaration
public ServiceClientCredentials Credentials { get; }
Property Value
| Type | Description |
|---|---|
| ServiceClientCredentials |
HttpClient
Declaration
public HttpClient HttpClient { get; protected set; }
Property Value
| Type | Description |
|---|---|
| HttpClient |
Methods
View SourceCertificateValidationCallBack(object, X509Certificate2Collection, X509Certificate, X509Chain, SslPolicyErrors)
SSl Cert Validation Callback
Declaration
public static bool CertificateValidationCallBack(object sender, X509Certificate2Collection caCerts, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | sender |
| X509Certificate2Collection | caCerts | client ca |
| X509Certificate | certificate | client certificate |
| X509Chain | chain | chain |
| SslPolicyErrors | sslPolicyErrors | ssl policy errors |
Returns
| Type | Description |
|---|---|
| bool | true if valid cert |
CreateCredentials(KubernetesClientConfiguration)
Creates ServiceClientCredentials based on the given config, or returns null if no such credentials are needed.
Declaration
public static ServiceClientCredentials CreateCredentials(KubernetesClientConfiguration config)
Parameters
| Type | Name | Description |
|---|---|---|
| KubernetesClientConfiguration | config | kubenetes config object |
Returns
| Type | Description |
|---|---|
| ServiceClientCredentials | instance of ServiceClientCredentials |
CreateResultAsync<T>(HttpRequestMessage, HttpResponseMessage, bool?, CancellationToken)
Declaration
protected override Task<HttpOperationResponse<T>> CreateResultAsync<T>(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpRequestMessage | httpRequest | |
| HttpResponseMessage | httpResponse | |
| bool? | watch | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<HttpOperationResponse<T>> |
Type Parameters
| Name | Description |
|---|---|
| T |
Overrides
View SourceDispose()
Dispose the ServiceClient.
Declaration
public void Dispose()
Dispose(bool)
Dispose the HttpClient and Handlers.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | True to release both managed and unmanaged resources; false to releases only unmanaged resources. |
GetExitCodeOrThrow(V1Status)
Determines the process' exit code based on a V1Status message.
This will:
- return 0 if the process completed successfully
- return the exit code if the process completed with a non-zero exit code
- throw a KubernetesException in all other cases.
Declaration
public static int GetExitCodeOrThrow(V1Status status)
Parameters
| Type | Name | Description |
|---|---|---|
| V1Status | status | A V1Status object. |
Returns
| Type | Description |
|---|---|
| int | The process exit code. |
MuxedStreamNamespacedPodExecAsync(string, string, IEnumerable<string>, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken)
Executes a command in a pod.
Declaration
public virtual Task<IStreamDemuxer> MuxedStreamNamespacedPodExecAsync(string name, string @namespace = "default", IEnumerable<string> command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, bool tty = true, string webSocketSubProtocol = "v4.channel.k8s.io", Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | name of the Pod |
| string | namespace | object name and auth scope, such as for teams and projects |
| IEnumerable<string> | command | Command is the remote command to execute. argv array. Not executed within a shell. |
| string | container | Container in which to execute the command. Defaults to only container if there is only one container in the pod. |
| bool | stderr | Redirect the standard error stream of the pod for this call. Defaults to true. |
| bool | stdin | Redirect the standard input stream of the pod for this call. Defaults to true. |
| bool | stdout | Redirect the standard output stream of the pod for this call. Defaults to true. |
| bool | tty | TTY if true indicates that a tty will be allocated for the exec call. Defaults to true. |
| string | webSocketSubProtocol | The Kubernetes-specific WebSocket sub protocol to use. See WebSocketProtocol for a list of available protocols. |
| Dictionary<string, List<string>> | customHeaders | Headers that will be added to request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IStreamDemuxer> | A IStreamDemuxer which can be used to communicate with the process running in the pod. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when a required parameter is null |
NamespacedPodExecAsync(string, string, string, IEnumerable<string>, bool, ExecAsyncCallback, CancellationToken)
Executes a command in a container in a pod.
Declaration
public Task<int> NamespacedPodExecAsync(string name, string @namespace, string container, IEnumerable<string> command, bool tty, ExecAsyncCallback action, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the pod which contains the container in which to execute the command. |
| string | namespace | The namespace of the container. |
| string | container | The container in which to run the command. |
| IEnumerable<string> | command | The command to execute. |
| bool | tty | if allocate a pseudo-TTY |
| ExecAsyncCallback | action | A callback which processes the standard input, standard output and standard error. |
| CancellationToken | cancellationToken | A CancellationToken which can be used to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<int> | A Task which represents the asynchronous operation. |
SendRequestRaw(string, HttpRequestMessage, CancellationToken)
Declaration
protected virtual Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | requestContent | |
| HttpRequestMessage | httpRequest | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<HttpResponseMessage> |
SendRequest<T>(string, HttpMethod, IReadOnlyDictionary<string, IReadOnlyList<string>>, T, CancellationToken)
Declaration
protected override Task<HttpResponseMessage> SendRequest<T>(string relativeUri, HttpMethod method, IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders, T body, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | relativeUri | |
| HttpMethod | method | |
| IReadOnlyDictionary<string, IReadOnlyList<string>> | customHeaders | |
| T | body | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<HttpResponseMessage> |
Type Parameters
| Name | Description |
|---|---|
| T |
Overrides
View SourceStreamConnectAsync(Uri, string, Dictionary<string, List<string>>, CancellationToken)
Declaration
protected Task<WebSocket> StreamConnectAsync(Uri uri, string webSocketSubProtocol = null, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri | |
| string | webSocketSubProtocol | |
| Dictionary<string, List<string>> | customHeaders | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<WebSocket> |
WebSocketNamespacedPodAttachAsync(string, string, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken)
connect GET requests to attach of Pod
Declaration
public Task<WebSocket> WebSocketNamespacedPodAttachAsync(string name, string @namespace, string container = null, bool stderr = true, bool stdin = false, bool stdout = true, bool tty = false, string webSocketSubProtocol = null, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | name of the Pod |
| string | namespace | object name and auth scope, such as for teams and projects |
| string | container | The container in which to execute the command. Defaults to only container if there is only one container in the pod. |
| bool | stderr | Stderr if true indicates that stderr is to be redirected for the attach call. Defaults to true. |
| bool | stdin | stdin if true, redirects the standard input stream of the pod for this call. Defaults to false. |
| bool | stdout | Stdout if true indicates that stdout is to be redirected for the attach call. Defaults to true. |
| bool | tty | TTY if true indicates that a tty will be allocated for the attach call. This is passed through the container runtime so the tty is allocated on the worker node by the container runtime. Defaults to false. |
| string | webSocketSubProtocol | The Kubernetes-specific WebSocket sub protocol to use. See WebSocketProtocol for a list of available protocols. |
| Dictionary<string, List<string>> | customHeaders | Headers that will be added to request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<WebSocket> | A response object containing the response body and response headers. |
WebSocketNamespacedPodExecAsync(string, string, IEnumerable<string>, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken)
Executes a command in a pod.
Declaration
public virtual Task<WebSocket> WebSocketNamespacedPodExecAsync(string name, string @namespace = "default", IEnumerable<string> command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, bool tty = true, string webSocketSubProtocol = "v4.channel.k8s.io", Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | name of the Pod |
| string | namespace | object name and auth scope, such as for teams and projects |
| IEnumerable<string> | command | Command is the remote command to execute. argv array. Not executed within a shell. |
| string | container | Container in which to execute the command. Defaults to only container if there is only one container in the pod. |
| bool | stderr | Redirect the standard error stream of the pod for this call. Defaults to true. |
| bool | stdin | Redirect the standard input stream of the pod for this call. Defaults to true. |
| bool | stdout | Redirect the standard output stream of the pod for this call. Defaults to true. |
| bool | tty | TTY if true indicates that a tty will be allocated for the exec call. Defaults to true. |
| string | webSocketSubProtocol | The Kubernetes-specific WebSocket sub protocol to use. See WebSocketProtocol for a list of available protocols. |
| Dictionary<string, List<string>> | customHeaders | Headers that will be added to request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<WebSocket> | A ClientWebSocket which can be used to communicate with the process running in the pod. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when a required parameter is null |
WebSocketNamespacedPodExecAsync(string, string, string, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken)
Executes a command in a pod.
Declaration
public Task<WebSocket> WebSocketNamespacedPodExecAsync(string name, string @namespace = "default", string command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, bool tty = true, string webSocketSubProtocol = null, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | name of the Pod |
| string | namespace | object name and auth scope, such as for teams and projects |
| string | command | Command is the remote command to execute. argv array. Not executed within a shell. |
| string | container | Container in which to execute the command. Defaults to only container if there is only one container in the pod. |
| bool | stderr | Redirect the standard error stream of the pod for this call. Defaults to true. |
| bool | stdin | Redirect the standard input stream of the pod for this call. Defaults to true. |
| bool | stdout | Redirect the standard output stream of the pod for this call. Defaults to true. |
| bool | tty | TTY if true indicates that a tty will be allocated for the exec call. Defaults to true. |
| string | webSocketSubProtocol | The Kubernetes-specific WebSocket sub protocol to use. See WebSocketProtocol for a list of available protocols. |
| Dictionary<string, List<string>> | customHeaders | Headers that will be added to request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<WebSocket> | A ClientWebSocket which can be used to communicate with the process running in the pod. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when a required parameter is null |
WebSocketNamespacedPodPortForwardAsync(string, string, IEnumerable<int>, string, Dictionary<string, List<string>>, CancellationToken)
Start port forwarding one or more ports of a pod.
Declaration
public Task<WebSocket> WebSocketNamespacedPodPortForwardAsync(string name, string @namespace, IEnumerable<int> ports, string webSocketSubProtocol = null, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the Pod |
| string | namespace | The object name and auth scope, such as for teams and projects |
| IEnumerable<int> | ports | List of ports to forward. |
| string | webSocketSubProtocol | The Kubernetes-specific WebSocket sub protocol to use. See WebSocketProtocol for a list of available protocols. |
| Dictionary<string, List<string>> | customHeaders | The headers that will be added to request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<WebSocket> | A ClientWebSocket which can be used to communicate with the process running in the pod. |