We are trying to use Kubernetes to deploy our application, currently, we have +30 microservices and we have a files mess.
we tried Kustomization to add a patch and create ConfigMaps depending on the overlay, and also merge some files. But we always need to create a lot of files, 1 for each deployment/service. And at the end when we want to update something, for example, replicas, is a bit painful.
---
apiVersion: v1
kind: Service
metadata:
name: service1
spec:
ports:
- port: 3000
selector:
app: service1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: service1
spec:
selector:
matchLabels:
app: service1
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: service1
spec:
containers:
- image: pyfarm-registry.local:5000/pyfarm/svclocation:dev
name: service1
envFrom:
- configMapRef:
name: configName
ports:
- containerPort: 3000
imagePullSecrets:
- name: local-registry
We have this file duplicated by +30 times, changing names, and env variables. But I am sure has to have something to parse these templates.
We already tried to implement Helm, but is not what we are finding.
Can we do for example 1 file with variables and generate the other 30 files, also we need different namespaces. Is it possible?
The only solution we found is using bash, but there are something more elegant?
To be honest, it feels as if helm is perfectly suited to what you’re doing here. Helm’s superpowers are templating and release / change management.
In what way didn’t it work for you?
As Kustomization and Helm template (as you mentiones security/privilige reasons) are not working for you, I don't think that you can do anything else. Only things comes to my mind except BASH script are Tempalte Designers:
1) Jinja2 which is template languate for Python. It is fast, widely used and secure with the optional sandboxed template execution environment.
2) Mustache is a simple web template system with implementations available for ActionScript, C++ etc. It's call "logic-less" because there are no if statements, else clauses, or for loops.