Java Code Examples for io.fabric8.kubernetes.api.model.Secret#setData()
The following examples show how to use
io.fabric8.kubernetes.api.model.Secret#setData() .
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: KubernetesService.java From vault-crd with Apache License 2.0 | 6 votes |
void modifySecret(Vault resource, VaultSecret vaultSecret) { Resource<Secret, DoneableSecret> secretDoneableSecretResource = client.secrets().inNamespace(resource.getMetadata().getNamespace()).withName(resource.getMetadata().getName()); Secret secret; if (secretDoneableSecretResource.get() != null) { secret = secretDoneableSecretResource.get(); } else { secret = newSecretInstance(resource, vaultSecret); } secret.setType(vaultSecret.getType()); updateAnnotations(secret, vaultSecret.getCompare()); secret.setData(vaultSecret.getData()); secretDoneableSecretResource.createOrReplace(secret); log.info("Modified secret {} in namespace {}", resource.getMetadata().getName(), resource.getMetadata().getNamespace()); }
Example 2
Source File: DefaultContainerFactoryTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void testProbeCredentialsInvalidSecret() throws Exception { Secret secret = randomSecret(); secret.setData(Collections.singletonMap("unexpectedkey", "dXNlcjpwYXNz")); String secretName = secret.getMetadata().getName(); Map<String,String> appProperties = new HashMap<>(); appProperties.put("spring.cloud.deployer.kubernetes.probeCredentialsSecret", secretName); AppDefinition definition = new AppDefinition("app-test", appProperties); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), appProperties); ContainerConfiguration containerConfiguration = new ContainerConfiguration("app-test", appDeploymentRequest) .withExternalPort(8080) .withProbeCredentialsSecret(secret); ContainerFactory containerFactory = new DefaultContainerFactory(new KubernetesDeployerProperties()); containerFactory.create(containerConfiguration); fail(); }
Example 3
Source File: KubernetesService.java From vault-crd with Apache License 2.0 | 5 votes |
private Secret newSecretInstance(Vault resource, VaultSecret vaultSecret){ Secret secret = new Secret(); secret.setType(vaultSecret.getType()); secret.setMetadata(metaData(resource.getMetadata(), vaultSecret.getCompare())); secret.setData(vaultSecret.getData()); return secret; }
Example 4
Source File: TillerInstaller.java From microbean-helm with Apache License 2.0 | 5 votes |
protected Secret createSecret(final String namespace, final URI tlsKeyUri, final URI tlsCertUri, final URI tlsCaCertUri, final Map<String, String> labels) throws IOException { final Secret secret = new Secret(); secret.setType("Opaque"); final Map<String, String> secretData = new HashMap<>(); try (final InputStream tlsKeyStream = read(tlsKeyUri)) { if (tlsKeyStream != null) { secretData.put("tls.key", Base64.getEncoder().encodeToString(toByteArray(tlsKeyStream))); } } try (final InputStream tlsCertStream = read(tlsCertUri)) { if (tlsCertStream != null) { secretData.put("tls.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCertStream))); } } try (final InputStream tlsCaCertStream = read(tlsCaCertUri)) { if (tlsCaCertStream != null) { secretData.put("ca.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCaCertStream))); } } secret.setData(secretData); final ObjectMeta metadata = new ObjectMeta(); metadata.setNamespace(normalizeNamespace(namespace)); metadata.setName(SECRET_NAME); metadata.setLabels(normalizeLabels(labels)); secret.setMetadata(metadata); return secret; }
Example 5
Source File: DefaultContainerFactoryTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private Secret randomSecret() { String secretName = "secret-" + UUID.randomUUID().toString().substring(0, 18); String secretValue = "dXNlcjpwYXNz"; // base64 encoded string of: user:pass ObjectMeta objectMeta = new ObjectMeta(); objectMeta.setName(secretName); Secret secret = new Secret(); secret.setData(Collections.singletonMap(ProbeCreator.PROBE_CREDENTIALS_SECRET_KEY_NAME, secretValue)); secret.setMetadata(objectMeta); return secret; }
Example 6
Source File: KubernetesAppDeployerIntegrationTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private Secret randomSecret() { Map<String, String> secretData = new HashMap<>(); secretData.put("d-" + UUID.randomUUID().toString().substring(0, 5), "dmFsdWUx"); secretData.put("d-" + UUID.randomUUID().toString().substring(0, 5), "dmFsdWUy"); Secret secret = new Secret(); secret.setData(secretData); ObjectMeta objectMeta = new ObjectMeta(); objectMeta.setName("secret-" + UUID.randomUUID().toString().substring(0, 5)); secret.setMetadata(objectMeta); return kubernetesClient.secrets().create(secret); }