Spring Cloud Kubernetes: Cannot pass secrets into application_properties.yaml

9/27/2019

I'm trying to apply the spring cloud kubernetes to be able to use my secrets inside of my application_properties.yml file.

I've set up my deployment.yaml like so

spec:
  template:
   spec:
    containers:
      - env:
          volumeMounts:
            - name: sep-secrets
              mountPath: /etc/secrets/psql-access
              readOnly: true
    volumes:
      - name: sep-secrets
        secret:
          secretName: postgres-access
          defaultMode: 420

with my secret created with the name "postgres-access" my secrets.yml looks like this

apiVersion: v1
data:
  dev.pwd: <>
  dev.user: <>
  prod.pwd: <>
  prod.user: <>
  qa.pwd: <>
  qa.user: <>
kind: Secret  
  name: postgres-access
  namespace: sep

In my application_properties.yaml

spring:
  cloud:
    kubernetes:
      secrets:
        enabled: true
        name: postgres-access
        namespace: sep
        paths:
          - /etc/secrets/psql-access

and trying to access my secret inside my application.yml file

spring:
  datasource:
    username: ${dev.user}
    password: ${dev.pwd}

however this is not pulling in my credentials for dev.user and dev.pwd

it is failing on authentication as it is using 'dev.user' and 'dev.pwd' for user name and auth respectively.

-- Addison Joseph
application.properties
kubernetes
kubernetes-secrets
spring
spring-cloud-kubernetes

0 Answers