io.fabric8.kubernetes.api.model.EnvVarSource Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.EnvVarSource.
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: LanderPodFactory.java From data-highway with Apache License 2.0 | 5 votes |
private EnvVar envFromFieldPath(String name, String fieldPath) { EnvVarSource envVarSource = new EnvVarSource(); envVarSource.setFieldRef(new ObjectFieldSelector()); ObjectFieldSelector fieldRef = envVarSource.getFieldRef(); fieldRef.setFieldPath(fieldPath); return new EnvVarBuilder().withName(name).withValueFrom(envVarSource).build(); }
Example #2
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 #3
Source File: DeploymentPropertiesResolver.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private EnvVar buildSecretKeyRefEnvVar(KubernetesDeployerProperties.SecretKeyRef secretKeyRef) { SecretKeySelector secretKeySelector = new SecretKeySelector(); EnvVarSource envVarSource = new EnvVarSource(); envVarSource.setSecretKeyRef(secretKeySelector); EnvVar secretKeyEnvRefVar = new EnvVar(); secretKeyEnvRefVar.setValueFrom(envVarSource); secretKeySelector.setName(secretKeyRef.getSecretName()); secretKeySelector.setKey(secretKeyRef.getDataKey()); secretKeyEnvRefVar.setName(secretKeyRef.getEnvVarName()); return secretKeyEnvRefVar; }
Example #4
Source File: DefaultContainerFactory.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private EnvVar getGUIDEnvVar() { ObjectFieldSelector objectFieldSelector = new ObjectFieldSelector(); objectFieldSelector.setFieldPath("metadata.uid"); EnvVarSource envVarSource = new EnvVarSource(); envVarSource.setFieldRef(objectFieldSelector); EnvVar guidEnvVar = new EnvVar(); guidEnvVar.setValueFrom(envVarSource); guidEnvVar.setName(SPRING_CLOUD_APPLICATION_GUID); return guidEnvVar; }
Example #5
Source File: AbstractModel.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
/** * Build an environment variable instance with the provided name from a field reference * using the Downward API * * @param name The name of the environment variable * @param field The field path from which the value is set * * @return The environment variable object */ protected static EnvVar buildEnvVarFromFieldRef(String name, String field) { EnvVarSource envVarSource = new EnvVarSourceBuilder() .withNewFieldRef() .withFieldPath(field) .endFieldRef() .build(); return new EnvVarBuilder() .withName(name) .withValueFrom(envVarSource) .build(); }
Example #6
Source File: EnvVarsTest.java From che with Eclipse Public License 2.0 | 5 votes |
@Test public void shouldOverrideEnvOnApplyingEnvVarIfContainersAlreadyHaveSomeEnvVars() throws Exception { // given EnvVar existingInitCEnvVar = new EnvVar("TEST_ENV", "value", null); EnvVar existingCEnvVar = new EnvVar("TEST_ENV", null, new EnvVarSource()); PodData pod = new PodData( new PodBuilder() .withNewMetadata() .withName("pod") .endMetadata() .withNewSpec() .withInitContainers( new ContainerBuilder() .withName("initContainer") .withEnv(copy(existingInitCEnvVar)) .build()) .withContainers( new ContainerBuilder() .withName("container") .withEnv(copy(existingCEnvVar)) .build()) .endSpec() .build()); // when envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue"))); // then List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv(); assertEquals(initCEnv.size(), 1); assertEquals(initCEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null)); List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv(); assertEquals(containerEnv.size(), 1); assertEquals(containerEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null)); }
Example #7
Source File: EnvVarsTest.java From che with Eclipse Public License 2.0 | 5 votes |
@Test public void shouldProvisionEnvIntoK8SListIfContainerAlreadyHasSomeEnvVars() throws Exception { // given EnvVar existingInitCEnvVar = new EnvVar("ENV", "value", null); EnvVar existingCEnvVar = new EnvVar("ENV", null, new EnvVarSource()); PodData pod = new PodData( new PodBuilder() .withNewMetadata() .withName("pod") .endMetadata() .withNewSpec() .withInitContainers( new ContainerBuilder() .withName("initContainer") .withEnv(copy(existingInitCEnvVar)) .build()) .withContainers( new ContainerBuilder() .withName("container") .withEnv(copy(existingCEnvVar)) .build()) .endSpec() .build()); // when envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue"))); // then List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv(); assertEquals(initCEnv.size(), 2); assertEquals(initCEnv.get(0), existingInitCEnvVar); assertEquals(initCEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null)); List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv(); assertEquals(containerEnv.size(), 2); assertEquals(containerEnv.get(0), existingCEnvVar); assertEquals(containerEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null)); }