io.fabric8.kubernetes.api.model.ConfigMapKeySelector Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.ConfigMapKeySelector.
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: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapKeyRef() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.configMapKeyRefs", "[{envVarName: 'MY_ENV', configMapName: 'myConfigMap', dataKey: 'envName'}]"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); deployer = new KubernetesAppDeployer(new KubernetesDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); List<EnvVar> envVars = podSpec.getContainers().get(0).getEnv(); assertEquals("Invalid number of env vars", 2, envVars.size()); EnvVar configMapKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "MY_ENV", configMapKeyRefEnvVar.getName()); ConfigMapKeySelector configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "envName", configMapKeySelector.getKey()); }
Example #2
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapKeyRefGlobal() { AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), null); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); KubernetesDeployerProperties.ConfigMapKeyRef configMapKeyRef = new KubernetesDeployerProperties.ConfigMapKeyRef(); configMapKeyRef.setEnvVarName("MY_ENV_GLOBAL"); configMapKeyRef.setConfigMapName("myConfigMapGlobal"); configMapKeyRef.setDataKey("envGlobal"); kubernetesDeployerProperties.setConfigMapKeyRefs(Collections.singletonList(configMapKeyRef)); deployer = new KubernetesAppDeployer(kubernetesDeployerProperties, null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); List<EnvVar> envVars = podSpec.getContainers().get(0).getEnv(); assertEquals("Invalid number of env vars", 2, envVars.size()); EnvVar configMapKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "MY_ENV_GLOBAL", configMapKeyRefEnvVar.getName()); ConfigMapKeySelector configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myConfigMapGlobal", configMapKeySelector.getName()); assertEquals("Unexpected config data key", "envGlobal", configMapKeySelector.getKey()); }
Example #3
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testConfigMapKeyRefGlobalFromYaml() throws Exception { AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), null); deployer = new KubernetesAppDeployer(bindDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); List<EnvVar> envVars = podSpec.getContainers().get(0).getEnv(); assertEquals("Invalid number of env vars", 3, envVars.size()); EnvVar configMapKeyRefEnvVar = envVars.get(1); assertEquals("Unexpected env var name", "MY_ENV", configMapKeyRefEnvVar.getName()); ConfigMapKeySelector configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "envName", configMapKeySelector.getKey()); }
Example #4
Source File: DeploymentPropertiesResolver.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private EnvVar buildConfigMapKeyRefEnvVar(KubernetesDeployerProperties.ConfigMapKeyRef configMapKeyRef) { ConfigMapKeySelector configMapKeySelector = new ConfigMapKeySelector(); EnvVarSource envVarSource = new EnvVarSource(); envVarSource.setConfigMapKeyRef(configMapKeySelector); EnvVar configMapKeyEnvRefVar = new EnvVar(); configMapKeyEnvRefVar.setValueFrom(envVarSource); configMapKeySelector.setName(configMapKeyRef.getConfigMapName()); configMapKeySelector.setKey(configMapKeyRef.getDataKey()); configMapKeyEnvRefVar.setName(configMapKeyRef.getEnvVarName()); return configMapKeyEnvRefVar; }
Example #5
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
@Test public void testConfigMapKeyRefMultiple() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.configMapKeyRefs", "[{envVarName: 'MY_ENV', configMapName: 'myConfigMap', dataKey: 'envName'}," + "{envVarName: 'ENV_VALUES', configMapName: 'myOtherConfigMap', dataKey: 'diskType'}]"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); deployer = new KubernetesAppDeployer(new KubernetesDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); List<EnvVar> envVars = podSpec.getContainers().get(0).getEnv(); assertEquals("Invalid number of env vars", 3, envVars.size()); EnvVar configMapKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "MY_ENV", configMapKeyRefEnvVar.getName()); ConfigMapKeySelector configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "envName", configMapKeySelector.getKey()); configMapKeyRefEnvVar = envVars.get(1); assertEquals("Unexpected env var name", "ENV_VALUES", configMapKeyRefEnvVar.getName()); configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myOtherConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "diskType", configMapKeySelector.getKey()); }
Example #6
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 4 votes |
@Test public void testConfigMapKeyRefPropertyOverride() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.configMapKeyRefs", "[{envVarName: 'MY_ENV', configMapName: 'myConfigMap', dataKey: 'envName'}," + "{envVarName: 'ENV_VALUES', configMapName: 'myOtherConfigMap', dataKey: 'diskType'}]"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); List<KubernetesDeployerProperties.ConfigMapKeyRef> globalConfigMapKeyRefs = new ArrayList<>(); KubernetesDeployerProperties.ConfigMapKeyRef globalConfigMapKeyRef1 = new KubernetesDeployerProperties.ConfigMapKeyRef(); globalConfigMapKeyRef1.setEnvVarName("MY_ENV"); globalConfigMapKeyRef1.setConfigMapName("myEnvGlobal"); globalConfigMapKeyRef1.setDataKey("envGlobal"); KubernetesDeployerProperties.ConfigMapKeyRef globalConfigMapKeyRef2 = new KubernetesDeployerProperties.ConfigMapKeyRef(); globalConfigMapKeyRef2.setEnvVarName("MY_VALS_GLOBAL"); globalConfigMapKeyRef2.setConfigMapName("myValsGlobal"); globalConfigMapKeyRef2.setDataKey("valsGlobal"); globalConfigMapKeyRefs.add(globalConfigMapKeyRef1); globalConfigMapKeyRefs.add(globalConfigMapKeyRef2); kubernetesDeployerProperties.setConfigMapKeyRefs(globalConfigMapKeyRefs); deployer = new KubernetesAppDeployer(kubernetesDeployerProperties, null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); List<EnvVar> envVars = podSpec.getContainers().get(0).getEnv(); assertEquals("Invalid number of env vars", 4, envVars.size()); // deploy prop overrides global EnvVar configMapKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "MY_ENV", configMapKeyRefEnvVar.getName()); ConfigMapKeySelector configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "envName", configMapKeySelector.getKey()); // unique deploy prop configMapKeyRefEnvVar = envVars.get(1); assertEquals("Unexpected env var name", "ENV_VALUES", configMapKeyRefEnvVar.getName()); configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myOtherConfigMap", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "diskType", configMapKeySelector.getKey()); // unique, non-overridden global prop configMapKeyRefEnvVar = envVars.get(2); assertEquals("Unexpected env var name", "MY_VALS_GLOBAL", configMapKeyRefEnvVar.getName()); configMapKeySelector = configMapKeyRefEnvVar.getValueFrom().getConfigMapKeyRef(); assertEquals("Unexpected config map name", "myValsGlobal", configMapKeySelector.getName()); assertEquals("Unexpected config map data key", "valsGlobal", configMapKeySelector.getKey()); }
Example #7
Source File: ExternalConfigurationEnvVarSource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
@Description("Refernce to a key in a ConfigMap.") @KubeLink(group = "core", version = "v1", kind = "configmapkeyselector") @JsonInclude(value = JsonInclude.Include.NON_NULL) public ConfigMapKeySelector getConfigMapKeyRef() { return configMapKeyRef; }
Example #8
Source File: ExternalConfigurationEnvVarSource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public void setConfigMapKeyRef(ConfigMapKeySelector configMapKeyRef) { this.configMapKeyRef = configMapKeyRef; }