Class ClientBuilder

java.lang.Object
io.kubernetes.client.util.ClientBuilder

public class ClientBuilder extends Object
A Builder which allows the construction of ApiClients in a fluent fashion.
  • Constructor Details

    • ClientBuilder

      public ClientBuilder()
  • Method Details

    • defaultClient

      public static io.kubernetes.client.openapi.ApiClient defaultClient() throws IOException
      Creates an ApiClient by calling standard() and build().
      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

      public static ClientBuilder standard() throws IOException
      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

      public static ClientBuilder standard(boolean persistConfig) throws IOException
      Throws:
      IOException
    • oldCluster

      public static ClientBuilder oldCluster() throws IOException
      [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

      public static ClientBuilder cluster() throws IOException
      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

      protected ClientBuilder setBasePath(String host, String port)
    • kubeconfig

      public static ClientBuilder kubeconfig(KubeConfig config) throws IOException
      Creates a builder which is pre-configured from a KubeConfig.

      To load a KubeConfig, see KubeConfig.loadKubeConfig(Reader).

      Parameters:
      config - The KubeConfig 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 config
      privateKey - the private key
      csr - the csr
      Returns:
      the api client
      Throws:
      IOException - the io exception
      CSRNotApprovedException - the csr not approved exception
      io.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 client
      privateKey - the private key
      csr - the csr
      Returns:
      the api client
      Throws:
      IOException - the io exception
      CSRNotApprovedException - the csr not approved exception
      io.kubernetes.client.openapi.ApiException - the api exception
    • getBasePath

      public String getBasePath()
    • setBasePath

      public ClientBuilder setBasePath(String basePath)
    • getAuthentication

      public Authentication getAuthentication()
    • setAuthentication

      public ClientBuilder setAuthentication(Authentication authentication)
    • setCertificateAuthority

      public ClientBuilder setCertificateAuthority(byte[] caCertBytes)
    • isVerifyingSsl

      public boolean isVerifyingSsl()
    • setVerifyingSsl

      public ClientBuilder setVerifyingSsl(boolean verifyingSsl)
    • setProtocols

      public ClientBuilder setProtocols(List<okhttp3.Protocol> protocols)
    • getProtocols

      public List<okhttp3.Protocol> getProtocols()
    • setReadTimeout

      public ClientBuilder setReadTimeout(Duration readTimeout)
    • getReadTimeout

      public Duration getReadTimeout()
    • setPingInterval

      public ClientBuilder setPingInterval(Duration pingInterval)
    • getPingInterval

      public Duration getPingInterval()
    • getKeyStorePassphrase

      public String getKeyStorePassphrase()
    • setKeyStorePassphrase

      public ClientBuilder setKeyStorePassphrase(String keyStorePassphrase)
    • build

      public io.kubernetes.client.openapi.ApiClient build()