Refine search
public static void configFromSysPropsOrEnvVars(Config config) { config.setTrustCerts(Utils.getSystemPropertyOrEnvVar(KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, config.isTrustCerts())); config.setDisableHostnameVerification(Utils.getSystemPropertyOrEnvVar(KUBERNETES_DISABLE_HOSTNAME_VERIFICATION_SYSTEM_PROPERTY, config.isDisableHostnameVerification())); config.setMasterUrl(Utils.getSystemPropertyOrEnvVar(KUBERNETES_MASTER_SYSTEM_PROPERTY, config.getMasterUrl())); config.setApiVersion(Utils.getSystemPropertyOrEnvVar(KUBERNETES_API_VERSION_SYSTEM_PROPERTY, config.getApiVersion())); config.setNamespace(Utils.getSystemPropertyOrEnvVar(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, config.getNamespace())); config.setCaCertFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY, config.getCaCertFile())); config.setCaCertData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY, config.getCaCertData())); config.setClientCertFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY, config.getClientCertFile())); config.setClientCertData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY, config.getClientCertData())); config.setClientKeyFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY, config.getClientKeyFile())); config.setClientKeyData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY, config.getClientKeyData())); config.setClientKeyAlgo(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY, config.getClientKeyAlgo())); config.setClientKeyPassphrase(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY, new String(config.getClientKeyPassphrase()))); config.setUserAgent(Utils.getSystemPropertyOrEnvVar(KUBERNETES_USER_AGENT, config.getUserAgent())); config.setTrustStorePassphrase(Utils.getSystemPropertyOrEnvVar(KUBERNETES_TRUSTSTORE_PASSPHRASE_PROPERTY, config.getTrustStorePassphrase())); config.setTrustStoreFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_TRUSTSTORE_FILE_PROPERTY, config.getTrustStoreFile())); config.setKeyStorePassphrase(Utils.getSystemPropertyOrEnvVar(KUBERNETES_KEYSTORE_PASSPHRASE_PROPERTY, config.getKeyStorePassphrase())); config.setKeyStoreFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_KEYSTORE_FILE_PROPERTY, config.getKeyStoreFile())); config.setOauthToken(Utils.getSystemPropertyOrEnvVar(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY, config.getOauthToken())); config.setUsername(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY, config.getUsername())); config.setPassword(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY, config.getPassword())); config.setImpersonateUsername(Utils.getSystemPropertyOrEnvVar(KUBERNETES_IMPERSONATE_USERNAME, config.getImpersonateUsername())); String configuredImpersonateGroups = Utils.getSystemPropertyOrEnvVar(KUBERNETES_IMPERSONATE_GROUP, config.getImpersonateGroup()); if (configuredImpersonateGroups != null) { config.setImpersonateGroups(configuredImpersonateGroups.split(","));
public Config kubernetesClientConfig( KubernetesClientProperties kubernetesClientProperties) { Config base = Config.autoConfigure(null); Config properties = new ConfigBuilder(base) base.getMasterUrl())) .withApiVersion(or(kubernetesClientProperties.getApiVersion(), base.getApiVersion())) .withNamespace(or(kubernetesClientProperties.getNamespace(), base.getNamespace())) .withUsername( or(kubernetesClientProperties.getUsername(), base.getUsername())) .withPassword( or(kubernetesClientProperties.getPassword(), base.getPassword())) base.getCaCertFile())) .withCaCertData(or(kubernetesClientProperties.getCaCertData(), base.getCaCertData())) base.getClientKeyFile())) .withClientKeyData(or(kubernetesClientProperties.getClientKeyData(), base.getClientKeyData())) base.getClientCertFile())) .withClientCertData(or(kubernetesClientProperties.getClientCertData(), base.getClientCertData())) base.getClientKeyAlgo())) .withClientKeyPassphrase(
public static KeyManager[] keyManagers(Config config) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, InvalidKeySpecException, IOException { return keyManagers(config.getClientCertData(), config.getClientCertFile(), config.getClientKeyData(), config.getClientKeyFile(), config.getClientKeyAlgo(), config.getClientKeyPassphrase(), config.getKeyStoreFile(), config.getKeyStorePassphrase()); }
public static TrustManager[] trustManagers(Config config) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { return trustManagers(config.getCaCertData(), config.getCaCertFile(), config.isTrustCerts(), config.getTrustStoreFile(), config.getTrustStorePassphrase()); }
public OpenShiftConfig(Config kubernetesConfig, String openShiftUrl, String oapiVersion, long buildTimeout) { this(openShiftUrl, oapiVersion, kubernetesConfig.getMasterUrl(), kubernetesConfig.getApiVersion(), kubernetesConfig.getNamespace(), kubernetesConfig.isTrustCerts(), kubernetesConfig.isDisableHostnameVerification(), kubernetesConfig.getCaCertFile(), kubernetesConfig.getCaCertData(), kubernetesConfig.getClientCertFile(), kubernetesConfig.getClientCertData(), kubernetesConfig.getClientKeyFile(), kubernetesConfig.getClientKeyData(), kubernetesConfig.getClientKeyAlgo(), kubernetesConfig.getClientKeyPassphrase(), kubernetesConfig.getUsername(), kubernetesConfig.getPassword(), kubernetesConfig.getOauthToken(), kubernetesConfig.getWatchReconnectInterval(), kubernetesConfig.getWatchReconnectLimit(), kubernetesConfig.getConnectionTimeout(), kubernetesConfig.getRequestTimeout(), kubernetesConfig.getRollingTimeout(), kubernetesConfig.getScaleTimeout(), kubernetesConfig.getLoggingInterval(), kubernetesConfig.getMaxConcurrentRequestsPerHost(), kubernetesConfig.getHttpProxy(), kubernetesConfig.getHttpsProxy(), kubernetesConfig.getNoProxy(), kubernetesConfig.getErrorMessages(), kubernetesConfig.getUserAgent(), kubernetesConfig.getTlsVersions(), buildTimeout, kubernetesConfig.getWebsocketTimeout(), kubernetesConfig.getWebsocketPingInterval(), kubernetesConfig.getProxyUsername(), kubernetesConfig.getProxyPassword(), kubernetesConfig.getTrustStoreFile(), kubernetesConfig.getTrustStorePassphrase(), kubernetesConfig.getKeyStoreFile(), kubernetesConfig.getKeyStorePassphrase(), kubernetesConfig.getImpersonateUsername(), kubernetesConfig.getImpersonateGroups(), kubernetesConfig.getImpersonateExtras()
public void configFromSysPropsOrEnvVars(Config config) { config.setTrustCerts(Utils.getSystemPropertyOrEnvVar(KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, config.isTrustCerts())); config.setMasterUrl(Utils.getSystemPropertyOrEnvVar(KUBERNETES_MASTER_SYSTEM_PROPERTY, config.getMasterUrl())); config.setApiVersion(Utils.getSystemPropertyOrEnvVar(KUBERNETES_API_VERSION_SYSTEM_PROPERTY, config.getApiVersion())); config.setNamespace(Utils.getSystemPropertyOrEnvVar(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, config.getNamespace())); config.setCaCertFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY, config.getCaCertFile())); config.setCaCertData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY, config.getCaCertData())); config.setClientCertFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY, config.getClientCertFile())); config.setClientCertData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY, config.getClientCertData())); config.setClientKeyFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY, config.getClientKeyFile())); config.setClientKeyData(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY, config.getClientKeyData())); config.setClientKeyAlgo(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY, config.getClientKeyAlgo())); config.setClientKeyPassphrase(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY, new String(config.getClientKeyPassphrase()))); config.setUserAgent(Utils.getSystemPropertyOrEnvVar(KUBERNETES_USER_AGENT, config.getUserAgent())); config.setOauthToken(Utils.getSystemPropertyOrEnvVar(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY, config.getOauthToken())); config.setUsername(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY, config.getUsername())); config.setPassword(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY, config.getPassword())); config.setWatchReconnectInterval(Integer.parseInt(configuredWatchReconnectInterval)); config.setWatchReconnectLimit(Integer.parseInt(configuredWatchReconnectLimit)); config.setRollingTimeout(Long.parseLong(configuredRollingTimeout)); config.setScaleTimeout(Long.parseLong(configuredScaleTimeout)); config.setLoggingInterval(Integer.parseInt(configuredLoggingInterval)); config.setConnectionTimeout(Utils.getSystemPropertyOrEnvVar(KUBERNETES_CONNECTION_TIMEOUT_SYSTEM_PROPERTY, config.getConnectionTimeout()));
@Bean @ConditionalOnMissingBean(Config.class) public Config kubernetesClientConfig(KubernetesClientProperties kubernetesClientProperties) { Config base = new Config(); Config properties = new ConfigBuilder(base) //Only set values that have been explicitly specified .withMasterUrl(or(kubernetesClientProperties.getMasterUrl(), base.getMasterUrl())) .withApiVersion(or(kubernetesClientProperties.getApiVersion(), base.getApiVersion())) .withNamespace(or(kubernetesClientProperties.getNamespace(), base.getNamespace())) .withUsername(or(kubernetesClientProperties.getUsername(), base.getUsername())) .withPassword(or(kubernetesClientProperties.getPassword(), base.getPassword())) .withCaCertFile(or(kubernetesClientProperties.getCaCertFile(), base.getCaCertFile())) .withCaCertData(or(kubernetesClientProperties.getCaCertData(), base.getCaCertData())) .withClientKeyFile(or(kubernetesClientProperties.getClientKeyFile(), base.getClientKeyFile())) .withClientKeyData(or(kubernetesClientProperties.getClientKeyData(), base.getClientKeyData())) .withClientCertFile(or(kubernetesClientProperties.getClientCertFile(), base.getClientCertFile())) .withClientCertData(or(kubernetesClientProperties.getClientCertData(), base.getClientCertData())) //No magic is done for the properties below so we leave them as is. .withClientKeyAlgo(or(kubernetesClientProperties.getClientKeyAlgo(), base.getClientKeyAlgo())) .withClientKeyPassphrase(or(kubernetesClientProperties.getClientKeyPassphrase(), base.getClientKeyPassphrase())) .withConnectionTimeout(or(kubernetesClientProperties.getConnectionTimeout(), base.getConnectionTimeout())) .withRequestTimeout(or(kubernetesClientProperties.getRequestTimeout(), base.getRequestTimeout())) .withRollingTimeout(or(kubernetesClientProperties.getRollingTimeout(), base.getRollingTimeout())) .withTrustCerts(or(kubernetesClientProperties.isTrustCerts(), base.isTrustCerts())) .build(); if (properties.getNamespace() == null || properties.getNamespace().isEmpty()) { LOG.warn("No namespace has been detected. Please specify KUBERNETES_NAMESPACE env var, or use a later kubernetes version (1.3 or later)"); } return properties; }
private void assertConfig(Config config) { assertNotNull(config); assertTrue(config.isTrustCerts()); assertTrue(config.isDisableHostnameVerification()); assertEquals("http://somehost:80/", config.getMasterUrl()); assertEquals("testns", config.getNamespace()); assertEquals("token", config.getOauthToken()); assertEquals("user", config.getUsername()); assertEquals("pass", config.getPassword()); assertEquals("/path/to/cert", config.getCaCertFile()); assertEquals("cacertdata", config.getCaCertData()); assertEquals("/path/to/clientcert", config.getClientCertFile()); assertEquals("clientcertdata", config.getClientCertData()); assertEquals("/path/to/clientkey", config.getClientKeyFile()); assertEquals("clientkeydata", config.getClientKeyData()); assertEquals("algo", config.getClientKeyAlgo()); assertEquals("passphrase", config.getClientKeyPassphrase()); assertEquals("httpProxy", config.getHttpProxy()); assertEquals(5000, config.getWatchReconnectInterval()); assertEquals(5, config.getWatchReconnectLimit()); assertEquals(5000, config.getRequestTimeout()); assertArrayEquals(new TlsVersion[]{TLS_1_2, TLS_1_1}, config.getTlsVersions()); assertEquals("/path/to/truststore", config.getTrustStoreFile()); assertEquals("truststorePassphrase", config.getTrustStorePassphrase()); assertEquals("/path/to/keystore", config.getKeyStoreFile());
@Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (Utils.isNotNullOrEmpty(config.getUsername()) && Utils.isNotNullOrEmpty(config.getPassword())) { Request authReq = chain.request().newBuilder().addHeader("Authorization", Credentials.basic(config.getUsername(), config.getPassword())).build(); return chain.proceed(authReq); } else if (Utils.isNotNullOrEmpty(config.getOauthToken())) { Request authReq = chain.request().newBuilder().addHeader("Authorization", "Bearer " + config.getOauthToken()).build(); return chain.proceed(authReq); } return chain.proceed(request); } }).addInterceptor(new ImpersonatorInterceptor(config))
Cluster currentCluster = KubeConfigUtils.getCluster(kubeConfig, currentContext); if (currentCluster != null) { config.setMasterUrl(currentCluster.getServer()); config.setNamespace(currentContext.getNamespace()); config.setTrustCerts(currentCluster.getInsecureSkipTlsVerify() != null && currentCluster.getInsecureSkipTlsVerify()); config.setDisableHostnameVerification(currentCluster.getInsecureSkipTlsVerify() != null && currentCluster.getInsecureSkipTlsVerify()); config.setCaCertData(currentCluster.getCertificateAuthorityData()); AuthInfo currentAuthInfo = KubeConfigUtils.getUserAuthInfo(kubeConfig, currentContext); if (currentAuthInfo != null) { String clientKeyFile = currentAuthInfo.getClientKey(); if (kubeconfigPath != null && !kubeconfigPath.isEmpty()) { caCertFile = absolutify(new File(kubeconfigPath), currentCluster.getCertificateAuthority()); clientCertFile = absolutify(new File(kubeconfigPath), currentAuthInfo.getClientCertificate()); clientKeyFile = absolutify(new File(kubeconfigPath), currentAuthInfo.getClientKey()); config.setCaCertFile(caCertFile); config.setClientCertFile(clientCertFile); config.setClientCertData(currentAuthInfo.getClientCertificateData()); config.setClientKeyFile(clientKeyFile); config.setClientKeyData(currentAuthInfo.getClientKeyData()); config.setOauthToken(currentAuthInfo.getToken()); config.setUsername(currentAuthInfo.getUsername()); config.setPassword(currentAuthInfo.getPassword()); if (Utils.isNullOrEmpty(config.getOauthToken()) && currentAuthInfo.getAuthProvider() != null && !Utils.isNullOrEmpty(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN))) { config.setOauthToken(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN)); } else { // https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins ExecConfig exec = currentAuthInfo.getExec();
@Test public void shouldInstantiateClientUsingSerializeDeserialize() throws MalformedURLException { DefaultKubernetesClient original = new DefaultKubernetesClient(); String json = Serialization.asJson(original.getConfiguration()); DefaultKubernetesClient copy = DefaultKubernetesClient.fromConfig(json); Assert.assertEquals(original.getConfiguration().getMasterUrl(), copy.getConfiguration().getMasterUrl()); Assert.assertEquals(original.getConfiguration().getOauthToken(), copy.getConfiguration().getOauthToken()); Assert.assertEquals(original.getConfiguration().getNamespace(), copy.getConfiguration().getNamespace()); Assert.assertEquals(original.getConfiguration().getUsername(), copy.getConfiguration().getUsername()); Assert.assertEquals(original.getConfiguration().getPassword(), copy.getConfiguration().getPassword()); }
private void updateKubeConfig(Config kubeConfig, JsonObject config, K8SDiscovery annotation) { final String user = ConfigurationUtil.getStringConfiguration(config, USER, annotation.user()); final String password = ConfigurationUtil.getStringConfiguration(config, PASSWORD, annotation.password()); final String api_token = ConfigurationUtil.getStringConfiguration(config, API_TOKEN, annotation.api_token()); final String master_url = ConfigurationUtil.getStringConfiguration(config, MASTER_URL, annotation.master_url()); final String namespace = ConfigurationUtil.getStringConfiguration(config, NAMESPACE, annotation.namespace()); if (StringUtil.isNullOrEmpty(kubeConfig.getUsername())) kubeConfig.setUsername(user); if (StringUtil.isNullOrEmpty(kubeConfig.getPassword())) kubeConfig.setPassword(password); if (StringUtil.isNullOrEmpty(kubeConfig.getOauthToken())) kubeConfig.setOauthToken(api_token); if (StringUtil.isNullOrEmpty(kubeConfig.getMasterUrl())) kubeConfig.setMasterUrl(master_url); if (StringUtil.isNullOrEmpty(kubeConfig.getNamespace())) kubeConfig.setNamespace(namespace); // check oauthToken if (StringUtil.isNullOrEmpty(kubeConfig.getOauthToken())) kubeConfig.setOauthToken(TokenUtil.getAccountToken()); } }
@Test public void testWithMultipleKubeConfigAndOverrideContext() { System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE + File.pathSeparator + "some-other-file"); Config config = Config.autoConfigure("production/172-28-128-4:8443/root"); assertNotNull(config); assertEquals("https://172.28.128.4:8443/", config.getMasterUrl()); assertEquals("production", config.getNamespace()); assertEquals("supertoken", config.getOauthToken()); assertTrue(config.getCaCertFile().endsWith("testns/ca.pem".replace("/", File.separator))); assertTrue(new File(config.getCaCertFile()).isAbsolute()); }
@Test public void testWithKubeConfig() { System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE); Config config = new Config(); assertNotNull(config); assertEquals("https://172.28.128.4:8443/", config.getMasterUrl()); assertEquals("testns", config.getNamespace()); assertEquals("token", config.getOauthToken()); assertTrue(config.getCaCertFile().endsWith("testns/ca.pem".replace("/", File.separator))); assertTrue(new File(config.getCaCertFile()).isAbsolute()); }
if (config.isTrustCerts() || config.isDisableHostnameVerification()) { httpClientBuilder.hostnameVerifier(new HostnameVerifier() { @Override if (keyManagers != null || trustManagers != null || config.isTrustCerts()) { X509TrustManager trustManager = null; if (trustManagers != null && trustManagers.length == 1) { SSLContext sslContext = SSLUtils.sslContext(keyManagers, trustManagers, config.isTrustCerts()); httpClientBuilder.sslSocketFactory(sslContext.getSocketFactory(), trustManager); } catch (GeneralSecurityException e) { if (config.getConnectionTimeout() > 0) { httpClientBuilder.connectTimeout(config.getConnectionTimeout(), TimeUnit.MILLISECONDS); if (config.getRequestTimeout() > 0) { httpClientBuilder.readTimeout(config.getRequestTimeout(), TimeUnit.MILLISECONDS); if (config.getWebsocketPingInterval() > 0) { httpClientBuilder.pingInterval(config.getWebsocketPingInterval(), TimeUnit.MILLISECONDS); if (config.getMaxConcurrentRequestsPerHost() > 0) { Dispatcher dispatcher = new Dispatcher(); dispatcher.setMaxRequests(config.getMaxConcurrentRequests()); dispatcher.setMaxRequestsPerHost(config.getMaxConcurrentRequestsPerHost()); httpClientBuilder.dispatcher(dispatcher); if (config.getMasterUrl().toLowerCase().startsWith(Config.HTTP_PROTOCOL_PREFIX) || config.getMasterUrl().startsWith(Config.HTTPS_PROTOCOL_PREFIX)) { try {
@Test public void testWithNonExistingNamespacePath() { System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "nokubeconfigfile"); System.setProperty(Config.KUBERNETES_NAMESPACE_FILE, "nonamespace"); System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80"); Config config = new Config(); assertNotNull(config); assertEquals("http://somehost:80/", config.getMasterUrl()); assertEquals(null, config.getNamespace()); }
if (config.isTrustCerts()) { httpClientBuilder.hostnameVerifier(new HostnameVerifier() { @Override if (keyManagers != null || trustManagers != null || config.isTrustCerts()) { X509TrustManager trustManager = null; if (trustManagers != null && trustManagers.length == 1) { SSLContext sslContext = SSLUtils.sslContext(keyManagers, trustManagers, config.isTrustCerts()); httpClientBuilder.sslSocketFactory(sslContext.getSocketFactory(), trustManager); } catch (GeneralSecurityException e) { if (config.getConnectionTimeout() > 0) { httpClientBuilder.connectTimeout(config.getConnectionTimeout(), TimeUnit.MILLISECONDS); if (config.getRequestTimeout() > 0) { httpClientBuilder.readTimeout(config.getRequestTimeout(), TimeUnit.MILLISECONDS); if (config.getWebsocketPingInterval() > 0) { httpClientBuilder.pingInterval(config.getWebsocketPingInterval(), TimeUnit.MILLISECONDS); if (config.getMasterUrl().toLowerCase().startsWith(Config.HTTP_PROTOCOL_PREFIX) || config.getMasterUrl().startsWith(Config.HTTPS_PROTOCOL_PREFIX)) { try { URL proxyUrl = getProxyUrl(config); if (config.getProxyUsername() != null) { httpClientBuilder.proxyAuthenticator(new Authenticator() { @Override
public BaseClient(final OkHttpClient httpClient, Config config) throws KubernetesClientException { try { this.httpClient = httpClient; this.namespace = config.getNamespace(); this.configuration = config; this.apiVersion = config.getApiVersion(); if (config.getMasterUrl() == null) { throw new KubernetesClientException("Unknown Kubernetes master URL - " + "please set with the builder, or set with either system property \"" + Config.KUBERNETES_MASTER_SYSTEM_PROPERTY + "\"" + " or environment variable \"" + Utils.convertSystemPropertyNameToEnvVar(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY) + "\""); } this.masterUrl = new URL(config.getMasterUrl()); } catch (Exception e) { throw KubernetesClientException.launderThrowable(e); } }
public static KeyManager[] keyManagers(Config config) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, InvalidKeySpecException, IOException { return keyManagers(config.getClientCertData(), config.getClientCertFile(), config.getClientKeyData(), config.getClientKeyFile(), config.getClientKeyAlgo(), config.getClientKeyPassphrase()); }
public VersionInfo fetchVersion() { try { Request.Builder requestBuilder = new Request.Builder() .get() .url(URLUtils.join(config.getMasterUrl(), versionEndpoint)); Response response = client.newCall(requestBuilder.build()).execute(); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> myMap = objectMapper.readValue(response.body().string(), HashMap.class); return new VersionInfo(myMap); } catch(Exception e) { KubernetesClientException.launderThrowable(e); } return null; } }