Java Code Examples for io.fabric8.kubernetes.client.ConfigBuilder#withCaCertData()

The following examples show how to use io.fabric8.kubernetes.client.ConfigBuilder#withCaCertData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesHandler.java    From apollo with Apache License 2.0 6 votes vote down vote up
private KubernetesClient createKubernetesClient(Environment environment) {
    try {
        ConfigBuilder configBuilder = new ConfigBuilder()
                .withMasterUrl(environment.getKubernetesMaster())
                .withOauthToken(environment.getKubernetesToken());

        String caCert = environment.getKubernetesCaCert();
        if (StringUtils.isNotBlank(caCert)) {
            configBuilder.withCaCertData(caCert);
        }

        Config config = configBuilder.build();
        return new DefaultKubernetesClient(config);
    } catch (Exception e) {
        logger.error("Could not create kubernetes client for environment {}", environment.getId(), e);
        throw new RuntimeException();
    }
}
 
Example 2
Source File: ClusterConfiguration.java    From jkube with Eclipse Public License 2.0 4 votes vote down vote up
public Config getConfig() {
  final ConfigBuilder configBuilder = new ConfigBuilder();

  if (StringUtils.isNotBlank(this.username)) {
    configBuilder.withUsername(this.username);
  }

  if (StringUtils.isNotBlank(this.password)) {
    configBuilder.withPassword(this.password);
  }

  if (StringUtils.isNotBlank(this.masterUrl)) {
    configBuilder.withMasterUrl(this.masterUrl);
  }

  if (StringUtils.isNotBlank(this.apiVersion)) {
    configBuilder.withApiVersion(this.apiVersion);
  }

  if (StringUtils.isNotBlank(this.caCertData)) {
    configBuilder.withCaCertData(this.caCertData);
  }

  if (StringUtils.isNotBlank(this.caCertFile)) {
    configBuilder.withCaCertFile(this.caCertFile);
  }

  if (StringUtils.isNotBlank(this.clientCertData)) {
    configBuilder.withClientCertData(this.clientCertData);
  }

  if (StringUtils.isNotBlank(this.clientCertFile)) {
    configBuilder.withClientCertFile(this.clientCertFile);
  }

  if (StringUtils.isNotBlank(this.clientKeyAlgo)) {
    configBuilder.withClientKeyAlgo(this.clientKeyAlgo);
  }

  if (StringUtils.isNotBlank(this.clientKeyData)) {
    configBuilder.withClientKeyData(this.clientKeyData);
  }

  if (StringUtils.isNotBlank(this.clientKeyFile)) {
    configBuilder.withClientKeyFile(this.clientKeyFile);
  }

  if (StringUtils.isNotBlank(this.clientKeyPassphrase)) {
    configBuilder.withClientKeyPassphrase(this.clientKeyPassphrase);
  }

  if (StringUtils.isNotBlank(this.keyStoreFile)) {
    configBuilder.withKeyStoreFile(this.keyStoreFile);
  }

  if (StringUtils.isNotBlank(this.keyStorePassphrase)) {
    configBuilder.withKeyStorePassphrase(this.keyStorePassphrase);
  }

  if (StringUtils.isNotBlank(namespace)) {
    configBuilder.withNamespace(getNamespace());
  }

  if (StringUtils.isNotBlank(this.trustStoreFile)) {
    configBuilder.withTrustStoreFile(this.trustStoreFile);
  }

  if (StringUtils.isNotBlank(this.trustStorePassphrase)) {
    configBuilder.withTrustStorePassphrase(this.trustStorePassphrase);
  }

  return configBuilder.build();

}
 
Example 3
Source File: ManagedKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Activate
public void activate(Map<String, Object> properties) {
  final ConfigBuilder builder = new ConfigBuilder();

  if (properties.containsKey(KUBERNETES_MASTER_SYSTEM_PROPERTY)) {
    builder.withMasterUrl((String) properties.get(KUBERNETES_MASTER_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_API_VERSION_SYSTEM_PROPERTY)) {
    builder.withApiVersion((String) properties.get(KUBERNETES_API_VERSION_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY)) {
    builder.withNamespace((String) properties.get(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY)) {
    builder.withCaCertFile((String) properties.get(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY)) {
    builder.withCaCertData((String) properties.get(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY)) {
    builder.withClientCertFile((String) properties.get(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY)) {
    builder.withClientCertData((String) properties.get(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY)) {
    builder.withClientKeyFile((String) properties.get(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY)) {
    builder.withClientKeyData((String) properties.get(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY)) {
    builder.withClientKeyAlgo((String) properties.get(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY)) {
    builder.withClientKeyPassphrase((String) properties.get(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY)) {
    builder.withUsername((String) properties.get(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY)) {
    builder.withPassword((String) properties.get(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY)) {
    builder.withOauthToken((String) properties.get(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_WATCH_RECONNECT_INTERVAL_SYSTEM_PROPERTY)) {
    builder.withWatchReconnectInterval(Integer.parseInt((String) properties.get(KUBERNETES_WATCH_RECONNECT_INTERVAL_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_WATCH_RECONNECT_LIMIT_SYSTEM_PROPERTY)) {
    builder.withWatchReconnectLimit(Integer.parseInt((String) properties.get(KUBERNETES_WATCH_RECONNECT_LIMIT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_REQUEST_TIMEOUT_SYSTEM_PROPERTY)) {
    builder.withRequestTimeout(Integer.parseInt((String) properties.get(KUBERNETES_REQUEST_TIMEOUT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_HTTP_PROXY)) {
    builder.withHttpProxy((String) properties.get(KUBERNETES_HTTP_PROXY));
  }
  if (properties.containsKey(KUBERNETES_HTTPS_PROXY)) {
    builder.withHttpsProxy((String) properties.get(KUBERNETES_HTTPS_PROXY));
  }
  if (properties.containsKey(KUBERNETES_NO_PROXY)) {
    String noProxyProperty = (String) properties.get(KUBERNETES_NO_PROXY);
    builder.withNoProxy(noProxyProperty.split(","));
  }
  if (properties.containsKey(KUBERNETES_WEBSOCKET_TIMEOUT_SYSTEM_PROPERTY)) {
    builder.withWebsocketTimeout(Long.parseLong((String) properties.get(KUBERNETES_WEBSOCKET_TIMEOUT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_WEBSOCKET_PING_INTERVAL_SYSTEM_PROPERTY)) {
    builder.withWebsocketPingInterval(Long.parseLong((String) properties.get(KUBERNETES_WEBSOCKET_PING_INTERVAL_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_TRUSTSTORE_FILE_PROPERTY)) {
    builder.withTrustStoreFile((String) properties.get(KUBERNETES_TRUSTSTORE_FILE_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_TRUSTSTORE_PASSPHRASE_PROPERTY)) {
    builder.withTrustStorePassphrase((String) properties.get(KUBERNETES_TRUSTSTORE_PASSPHRASE_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_KEYSTORE_FILE_PROPERTY)) {
    builder.withKeyStoreFile((String) properties.get(KUBERNETES_KEYSTORE_FILE_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_KEYSTORE_PASSPHRASE_PROPERTY)) {
    builder.withKeyStorePassphrase((String) properties.get(KUBERNETES_KEYSTORE_PASSPHRASE_PROPERTY));
  }
  if (provider != null ) {
    builder.withOauthTokenProvider(provider);
  }

  delegate = new DefaultKubernetesClient(builder.build());
}