I'm currently stuck and don`t know how to proceed.
This is my Spring Boot application.properties
...
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/postgres
spring.datasource.username=${POSTGRES_USER}
spring.datasource.password=${POSTGRES_PASSWORD}
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#Setup SSL
server.port: 8443
server.ssl.key-store: ${TLS_CERTIFICATE}
server.ssl.key-store-password: ${TLS_PASSWORD}
server.ssl.keyStoreType: PKCS12
server.ssl.keyAlias fundtr
...
My Deployment yaml for Spring Boot Application:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: f-app
namespace: default
spec:
replicas: 1
template:
metadata:
name: f-app
labels:
app: f-app
spec:
containers:
- name: f-app
image: eu.gcr.io/..../...
env:
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: postgres-config
key: postgres_user
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
name: postgres-config
key: postgres_password
- name: POSTGRES_HOST
valueFrom:
configMapKeyRef:
name: hostname-config
key: postgres_host
- name: TLS-CERTIFICATE
valueFrom:
secretKeyRef:
name: f-tls
key: Certificate.p12
- name: TLS-PASSWORD
valueFrom:
secretKeyRef:
name: f-tls
key: password
This is how I create secret in Kubernetes:
kubectl create secret generic f-tls --from-file=Certificate.p12 --from-literal=password=changeit
When it's deployed I'm getting
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: ContainerCannotRun
Message: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:295: setting oom score for ready process caused \"write /proc/13895/oom_score_adj: invalid argument\""
When I remove the Secrets from the Deployment yaml it's working fine, but I could not understand what it the root cause of this issue. I'm using Google Cloud Platform Container Engine.
TLS-CERTIFICATE
versusTLS_CERTIFICATE
a S.O. typo, or your descriptor also contains that typo? – Globularserver.ssl.key-store: ${TLS_CERTIFICATE}
would be much, much, much better served by eitherfile:///a/fs/path/Certificate.p12
orclasspath:///Certificate.p12
rather than trying to inject a binary value into an environment variable. I don't know that it's your problem, but I know for sure it's not helping matters – Globularserver.ssl.keyAlias fundtr
which is missing its K-V delimiter – Globularm following the main tutorial from https://kubernetes.io/docs/concepts/configuration/secret/. I saw another tutorial today http://software.danielwatrous.com/generate-tls-secret-for-kubernetes/ Maybe the issue is that I didn
t specify the type correctly. – Alcatrazfile://
also, but don't forget that the classpath can include folders as well as jars, so one need not bundle the p12 just to make it available on the classpath. A silly, non-production, example might be to volume mountwebapps/ROOT/WEB-INF/classes/Certificate.p12
which would make it appear on the classpath without actually living in your deployment (emphasis: just a silly example of the idea) – Globular