io.fabric8.kubernetes.api.model.SecretKeySelector Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.SecretKeySelector.
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 testSecretKeyRef() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.secretKeyRefs", "[{envVarName: 'SECRET_PASSWORD', secretName: 'mySecret', dataKey: 'password'}]"); 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 secretKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "SECRET_PASSWORD", secretKeyRefEnvVar.getName()); SecretKeySelector secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "password", secretKeySelector.getKey()); }
Example #2
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testSecretKeyRefGlobal() { AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), null); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); KubernetesDeployerProperties.SecretKeyRef secretKeyRef = new KubernetesDeployerProperties.SecretKeyRef(); secretKeyRef.setEnvVarName("SECRET_PASSWORD_GLOBAL"); secretKeyRef.setSecretName("mySecretGlobal"); secretKeyRef.setDataKey("passwordGlobal"); kubernetesDeployerProperties.setSecretKeyRefs(Collections.singletonList(secretKeyRef)); 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 secretKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "SECRET_PASSWORD_GLOBAL", secretKeyRefEnvVar.getName()); SecretKeySelector secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecretGlobal", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "passwordGlobal", secretKeySelector.getKey()); }
Example #3
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testSecretKeyRefGlobalFromYaml() 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 secretKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "SECRET_PASSWORD", secretKeyRefEnvVar.getName()); SecretKeySelector secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "myPassword", secretKeySelector.getKey()); }
Example #4
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 #5
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
@Test public void testSecretKeyRefMultiple() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.secretKeyRefs", "[{envVarName: 'SECRET_PASSWORD', secretName: 'mySecret', dataKey: 'password'}," + "{envVarName: 'SECRET_USERNAME', secretName: 'mySecret2', dataKey: 'username'}]"); 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 secretKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "SECRET_PASSWORD", secretKeyRefEnvVar.getName()); SecretKeySelector secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "password", secretKeySelector.getKey()); secretKeyRefEnvVar = envVars.get(1); assertEquals("Unexpected env var name", "SECRET_USERNAME", secretKeyRefEnvVar.getName()); secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret2", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "username", secretKeySelector.getKey()); }
Example #6
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 4 votes |
@Test public void testSecretKeyRefPropertyOverride() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.secretKeyRefs", "[{envVarName: 'SECRET_PASSWORD_GLOBAL', secretName: 'mySecret', dataKey: 'password'}," + "{envVarName: 'SECRET_USERNAME', secretName: 'mySecret2', dataKey: 'username'}]"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); List<KubernetesDeployerProperties.SecretKeyRef> globalSecretKeyRefs = new ArrayList<>(); KubernetesDeployerProperties.SecretKeyRef globalSecretKeyRef1 = new KubernetesDeployerProperties.SecretKeyRef(); globalSecretKeyRef1.setEnvVarName("SECRET_PASSWORD_GLOBAL"); globalSecretKeyRef1.setSecretName("mySecretGlobal"); globalSecretKeyRef1.setDataKey("passwordGlobal"); KubernetesDeployerProperties.SecretKeyRef globalSecretKeyRef2 = new KubernetesDeployerProperties.SecretKeyRef(); globalSecretKeyRef2.setEnvVarName("SECRET_USERNAME_GLOBAL"); globalSecretKeyRef2.setSecretName("mySecretGlobal"); globalSecretKeyRef2.setDataKey("usernameGlobal"); globalSecretKeyRefs.add(globalSecretKeyRef1); globalSecretKeyRefs.add(globalSecretKeyRef2); kubernetesDeployerProperties.setSecretKeyRefs(globalSecretKeyRefs); 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 secretKeyRefEnvVar = envVars.get(0); assertEquals("Unexpected env var name", "SECRET_PASSWORD_GLOBAL", secretKeyRefEnvVar.getName()); SecretKeySelector secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "password", secretKeySelector.getKey()); // unique deploy prop secretKeyRefEnvVar = envVars.get(1); assertEquals("Unexpected env var name", "SECRET_USERNAME", secretKeyRefEnvVar.getName()); secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecret2", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "username", secretKeySelector.getKey()); // unique, non-overridden global prop secretKeyRefEnvVar = envVars.get(2); assertEquals("Unexpected env var name", "SECRET_USERNAME_GLOBAL", secretKeyRefEnvVar.getName()); secretKeySelector = secretKeyRefEnvVar.getValueFrom().getSecretKeyRef(); assertEquals("Unexpected secret name", "mySecretGlobal", secretKeySelector.getName()); assertEquals("Unexpected secret data key", "usernameGlobal", secretKeySelector.getKey()); }
Example #7
Source File: ExternalConfigurationEnvVarSource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
@Description("Reference to a key in a Secret.") @KubeLink(group = "core", version = "v1", kind = "secretkeyselector") @JsonInclude(value = JsonInclude.Include.NON_NULL) public SecretKeySelector getSecretKeyRef() { return secretKeyRef; }
Example #8
Source File: ExternalConfigurationEnvVarSource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public void setSecretKeyRef(SecretKeySelector secretKeyRef) { this.secretKeyRef = secretKeyRef; }
Example #9
Source File: StringOrSecretSelector.java From enmasse with Apache License 2.0 | 4 votes |
public SecretKeySelector getValueFromSecret() { return valueFromSecret; }
Example #10
Source File: StringOrSecretSelector.java From enmasse with Apache License 2.0 | 4 votes |
public void setValueFromSecret(SecretKeySelector valueFromSecret) { this.valueFromSecret = valueFromSecret; }