Garima Bathla
Garima Bathla

Reputation: 41

How to pass ConfigMap value as env variable when using default helm charts in gitlab autodevops

I am a newbie, just getting started with out of the box magic of auto devops by gitlab.

I have a very basic Golang Microservice that I am able to deploy - and it uses the default helm charts out of the box (creates namespace, service, deployment, docker registry management), and I provide my own Dockerfiles to build the docker image.

Question:

How do I read an existing K8 ConfigMap entry as environment variable to the microservice without providing a custom helm chart? ConfigMap is created in a different namespace by some other process

How do I override the namespace in which the Microservice should be deployed and not create a new namespace? I want multiple Microservices to be deployed into same namespace - I don't want a different namespace for each repository.

Basically I don't want to provide custom helm charts as I think if I provide custom chart then I will also need to do the complete setup of setting up docker registry on K8 cluster too - and I want to avoid that, I want to customize my application components, service type (I don't want ClusterIP), change namespace, refer to configMap as environment variable - without creating custom helm charts for my basic golang based micro service.

Upvotes: 3

Views: 887

Answers (1)

VonC
VonC

Reputation: 1329092

See if GitLab 15.6 (November 2022) can help in your case:

Mount ConfigMap to volumes with the Auto Deploy chart

The default Auto Deploy Helm chart now supports the extraVolumes and extraVolumeMounts options.

In past releases, you could specify only Persistent Volumes for Kubernetes.

Among other use cases, you can now mount:

  • Secrets and ConfigMaps as files to Deployments, CronJobs, and Workers.
  • Existing or external Persistent Volumes Claims to Deployments, CronJobs, and Workers.
  • Private PKI CA certificates with hostPath mounts to achieve trust with the PKI.

Thanks to Maik Boltze for this community contribution.

See Documentation and Issue.

Upvotes: 0

Related Questions