diff --git a/app.rb b/app.rb index 5679d24..03568cb 100644 --- a/app.rb +++ b/app.rb @@ -5,6 +5,8 @@ class App < Sinatra::Base set :public_folder, File.dirname(__FILE__) + '/public' get "/" do - erb :index + secrets_base_dir = ENV["SECRETS_BASE_DIR"] + secrets_base_dir ||= "/tmp/secrets" + erb :index, locals: {secrets_base_dir: secrets_base_dir} end end diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 285fbc6..518904e 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -27,8 +27,22 @@ spec: - name: http containerPort: 8080 protocol: TCP - {{- if .Values.database.service.class }} + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + {{- if .Values.database.service.class }} + volumeMounts: + - name: db-credentials + mountPath: "/secrets/db-credentials" + readOnly: true env: + - name: SECRETS_BASE_DIR + value: /secrets - name: DATABASE_URL valueFrom: secretKeyRef: @@ -49,16 +63,6 @@ spec: secretKeyRef: name: {{ template "ruby-with-binding.fullname" . }}-db-secret key: password - {{- end }} - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - {{- if .Values.database.service.class }} volumes: - name: db-credentials secret: diff --git a/views/index.erb b/views/index.erb index 7f489e1..4f9d104 100644 --- a/views/index.erb +++ b/views/index.erb @@ -12,8 +12,13 @@

View environment vars and secret files

This little app will show environment variables and files mounted under /secret folder.

Secrets

+

List of files and their contents within secrets directory <%= secrets_base_dir %>:

-/secret/database/url - postgres://...
+<%=
+Dir["#{secrets_base_dir}/**/*"].map do |path|
+path + "=" + File.read(path)
+end.join("\n")
+%>
   

Environment Variables