Module: lib/k8s/apiProxy
Interfaces
Type aliases
StreamErrCb
Ƭ StreamErrCb: (err
: Error
& { status?
: number
}, cancelStreamFunc?
: () => void
) => void
Type declaration
▸ (err
, cancelStreamFunc?
): void
Parameters
Name | Type |
---|---|
err |
Error & { status? : number } |
cancelStreamFunc? |
() => void |
Returns
void
Defined in
StreamResultsCb
Ƭ StreamResultsCb: (…args
: any
[]) => void
Type declaration
▸ (…args
): void
Parameters
Name | Type |
---|---|
...args |
any [] |
Returns
void
Defined in
Functions
apiFactory
▸ apiFactory(…args
): Object
Parameters
Name | Type |
---|---|
...args |
[group: string, version: string, resource: string] | [group: string, version: string, resource: string][] |
Returns
Object
Name | Type |
---|---|
delete |
(name : string , queryParams? :
QueryParameters
) => Promise <any > |
get |
(name : string , cb :
StreamResultsCb
, errCb :
StreamErrCb
, queryParams? :
QueryParameters
) => Promise <() => void > |
isNamespaced |
boolean |
list |
(cb :
StreamResultsCb
, errCb :
StreamErrCb
, queryParams? :
QueryParameters
) => Promise <() => void > |
patch |
(body : OpPatch [], name : string , queryParams? :
QueryParameters
) => Promise <any > |
post |
(body :
KubeObjectInterface
, queryParams? :
QueryParameters
) => Promise <any > |
put |
(body :
KubeObjectInterface
, queryParams? :
QueryParameters
) => Promise <any > |
Defined in
apiFactoryWithNamespace
▸ apiFactoryWithNamespace(…args
): Object
Parameters
Name | Type |
---|---|
...args |
[group: string, version: string, resource: string, includeScale: boolean] | [group: string, version: string, resource: string, includeScale: boolean][] |
Returns
Object
Name | Type |
---|---|
scale? |
{ get : (namespace : string , name : string ) => Promise <any > ; put : (body : { metadata :
KubeMetadata
; spec : { replicas : number } }) => Promise <any > } |
scale.get |
(namespace : string , name : string ) => Promise <any > |
scale.put |
(body : { metadata :
KubeMetadata
; spec : { replicas : number } }) => Promise <any > |
Defined in
apply
▸ apply(body
): Promise
<JSON
>
Parameters
Name | Type |
---|---|
body |
KubeObjectInterface
|
Returns
Promise
<JSON
>
Defined in
clusterRequest
▸ clusterRequest(path
, params?
, queryParams?
): Promise
<any
>
Sends a request to the backend. If the cluster is required in the params parameter, it will be used as a request to the respective Kubernetes server.
throws
An ApiError if the response status is not ok.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
The path to the API endpoint. |
params |
RequestParams
|
Optional parameters for the request. |
queryParams? |
QueryParameters
|
Optional query parameters for the request. |
Returns
Promise
<any
>
A Promise that resolves to the JSON response from the API server.
Defined in
deleteCluster
▸ deleteCluster(cluster
): Promise
<any
>
Parameters
Name | Type |
---|---|
cluster |
string |
Returns
Promise
<any
>
Defined in
drainNode
▸ drainNode(cluster
, nodeName
): Promise
<any
>
Drain a node
throws
{Error} if the request fails
throws
{Error} if the response is not ok
This function is used to drain a node. It is used in the node detail page. As draining a node is a long running process, we get the request received message if the request is successful. And then we poll the drain node status endpoint to get the status of the drain node process.
Parameters
Name | Type |
---|---|
cluster |
string |
nodeName |
string |
Returns
Promise
<any
>
Defined in
drainNodeStatus
▸ drainNodeStatus(cluster
, nodeName
): Promise
<any
>
Get the status of the drain node process
throws
{Error} if the request fails
throws
{Error} if the response is not ok
This function is used to get the status of the drain node process. It is used in the node detail page. As draining a node is a long running process, we poll this endpoint to get the status of the drain node process.
Parameters
Name | Type |
---|---|
cluster |
string |
nodeName |
string |
Returns
Promise
<any
>
Defined in
listPortForward
▸ listPortForward(cluster
): Promise
<any
>
Parameters
Name | Type |
---|---|
cluster |
string |
Returns
Promise
<any
>
Defined in
metrics
▸ metrics(url
, onMetrics
, onError?
): Promise
<() => void
>
Parameters
Name | Type |
---|---|
url |
string |
onMetrics |
(arg :
KubeMetrics
[]) => void |
onError? |
(err :
ApiError
) => void |
Returns
Promise
<() => void
>
Defined in
patch
▸ patch(url
, json
, autoLogoutOnAuthError?
, requestOptions?
): Promise
<any
>
Parameters
Name | Type | Default value |
---|---|---|
url |
string |
undefined |
json |
any |
undefined |
autoLogoutOnAuthError |
boolean |
true |
requestOptions |
Object |
{} |
Returns
Promise
<any
>
Defined in
post
▸ post(url
, json
, autoLogoutOnAuthError?
, requestOptions?
): Promise
<any
>
Parameters
Name | Type | Default value |
---|---|---|
url |
string |
undefined |
json |
object |
KubeObjectInterface
| JSON |
undefined |
autoLogoutOnAuthError |
boolean |
true |
requestOptions |
Object |
{} |
Returns
Promise
<any
>
Defined in
put
▸ put(url
, json
, autoLogoutOnAuthError?
, requestOptions?
): Promise
<any
>
Parameters
Name | Type | Default value |
---|---|---|
url |
string |
undefined |
json |
Partial <
KubeObjectInterface
> |
undefined |
autoLogoutOnAuthError |
boolean |
true |
requestOptions |
Object |
{} |
Returns
Promise
<any
>
Defined in
remove
▸ remove(url
, requestOptions?
): Promise
<any
>
Parameters
Name | Type |
---|---|
url |
string |
requestOptions |
Object |
Returns
Promise
<any
>
Defined in
request
▸ request(path
, params?
, autoLogoutOnAuthError?
, useCluster?
, queryParams?
): Promise
<any
>
Sends a request to the backend. If the useCluster parameter is true (which it is, by default), it will be treated as a request to the Kubernetes server of the currently defined (in the URL) cluster.
throws
An ApiError if the response status is not ok.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
path |
string |
undefined |
The path to the API endpoint. |
params |
RequestParams
|
{} |
Optional parameters for the request. |
autoLogoutOnAuthError |
boolean |
true |
Whether to automatically log out the user if there is an authentication error. |
useCluster |
boolean |
true |
Whether to use the current cluster for the request. |
queryParams? |
QueryParameters
|
undefined |
Optional query parameters for the request. |
Returns
Promise
<any
>
A Promise that resolves to the JSON response from the API server.
Defined in
setCluster
▸ setCluster(clusterReq
): Promise
<any
>
Parameters
Name | Type |
---|---|
clusterReq |
ClusterRequest
|
Returns
Promise
<any
>
Defined in
startPortForward
▸ startPortForward(cluster
, namespace
, podname
, containerPort
, service
, serviceNamespace
, port?
, id?
): Promise
<any
>
Parameters
Name | Type | Default value |
---|---|---|
cluster |
string |
undefined |
namespace |
string |
undefined |
podname |
string |
undefined |
containerPort |
string | number |
undefined |
service |
string |
undefined |
serviceNamespace |
string |
undefined |
port? |
string |
undefined |
id |
string |
'' |
Returns
Promise
<any
>
Defined in
stopOrDeletePortForward
▸ stopOrDeletePortForward(cluster
, id
, stopOrDelete?
): Promise
<string
>
Parameters
Name | Type | Default value |
---|---|---|
cluster |
string |
undefined |
id |
string |
undefined |
stopOrDelete |
boolean |
true |
Returns
Promise
<string
>
Defined in
stream
▸ stream(url
, cb
, args
): Object
Establishes a WebSocket connection to the specified URL and streams the results to the provided callback function.
Parameters
Name | Type | Description |
---|---|---|
url |
string |
The URL to connect to. |
cb |
StreamResultsCb
|
The callback function to receive the streamed results. |
args |
StreamArgs
|
Additional arguments to configure the stream. |
Returns
Object
An object with two functions: cancel
, which can be called to cancel
the stream, and getSocket
, which returns the WebSocket object.
Name | Type |
---|---|
cancel |
() => void |
getSocket |
() => null | WebSocket |
Defined in
streamResult
▸ streamResult(url
, name
, cb
, errCb
, queryParams?
): Promise
<() => void
>
Streams the results of a Kubernetes API request.
Parameters
Name | Type | Description |
---|---|---|
url |
string |
The URL of the Kubernetes API endpoint. |
name |
string |
The name of the Kubernetes API resource. |
cb |
StreamResultsCb
|
The callback function to execute when the stream receives data. |
errCb |
StreamErrCb
|
The callback function to execute when an error occurs. |
queryParams? |
QueryParameters
|
The query parameters to include in the API request. |
Returns
Promise
<() => void
>
A function to cancel the stream.
Defined in
streamResults
▸ streamResults(url
, cb
, errCb
, queryParams
): Promise
<() => void
>
Streams the results of a Kubernetes API request.
Parameters
Name | Type | Description |
---|---|---|
url |
string |
The URL of the Kubernetes API endpoint. |
cb |
StreamResultsCb
|
The callback function to execute when the stream receives data. |
errCb |
StreamErrCb
|
The callback function to execute when an error occurs. |
queryParams |
undefined |
QueryParameters
|
The query parameters to include in the API request. |
Returns
Promise
<() => void
>
A function to cancel the stream.
Defined in
testAuth
▸ testAuth(): Promise
<any
>
Returns
Promise
<any
>
Defined in
testClusterHealth
▸ testClusterHealth(): Promise
<any
>
Returns
Promise
<any
>