Reading a text file from kubernetes root using java springboot

2/1/2019

I am writing a secret to a file using Drone while deploying to Kubernates. How can read this file using java Springboot?

Drone commands

 commands:
   - touch naspvtkey.txt
   - ls -a
   - echo "$NASPVTKEY" > naspvtkey.txt

Drone outputs:

+ touch naspvtkey.txt -------> created the file
+ ls -a
.DS_Store
.drone.yml
.drone.yml.sig
.git
.gitignore
.mvn
Dockerfile
README.md
kubernetes
mvnw
naspvtkey.txt
pom.xml
src
+ echo "$NASPVTKEY" > naspvtkey.txt ---------> added my secret

I am trying to access the file using

  file = new File("/naspvtkey.txt");
-- Hearaman
drone.io
java
kubernetes
spring-boot

1 Answer

2/2/2019

Ensure container user has permission to create file in root directory.

-- P Ekambaram
Source: StackOverflow