Java Code Examples for io.fabric8.kubernetes.api.model.EnvVar#setValueFrom()
The following examples show how to use
io.fabric8.kubernetes.api.model.EnvVar#setValueFrom() .
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: 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 2
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 3
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 4
Source File: EnvVars.java From che with Eclipse Public License 2.0 | 5 votes |
private void apply(List<EnvVar> targetEnv, Env env) { Optional<EnvVar> existingOpt = targetEnv.stream().filter(e -> e.getName().equals(env.getName())).findAny(); if (existingOpt.isPresent()) { EnvVar envVar = existingOpt.get(); envVar.setValue(env.getValue()); envVar.setValueFrom(null); } else { targetEnv.add(new EnvVar(env.getName(), env.getValue(), null)); } }
Example 5
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
private static DeploymentBuilder defaultCLusterOperator(String namespace, long operationTimeout, long reconciliationInterval) { Deployment clusterOperator = getDeploymentFromYaml(PATH_TO_CO_CONFIG); // Get env from config file List<EnvVar> envVars = clusterOperator.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv(); // Get default CO image String coImage = clusterOperator.getSpec().getTemplate().getSpec().getContainers().get(0).getImage(); // Update images for (EnvVar envVar : envVars) { switch (envVar.getName()) { case "STRIMZI_LOG_LEVEL": envVar.setValue(Environment.STRIMZI_LOG_LEVEL); break; case "STRIMZI_NAMESPACE": envVar.setValue(namespace); envVar.setValueFrom(null); break; case "STRIMZI_FULL_RECONCILIATION_INTERVAL_MS": envVar.setValue(Long.toString(reconciliationInterval)); break; case "STRIMZI_OPERATION_TIMEOUT_MS": envVar.setValue(Long.toString(operationTimeout)); break; default: if (envVar.getName().contains("KAFKA_BRIDGE_IMAGE")) { envVar.setValue(Environment.useLatestReleasedBridge() ? envVar.getValue() : Environment.BRIDGE_IMAGE); } else if (envVar.getName().contains("STRIMZI_DEFAULT")) { envVar.setValue(StUtils.changeOrgAndTag(envVar.getValue())); } else if (envVar.getName().contains("IMAGES")) { envVar.setValue(StUtils.changeOrgAndTagInImageMap(envVar.getValue())); } } } envVars.add(new EnvVar("STRIMZI_IMAGE_PULL_POLICY", Environment.COMPONENTS_IMAGE_PULL_POLICY, null)); // Apply updated env variables clusterOperator.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(envVars); return new DeploymentBuilder(clusterOperator) .editSpec() .withNewSelector() .addToMatchLabels("name", Constants.STRIMZI_DEPLOYMENT_NAME) .endSelector() .editTemplate() .editSpec() .editFirstContainer() .withImage(StUtils.changeOrgAndTag(coImage)) .withImagePullPolicy(Environment.OPERATOR_IMAGE_PULL_POLICY) .endContainer() .endSpec() .endTemplate() .endSpec(); }