biometric:reference-helm michaelobrien$ kubectl create secret generic spring-security --from-literal=spring.user.name=demo --from-literal=spring.user.password=password
secret/spring-security created
biometric:reference-helm michaelobrien$ kubectl get secret spring-security -o yaml
apiVersion: v1
data:
spring.user.name: ZGVtbw==
spring.user.password: cGFzc3dvcmQ=
kind: Secret
metadata:
creationTimestamp: "2021-09-21T16:41:47Z"
name: spring-security
namespace: default
resourceVersion: "1554507"
selfLink: /api/v1/namespaces/default/secrets/spring-security
uid: 49733d89-4cdf-4d32-b871-7efa63b60c07
type: Opaque
in deployment yaml
- name: {{ .Chart.Name }}
envFrom:
- secretRef:
name: spring-security
#key: spring.user.password
in spring boot
String secret = System.getenv("spring.user.password");
redeploy
helm3 delete reference-nbi
sudo helm3 package reference-nbi
helm3 install --set name=reference-nbi reference-nbi ./reference-nbi
run and endpoint
http://localhost:30040/nbi/api
logs
kubectl logs -f reference-nbi-7c45ff855d-nh4dd
2021-09-21 19:27:43.607 INFO 8 --- [nio-8080-exec-9] c.c.reference.nbi.ApiController : secret: password