How to Add Custom Files to Docker Images in Kubernetes?

0
5
Asked By CraftyPineapple42 On

I'm working with Helm charts in Kubernetes and need to add some custom artifacts to my Docker images. For instance, we're using Keycloak with a custom theme that we update regularly. Currently, I create a new Docker image that pulls from the base Keycloak image and adds my theme with a simple command:
```
FROM keycloak:26.4.0
ADD theme /opt/keycloak/providers
```
This setup has led to issues with tracking updates to the base image separately from my chart updates in ArgoCD, resulting in problems like changes in environment variable names. I've faced similar situations with other applications, like loading an Angular app in an NGINX deployment and adding custom plugins to Pulsar. So I'm curious, how do others handle this situation? Would using an init container for just the artifacts be a viable solution, and would this work in OpenShift?

2 Answers

Answered By ContainerConnoisseur11 On

Have you considered using ephemeral volumes? They're in beta since K8s v1.33 and allow you to utilize OCI-images stored in a registry as volumes. You can tag them for versioning too, which adds a nice layer of flexibility.

Answered By TechGuru87 On

A possible solution could be to store your files in an image and mount that image as a volume in your pod. This way, you only manage the files in one place, and it helps simplify your deployment process.

NerdyOctopus33 -

Exactly! Image volumes are the way to go. If you're using Containerd 2.2, it even allows for image volume subpaths, which means you can specify only the parts you need. Previously, you’d use an init container to copy files into a volume that's shared with the main containers.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.