Java Code Examples for io.fabric8.kubernetes.client.Config#getMasterUrl()

The following examples show how to use io.fabric8.kubernetes.client.Config#getMasterUrl() . 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: HttpClientUtils.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private static URL getProxyUrl(Config config) throws MalformedURLException {
    URL master = new URL(config.getMasterUrl());
    String host = master.getHost();
    if (config.getNoProxy() != null) {
        for (String noProxy : config.getNoProxy()) {
            if (isIpAddress(noProxy)) {
                if (new IpAddressMatcher(noProxy).matches(host)) {
                    return null;
                }
            } else {
                if (host.contains(noProxy)) {
                    return null;
                }
            }
        }
    }
    String proxy = config.getHttpsProxy();
    if (master.getProtocol().equals("http")) {
        proxy = config.getHttpProxy();
    }
    if (proxy != null) {
        return new URL(proxy);
    }
    return null;
}
 
Example 2
Source File: HttpClientUtils.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
private static URL getProxyUrl(Config config) throws MalformedURLException {
    URL master = new URL(config.getMasterUrl());
    String host = master.getHost();
    if (config.getNoProxy() != null) {
     for (String noProxy : config.getNoProxy()) {
        if (isIpAddress(noProxy)) {
          if (new IpAddressMatcher(noProxy).matches(host)) {
            return null;
          }
        } else {
          if (host.contains(noProxy)) {
            return null;
          }
        }
     }
    }
    String proxy = config.getHttpsProxy();
    if (master.getProtocol().equals("http")) {
        proxy = config.getHttpProxy();
    }
    if (proxy != null) {
        return new URL(proxy);
    }
    return null;
}
 
Example 3
Source File: Environment.java    From enmasse with Apache License 2.0 5 votes vote down vote up
private Environment() {
    if (Strings.isNullOrEmpty(token) || Strings.isNullOrEmpty(url)) {
        Config config = Config.autoConfigure(System.getenv()
                .getOrDefault("TEST_CLUSTER_CONTEXT", null));
        token = config.getOauthToken();
        url = config.getMasterUrl();
    }
    String debugFormat = "{}:{}";
    LOGGER.info(debugFormat, INSTALL_TYPE, installType.name());
    if (installType == EnmasseInstallType.OLM) {
        LOGGER.info(debugFormat, OLM_INSTALL_TYPE, olmInstallType.name());
    }
    if (Strings.isNullOrEmpty(this.kubernetesDomain)) {
        if (url.equals("https://api.crc.testing:6443")) {
            this.kubernetesDomain = "apps-crc.testing";
        } else if (url.startsWith("https://api")) { //is api url for openshift4
            try {
                this.kubernetesDomain = new URL(url).getHost().replace("api", "apps");
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        } else {
            this.kubernetesDomain = "nip.io";
        }
    }
    LOGGER.info(debugFormat, "CONFIG", config);
    LOGGER.info(debugFormat, "SCALE_CONFIG", scaleConfig);
    values.forEach(v -> LOGGER.info(debugFormat, v.getKey(), v.getValue()));
}
 
Example 4
Source File: OpenShiftConfig.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
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(),
    false,
    false
    );
}