Is there an example of howto use spring.cloud.kubernetes.secrets.paths=/mnt/secrets-store
property to read secrets as files (mounted as a volume)?
My Pod.yaml
kind: Pod
apiVersion: v1
metadata:
name: nginx-mounted-secrets
namespace: default
labels:
aadpodidbinding: pod-mi
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: foo
mountPath: "/mnt/secrets-store"
readOnly: true
volumes:
- name: foo
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: spc
When I run the Pod the secrets are mounted
kubectl -n default exec -it nginx-mounted-secrets -- bash
root@nginx-mounted-secrets:/# ls /mnt/secrets-store
service-one-secret
service-two-secret
I've tried the following but the fields do not get populated:
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties
@Data
public class ApplicationSecrets {
private String serviceOneSecret;
private String serviceTwoSecret;
}
I'm using
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-config</artifactId>
<version>1.1.6.RELEASE</version>
</dependency>