Codota Logo
Config.getMasterUrl
Code IndexAdd Codota to your IDE (free)

How to use
getMasterUrl
method
in
io.fabric8.kubernetes.client.Config

Best Java code snippets using io.fabric8.kubernetes.client.Config.getMasterUrl (Showing top 20 results out of 315)

  • Common ways to obtain Config
private void myMethod () {
Config c =
  • Codota IconString str;new ConfigBuilder().withMasterUrl(str).build()
  • Codota Iconnew Config()
  • Codota Iconnew ConfigBuilder().build()
  • Smart code suggestions by Codota
}
origin: fabric8io/kubernetes-client

public URL getRootUrl() {
 try {
  if (!Utils.isNullOrEmpty(apiGroupName)) {
   return new URL(URLUtils.join(config.getMasterUrl().toString(), "apis", apiGroupName, apiGroupVersion));
  }
  return new URL(URLUtils.join(config.getMasterUrl().toString(), "api", apiGroupVersion));
 } catch (MalformedURLException e) {
  throw KubernetesClientException.launderThrowable(e);
 }
}
origin: fabric8io/kubernetes-client

 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;
 }
}
origin: fabric8io/kubernetes-client

public RootPaths getRootPaths() {
 try {
  URL requestUrl = new URL(config.getMasterUrl());
  Request.Builder req = new Request.Builder().get().url(requestUrl);
  return handleResponse(req, RootPaths.class);
 } catch (KubernetesClientException e) {
  if (e.getCode() != 404) {
   throw e;
  }
  return null;
 } catch (InterruptedException | ExecutionException | IOException e) {
  throw KubernetesClientException.launderThrowable(e);
 }
}
origin: fabric8io/kubernetes-client

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);
 }
}
origin: fabric8io/kubernetes-client

public static boolean isHttpsAvailable(Config config) {
  Config sslConfig = new ConfigBuilder(config)
      .withMasterUrl(Config.HTTPS_PROTOCOL_PREFIX + config.getMasterUrl())
      .withRequestTimeout(1000)
      .withConnectionTimeout(1000)
      .build();
  OkHttpClient client = HttpClientUtils.createHttpClient(config);
  try {
    Request request = new Request.Builder().get().url(sslConfig.getMasterUrl())
        .build();
    Response response = client.newCall(request).execute();
    try (ResponseBody body = response.body()) {
     return response.isSuccessful();
    }
  } catch (Throwable t) {
    LOG.warn("SSL handshake failed. Falling back to insecure connection.");
  } finally {
    if (client != null && client.connectionPool() != null) {
      client.connectionPool().evictAll();
    }
  }
  return false;
}
origin: spring-cloud/spring-cloud-kubernetes

    base.getMasterUrl()))
.withApiVersion(or(kubernetesClientProperties.getApiVersion(),
    base.getApiVersion()))
origin: fabric8io/kubernetes-client

@Test
public void testMasterUrlWithServiceAccountIPv6() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "/dev/null");
 System.setProperty(Config.KUBERNETES_SERVICE_HOST_PROPERTY, "2001:db8:1f70::999:de8:7648:6e8");
 System.setProperty(Config.KUBERNETES_SERVICE_PORT_PROPERTY, "443");
 Config config = Config.autoConfigure(null);
 assertNotNull(config);
 assertEquals("https://[2001:db8:1f70::999:de8:7648:6e8]:443/", config.getMasterUrl());
}
origin: fabric8io/kubernetes-client

@Test
public void testMasterUrlWithServiceAccount() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "/dev/null");
 System.setProperty(Config.KUBERNETES_SERVICE_HOST_PROPERTY, "10.0.0.1");
 System.setProperty(Config.KUBERNETES_SERVICE_PORT_PROPERTY, "443");
 Config config = Config.autoConfigure(null);
 assertNotNull(config);
 assertEquals("https://10.0.0.1:443/", config.getMasterUrl());
}
origin: fabric8io/kubernetes-client

private static String getDefaultOpenShiftUrl(Config config) {
 String openshiftUrl = Utils.getSystemPropertyOrEnvVar(OPENSHIFT_URL_SYTEM_PROPERTY);
 if (openshiftUrl != null) {
  // The OPENSHIFT_URL environment variable may be set to the root url (i.e. without the '/oapi/version' path) in some configurations
  if (isRootURL(openshiftUrl)) {
   openshiftUrl = URLUtils.join(openshiftUrl, "oapi", getDefaultOapiVersion(config));
  }
  return openshiftUrl;
 } else {
  return URLUtils.join(config.getMasterUrl(), "oapi", getDefaultOapiVersion(config));
 }
}
origin: fabric8io/kubernetes-client

@Test
public void testWithNamespacePathAndSystemProperties() {
 System.setProperty(Config.KUBERNETES_NAMESPACE_FILE, TEST_NAMESPACE_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "testns");
 Config config = new Config();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("testns", config.getNamespace());
}
origin: fabric8io/kubernetes-client

@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());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithNamespacePath() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "nokubeconfigfile");
 System.setProperty(Config.KUBERNETES_NAMESPACE_FILE, TEST_NAMESPACE_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 Config config = new Config();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("testnsfrompath", config.getNamespace());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithNamespacePathAndSytemPropertiesAndBuilder() {
 System.setProperty(Config.KUBERNETES_NAMESPACE_FILE, TEST_NAMESPACE_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "tobeoverriden");
 Config config = new ConfigBuilder()
  .withNamespace("testns2")
  .build();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("testns2", config.getNamespace());
}
origin: fabric8io/kubernetes-client

@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());
}
origin: fabric8io/kubernetes-client

@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());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndOverrideContext() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_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());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndSystemProperties() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 Config config = new Config();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("testns", config.getNamespace());
 assertEquals("token", config.getOauthToken());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndSytemPropertiesAndBuilder() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 Config config = new ConfigBuilder()
  .withNamespace("testns2")
  .build();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("token", config.getOauthToken());
 assertEquals("testns2", config.getNamespace());
}
origin: fabric8io/kubernetes-client

@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());
}
origin: fabric8io/kubernetes-client

 @Test
 public void shouldInstantiateClientUsingSerializeDeserialize() throws MalformedURLException {
  DefaultOpenShiftClient original = new DefaultOpenShiftClient();
  String json = Serialization.asJson(original.getConfiguration());
  DefaultOpenShiftClient copy = DefaultOpenShiftClient.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());
 }
}
io.fabric8.kubernetes.clientConfiggetMasterUrl

Popular methods of Config

  • getOauthToken
  • getNamespace
  • getPassword
  • getUsername
  • getCaCertData
  • getClientCertData
  • getClientKeyData
  • getClientKeyPassphrase
  • getCaCertFile
  • getClientCertFile
  • getClientKeyAlgo
  • getClientKeyFile
  • getClientKeyAlgo,
  • getClientKeyFile,
  • getRequestTimeout,
  • isTrustCerts,
  • autoConfigure,
  • getApiVersion,
  • getConnectionTimeout,
  • getRollingTimeout,
  • <init>

Popular in Java

  • Updating database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • addToBackStack (FragmentTransaction)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now