io.fabric8.kubernetes.api.model.ConfigMapBuilder Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.ConfigMapBuilder.
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: ConfigMapsWithProfilesTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-with-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #2
Source File: ConfigMapsWithoutProfilesTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-without-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #3
Source File: ConfigMapsMixedTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws IOException { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); Files.createDirectories(Paths.get(FILES_ROOT_PATH)); ConfigMapTestUtil.createFileWithContent(FILE_NAME_FULL_PATH, readResourceFile("application-path.yaml")); HashMap<String, String> data = new HashMap<>(); data.put("bean.morning", "Buenos Dias ConfigMap, %s"); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #4
Source File: ConfigMapsWithProfileExpressionTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { KubernetesClient mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-with-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #5
Source File: SshKeysProvisioner.java From che with Eclipse Public License 2.0 | 6 votes |
private void doProvisionVcsSshConfig( List<SshPairImpl> vcsSshPairs, KubernetesEnvironment k8sEnv, String wsId) { StringBuilder sshConfigData = new StringBuilder(); for (SshPair sshPair : vcsSshPairs) { sshConfigData.append(buildConfig(sshPair.getName())); } String sshConfigMapName = wsId + SSH_CONFIG_MAP_NAME_SUFFIX; Map<String, String> sshConfig = new HashMap<>(); sshConfig.put(SSH_CONFIG, sshConfigData.toString()); ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(sshConfigMapName) .endMetadata() .withData(sshConfig) .build(); k8sEnv.getConfigMaps().put(configMap.getMetadata().getName(), configMap); k8sEnv .getPodsData() .values() .forEach( p -> mountConfigFile(p.getSpec(), sshConfigMapName, p.getRole() != PodRole.INJECTABLE)); }
Example #6
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapFromSingleInvalidYamlContent() { String configMapName = "single-unparseable-yaml-test"; String namespace = "app-props"; this.server.expect() .withPath(String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, configMapName)) .andReturn(200, new ConfigMapBuilder().withNewMetadata().withName(configMapName) .endMetadata().addToData("application.yaml", "somevalue") .build()) .once(); new ConfigMapPropertySource(this.server.getClient().inNamespace(namespace), configMapName); // no exception is thrown for unparseable content }
Example #7
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapFromSingleInvalidPropertiesContent() { String configMapName = "single-unparseable-properties-test"; String namespace = "app-props"; this.server.expect() .withPath(String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, configMapName)) .andReturn(200, new ConfigMapBuilder().withNewMetadata().withName(configMapName) .endMetadata() .addToData("application.properties", "somevalue").build()) .once(); new ConfigMapPropertySource(this.server.getClient().inNamespace(namespace), configMapName); // no exception is thrown for unparseable content }
Example #8
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapFromSingleNonStandardFileName() { String configMapName = "single-non-standard-test"; String namespace = "app-props"; this.server.expect() .withPath(String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, configMapName)) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(configMapName).endMetadata() .addToData("adhoc.yml", readResourceFile("adhoc.yml")).build()) .once(); ConfigMapPropertySource cmps = new ConfigMapPropertySource( this.server.getClient().inNamespace(namespace), configMapName); assertThat(cmps.getProperty("dummy.property.string3")).isEqualTo("a"); assertThat(cmps.getProperty("dummy.property.int3")).isEqualTo(1); assertThat(cmps.getProperty("dummy.property.bool3")).isEqualTo(true); }
Example #9
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapFromSingleApplicationYaml() { String configMapName = "app-yaml-test"; String namespace = "app-props"; this.server.expect() .withPath(String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, configMapName)) .andReturn(200, new ConfigMapBuilder().withNewMetadata().withName(configMapName) .endMetadata() .addToData("application.yaml", readResourceFile("application.yaml")) .build()) .once(); ConfigMapPropertySource cmps = new ConfigMapPropertySource( this.server.getClient().inNamespace(namespace), configMapName); assertThat(cmps.getProperty("dummy.property.string2")).isEqualTo("a"); assertThat(cmps.getProperty("dummy.property.int2")).isEqualTo(1); assertThat(cmps.getProperty("dummy.property.bool2")).isEqualTo(true); }
Example #10
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapFromSingleApplicationProperties() { String configMapName = "app-properties-test"; String namespace = "app-props"; this.server.expect() .withPath(String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, configMapName)) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(configMapName).endMetadata() .addToData("application.properties", readResourceFile("application.properties")) .build()) .once(); ConfigMapPropertySource cmps = new ConfigMapPropertySource( this.server.getClient().inNamespace(namespace), configMapName); assertThat(cmps.getProperty("dummy.property.string1")).isEqualTo("a"); assertThat(cmps.getProperty("dummy.property.int1")).isEqualTo("1"); assertThat(cmps.getProperty("dummy.property.bool1")).isEqualTo("true"); }
Example #11
Source File: ConfigMapsTest.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapGet() { this.server.expect().withPath("/api/v1/namespaces/ns2/configmaps") .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName("reload-example").endMetadata() .addToData("KEY", "123").build()) .once(); KubernetesClient client = this.server.getClient(); ConfigMapList configMapList = client.configMaps().inNamespace("ns2").list(); assertThat(configMapList).isNotNull(); assertThat(configMapList.getAdditionalProperties()).containsKey("data"); @SuppressWarnings("unchecked") Map<String, String> data = (Map<String, String>) configMapList .getAdditionalProperties().get("data"); assertThat(data.get("KEY")).isEqualTo("123"); }
Example #12
Source File: ConfigMapsWithProfilesNoActiveProfileTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-with-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #13
Source File: ConfigMapsTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("bean.greeting", "Hello ConfigMap, %s!"); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #14
Source File: CreateOrReplaceResourceTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testReplaceWithoutLock() throws Exception { server.expect().get().withPath("/api/v1/namespaces/test/configmaps/map1").andReturn(200, new ConfigMapBuilder() .withNewMetadata().withResourceVersion("1000").and().build()).always(); server.expect().put().withPath("/api/v1/namespaces/test/configmaps/map1").andReturn(200, new ConfigMapBuilder() .withNewMetadata().withResourceVersion("1001").and().build()).once(); KubernetesClient client = server.getClient(); ConfigMap map = client.configMaps().withName("map1").replace(new ConfigMapBuilder() .withNewMetadata().withName("map1").and().build()); assertNotNull(map); assertEquals("1001", map.getMetadata().getResourceVersion()); RecordedRequest request = server.getLastRequest(); ConfigMap replacedMap = new ObjectMapper().readerFor(ConfigMap.class).readValue(request.getBody().inputStream()); assertEquals("1000", replacedMap.getMetadata().getResourceVersion()); }
Example #15
Source File: CreateOrReplaceResourceTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testReplaceWithLock() throws Exception { server.expect().put().withPath("/api/v1/namespaces/test/configmaps/map1").andReturn(200, new ConfigMapBuilder() .withNewMetadata().withResourceVersion("1001").and().build()).once(); KubernetesClient client = server.getClient(); ConfigMap map = client.configMaps().withName("map1") .lockResourceVersion("900") .replace(new ConfigMapBuilder().withNewMetadata().withName("map1").and().build()); assertNotNull(map); assertEquals("1001", map.getMetadata().getResourceVersion()); RecordedRequest request = server.getLastRequest(); ConfigMap replacedMap = new ObjectMapper().readerFor(ConfigMap.class).readValue(request.getBody().inputStream()); assertEquals("900", replacedMap.getMetadata().getResourceVersion()); }
Example #16
Source File: LeaderElectionTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void singleLeaderConfigMapLockUpdateTest() throws Exception { // Given server.expect().get().withPath("/api/v1/namespaces/namespace/configmaps/name") .andReturn(200, new ConfigMapBuilder() .withNewMetadata() .withResourceVersion("1") .withAnnotations(Collections.singletonMap( "control-plane.alpha.kubernetes.io/leader", "{\"holderIdentity\": \"not-lead-config-map\", \"leaseDuration\": 100, \"acquireTime\": 0, \"renewTime\": 0}")) .endMetadata() .build()).always(); server.expect().put().withPath("/api/v1/namespaces/namespace/configmaps/name") .andReturn(200, null).once(); // When - Then testAndAssertSingleLeader("lead-config-map", new ConfigMapLock("namespace", "name", "lead-config-map")); }
Example #17
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ConfigMap with PropagationPolicy=Background") void testDeleteConfigMap() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/configmaps/myconfigMap") .andReturn(HttpURLConnection.HTTP_OK, new ConfigMapBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.configMaps().inNamespace("ns1").withName("myconfigMap").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #18
Source File: ConfigMapHandler.java From module-ballerina-kubernetes with Apache License 2.0 | 6 votes |
private void generate(ConfigMapModel configMapModel) throws KubernetesPluginException { ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(configMapModel.getName()) .withNamespace(dataHolder.getNamespace()) .endMetadata() .withData(configMapModel.getData()) .build(); try { String configMapContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(configMap); KubernetesUtils.writeToFile(configMapContent, CONFIG_MAP_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while parsing yaml file for config map: " + configMapModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
Example #19
Source File: KnativeConfigMapHandler.java From module-ballerina-kubernetes with Apache License 2.0 | 6 votes |
private void generate(ConfigMapModel configMapModel) throws KubernetesPluginException { ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(configMapModel.getName()) .withNamespace(knativeDataHolder.getNamespace()) .endMetadata() .withData(configMapModel.getData()) .build(); try { String configMapContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(configMap); KnativeUtils.writeToFile(configMapContent, CONFIG_MAP_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while parsing yaml file for config map: " + configMapModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
Example #20
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ConfigMap with specified PropagationPolicy") void testDeleteConfigMapWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/configmaps/myconfigMap") .andReturn(HttpURLConnection.HTTP_OK, new ConfigMapBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.configMaps().inNamespace("ns1").withName("myconfigMap").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #21
Source File: ConfigMapTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testLiteralConfigMap() throws InterruptedException { HashMap<String, String> data = new HashMap<>(); data.put("foo", "bar"); data.put("cheese", "gouda"); server.expect().withPath("/api/v1/namespaces/test/configmaps").andReturn(200, new ConfigMapBuilder() .withNewMetadata() .withName("cfg1") .endMetadata() .addToData(data) .build()) .once(); NamespacedKubernetesClient client = server.getClient(); ConfigMapList cfgList = client.configMaps().list(); assertNotNull(cfgList); assertEquals(1, cfgList.getAdditionalProperties().size()); Map<String, String> keys = (Map<String, String>) cfgList.getAdditionalProperties().get("data"); assertEquals("gouda",keys.get("cheese")); assertEquals("bar",keys.get("foo")); }
Example #22
Source File: GitConfigProvisioner.java From che with Eclipse Public License 2.0 | 6 votes |
private void doProvisionGitConfiguration( String gitConfigMapName, String gitConfig, KubernetesEnvironment k8sEnv) { Map<String, String> gitConfigData = singletonMap(GIT_CONFIG, gitConfig); ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(gitConfigMapName) .endMetadata() .withData(gitConfigData) .build(); k8sEnv.getConfigMaps().put(configMap.getMetadata().getName(), configMap); k8sEnv .getPodsData() .values() .forEach( p -> mountConfigFile(p.getSpec(), gitConfigMapName, p.getRole() != PodRole.INJECTABLE)); }
Example #23
Source File: PatchServiceTest.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void testInvalidPatcherKind() { ConfigMap oldResource = new ConfigMapBuilder() .withNewMetadata().withName("configmap1").endMetadata() .addToData(Collections.singletonMap("foo", "bar")) .build(); ConfigMap newResource = new ConfigMapBuilder() .withNewMetadata().withName("configmap1").endMetadata() .addToData(Collections.singletonMap("FOO", "BAR")) .build(); OpenShiftClient client = mockServer.createOpenShiftClient(); PatchService patchService = new PatchService(client, log); patchService.compareAndPatchEntity("test", newResource, oldResource); }
Example #24
Source File: FlinkConfMountDecorator.java From flink with Apache License 2.0 | 6 votes |
@Override public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException { final String clusterId = kubernetesComponentConf.getClusterId(); final Map<String, String> data = new HashMap<>(); final List<File> localLogFiles = getLocalLogConfFiles(); for (File file : localLogFiles) { data.put(file.getName(), Files.toString(file, StandardCharsets.UTF_8)); } final Map<String, String> propertiesMap = getClusterSidePropertiesMap(kubernetesComponentConf.getFlinkConfiguration()); data.put(FLINK_CONF_FILENAME, getFlinkConfData(propertiesMap)); final ConfigMap flinkConfConfigMap = new ConfigMapBuilder() .withApiVersion(Constants.API_VERSION) .withNewMetadata() .withName(getFlinkConfConfigMapName(clusterId)) .withLabels(kubernetesComponentConf.getCommonLabels()) .endMetadata() .addToData(data) .build(); return Collections.singletonList(flinkConfConfigMap); }
Example #25
Source File: ConfigMapEnricher.java From jkube with Eclipse Public License 2.0 | 6 votes |
private void addAnnotations(KubernetesListBuilder builder) { builder.accept(new TypedVisitor<ConfigMapBuilder>() { @Override public void visit(ConfigMapBuilder element) { final Map<String, String> annotations = element.buildMetadata().getAnnotations(); if (annotations != null) { try { addConfigMapFromAnnotations(annotations, element); } catch (IOException e) { throw new IllegalArgumentException(e); } } } }); }
Example #26
Source File: HadoopConfMountDecorator.java From flink with Apache License 2.0 | 5 votes |
@Override public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException { if (kubernetesParameters.getExistingHadoopConfigurationConfigMap().isPresent()) { return Collections.emptyList(); } final Optional<String> localHadoopConfigurationDirectory = kubernetesParameters.getLocalHadoopConfigurationDirectory(); if (!localHadoopConfigurationDirectory.isPresent()) { return Collections.emptyList(); } final List<File> hadoopConfigurationFileItems = getHadoopConfigurationFileItems(localHadoopConfigurationDirectory.get()); if (hadoopConfigurationFileItems.isEmpty()) { LOG.warn("Found 0 files in directory {}, skip to create the Hadoop Configuration ConfigMap.", localHadoopConfigurationDirectory.get()); return Collections.emptyList(); } final Map<String, String> data = new HashMap<>(); for (File file: hadoopConfigurationFileItems) { data.put(file.getName(), FileUtils.readFileUtf8(file)); } final ConfigMap hadoopConfigMap = new ConfigMapBuilder() .withApiVersion(Constants.API_VERSION) .withNewMetadata() .withName(getHadoopConfConfigMapName(kubernetesParameters.getClusterId())) .withLabels(kubernetesParameters.getCommonLabels()) .endMetadata() .addToData(data) .build(); return Collections.singletonList(hadoopConfigMap); }
Example #27
Source File: BrokerEnvironmentFactory.java From che with Eclipse Public License 2.0 | 5 votes |
private ConfigMap newConfigMap(String configMapName, Collection<PluginFQN> pluginFQNs) throws InternalInfrastructureException { try { return new ConfigMapBuilder() .withNewMetadata() .withName(configMapName) .endMetadata() .withData(singletonMap(CONFIG_FILE, objectMapper.writeValueAsString(pluginFQNs))) .build(); } catch (JsonProcessingException e) { throw new InternalInfrastructureException(e.getMessage(), e); } }
Example #28
Source File: AbstractJwtProxyProvisioner.java From che with Eclipse Public License 2.0 | 5 votes |
private void ensureJwtProxyInjected(KubernetesEnvironment k8sEnv, String machineName, PodData pod) throws InfrastructureException { if (!k8sEnv.getMachines().containsKey(JWT_PROXY_MACHINE_NAME)) { k8sEnv.getMachines().put(JWT_PROXY_MACHINE_NAME, createJwtProxyMachine()); Pod jwtProxyPod = createJwtProxyPod(); k8sEnv.addInjectablePod(machineName, JWT_PROXY_MACHINE_NAME, jwtProxyPod); Map<String, String> initConfigMapData = new HashMap<>(); initConfigMapData.put( JWT_PROXY_PUBLIC_KEY_FILE, PUBLIC_KEY_HEADER + java.util.Base64.getEncoder().encodeToString(keyPair.getPublic().getEncoded()) + PUBLIC_KEY_FOOTER); initConfigMapData.put(JWT_PROXY_CONFIG_FILE, proxyConfigBuilder.build()); ConfigMap jwtProxyConfigMap = new ConfigMapBuilder() .withNewMetadata() .withName(getConfigMapName()) .endMetadata() .withData(initConfigMapData) .build(); k8sEnv.getConfigMaps().put(jwtProxyConfigMap.getMetadata().getName(), jwtProxyConfigMap); Service jwtProxyService = new ServerServiceBuilder() .withName(serviceName) // we're merely injecting the pod, so we need a selector that is going to hit the // pod that runs the server that we're exposing .withSelectorEntry(CHE_ORIGINAL_NAME_LABEL, pod.getMetadata().getName()) .withMachineName(JWT_PROXY_MACHINE_NAME) .withPorts(emptyList()) .build(); k8sEnv.getServices().put(jwtProxyService.getMetadata().getName(), jwtProxyService); } }
Example #29
Source File: EnmasseOperatorManager.java From enmasse with Apache License 2.0 | 5 votes |
private void enableUserWorkloadMonitoring() throws Exception { LOGGER.info("***********************************************************"); LOGGER.info(" Enmasse user workload monitoring"); LOGGER.info("***********************************************************"); enableOperatorMetrics(true); kube.createConfigmapFromResource("openshift-monitoring", new ConfigMapBuilder() .editOrNewMetadata() .withNamespace("openshift-monitoring") .withName("cluster-monitoring-config") .endMetadata() .addToData("config.yaml", "techPreviewUserWorkload:\n enabled: true") .build()); TestUtils.waitForPodReady("prometheus-user-workload-0", "openshift-user-workload-monitoring"); LOGGER.info("***********************************************************"); }
Example #30
Source File: OpenShiftEnvironmentFactoryTest.java From che with Eclipse Public License 2.0 | 5 votes |
@Test public void addConfigMapsWhenRecipeContainsThem() throws Exception { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("test-configmap").endMetadata().build(); when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(configMap)); final KubernetesEnvironment parsed = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList()); assertEquals(parsed.getConfigMaps().size(), 1); assertEquals( parsed.getConfigMaps().values().iterator().next().getMetadata().getName(), configMap.getMetadata().getName()); }