Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
How can sslcert and sslkey be passed as environment variables in Kubernetes?

I'm trying to make my app connect to my PostgreSQL instance through an encrypted and secure connection.

I've configured my server certificate and generated the client cert and key files.

The following command connects without problems:

psql "sslmode=verify-ca sslrootcert=server-ca.pem \
  sslcert=client-cert.pem sslkey=client-key.pem \
  hostaddr=<instance_ip> \
  port=5432 \
  user=db dbname=dbname"

Unfortunately, I couldn't find a way to pass the client key as value, I can only pass the file path. Even using the default environment variables from psql, this is not possible: https://www.postgresql.org/docs/current/libpq-envars.html

Golang follows the same specifications as lib-pq and there is no way to pass the cert and key values: https://pkg.go.dev/github.com/lib/pq?tab=doc#hdr-Connection_String_Parameters.

I want to store the client cert and key in environment variables for security reasons, I don't want to store sensitive files in github/gitlab.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Just set the values in your environment and you can get them in a init function.

func init() {
   var := os.Getenv("SOME_KEY")
}

When you want to set these with K8s you would just do this in a yaml file.

apiVersion: v1
kind: Secret
metadata:
  name: my-secret
data:
  SOME_KEY: the-value-of-the-key

Then to inject into the environment do.

envFrom:
  - secretRef:
    name: my-secret

Now when your init function runs it will we able to see SOME_KEY.

If you want to pass a secret as a file you do something like this.

kubectl create secret generic my-secret-files --from-file=my-secret-file-1.stuff --from-file=my-secret-file-2.stuff

Then in your deployment.

volumes:
  - name: my-secret-files
    secret:
      secretName: my-secret-files

Also in your deployment under you container.

volumeMounts:
  - name: my-secret-files
    mountPath: /config/

Now your init would be able to see.

/config/my-secret-file-1.stuff
/config/my-secret-file-2.stuff
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda