Package io.kubernetes.client.util
Class ClientBuilder
java.lang.Object
io.kubernetes.client.util.ClientBuilder
A Builder which allows the construction of
ApiClient
s in a fluent fashion.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.kubernetes.client.openapi.ApiClient
build()
static ClientBuilder
cluster()
Creates a builder which is pre-configured from the cluster configuration.static io.kubernetes.client.openapi.ApiClient
static io.kubernetes.client.openapi.ApiClient
fromCertificateSigningRequest
(io.kubernetes.client.openapi.ApiClient bootstrapApiClient, PrivateKey privateKey, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Returns a new ApiClient instance reading from CertificateSigningRequest.static io.kubernetes.client.openapi.ApiClient
fromCertificateSigningRequest
(KubeConfig bootstrapKubeConfig, PrivateKey privateKey, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Returns a new ApiClient instance reading from CertificateSigningRequest.List<okhttp3.Protocol>
boolean
static ClientBuilder
kubeconfig
(KubeConfig config) Creates a builder which is pre-configured from aKubeConfig
.static ClientBuilder
[DEPRECATED] Creates a builder which is pre-configured from the cluster configuration.setAuthentication
(Authentication authentication) setBasePath
(String basePath) protected ClientBuilder
setBasePath
(String host, String port) setCertificateAuthority
(byte[] caCertBytes) setKeyStorePassphrase
(String keyStorePassphrase) setPingInterval
(Duration pingInterval) setProtocols
(List<okhttp3.Protocol> protocols) setReadTimeout
(Duration readTimeout) setVerifyingSsl
(boolean verifyingSsl) static ClientBuilder
standard()
Creates a builder which is pre-configured in the following way If $KUBECONFIG is defined, use that config file.static ClientBuilder
standard
(boolean persistConfig)
-
Constructor Details
-
ClientBuilder
public ClientBuilder()
-
-
Method Details
-
defaultClient
- Returns:
- An ApiClient configured using the precedence specified for
standard()
. - Throws:
IOException
- if the configuration file or a file specified in a configuration file cannot be read.
-
standard
Creates a builder which is pre-configured in the following way- If $KUBECONFIG is defined, use that config file.
- If $HOME/.kube/config can be found, use that.
- If the in-cluster service account can be found, assume in cluster config.
- Default to localhost:8080 as a last resort.
- Returns:
- ClientBuilder pre-configured using the above precedence
- Throws:
IOException
- if the configuration file or a file specified in a configuration file cannot be read.
-
standard
- Throws:
IOException
-
oldCluster
[DEPRECATED] Creates a builder which is pre-configured from the cluster configuration.- Returns:
- ClientBuilder configured from the cluster configuration.
- Throws:
IOException
- if the Service Account Token Path or CA Path is not readable.
-
cluster
Creates a builder which is pre-configured from the cluster configuration.- Returns:
- ClientBuilder configured from the cluster configuration where service account token will be reloaded.
- Throws:
IOException
- if the Service Account Token Path or CA Path is not readable.
-
setBasePath
-
kubeconfig
Creates a builder which is pre-configured from aKubeConfig
.To load a KubeConfig, see
KubeConfig.loadKubeConfig(Reader)
.- Parameters:
config
- TheKubeConfig
to configure the builder from.- Returns:
- ClientBuilder configured from the provided KubeConfig
- Throws:
IOException
- if the files specified in the provided KubeConfig are not readable
-
fromCertificateSigningRequest
public static io.kubernetes.client.openapi.ApiClient fromCertificateSigningRequest(KubeConfig bootstrapKubeConfig, PrivateKey privateKey, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) throws IOException, CSRNotApprovedException, io.kubernetes.client.openapi.ApiException Returns a new ApiClient instance reading from CertificateSigningRequest.It will create a CertificateSigningRequest object to the cluster if it doesn't exist, and waits until the request is approved.
- Parameters:
bootstrapKubeConfig
- the bootstrap kube configprivateKey
- the private keycsr
- the csr- Returns:
- the api client
- Throws:
IOException
- the io exceptionCSRNotApprovedException
- the csr not approved exceptionio.kubernetes.client.openapi.ApiException
- the api exception
-
fromCertificateSigningRequest
public static io.kubernetes.client.openapi.ApiClient fromCertificateSigningRequest(io.kubernetes.client.openapi.ApiClient bootstrapApiClient, PrivateKey privateKey, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) throws IOException, CSRNotApprovedException, io.kubernetes.client.openapi.ApiException Returns a new ApiClient instance reading from CertificateSigningRequest.It will create a CertificateSigningRequest object to the cluster if it doesn't exist, and waits until the request is approved.
- Parameters:
bootstrapApiClient
- the bootstrap api clientprivateKey
- the private keycsr
- the csr- Returns:
- the api client
- Throws:
IOException
- the io exceptionCSRNotApprovedException
- the csr not approved exceptionio.kubernetes.client.openapi.ApiException
- the api exception
-
getBasePath
-
setBasePath
-
getAuthentication
-
setAuthentication
-
setCertificateAuthority
-
isVerifyingSsl
public boolean isVerifyingSsl() -
setVerifyingSsl
-
setProtocols
-
getProtocols
-
setReadTimeout
-
getReadTimeout
-
setPingInterval
-
getPingInterval
-
getKeyStorePassphrase
-
setKeyStorePassphrase
-
build
public io.kubernetes.client.openapi.ApiClient build()
-