Is it possible to have multiple clusters without duplicating `cluster.yaml`?
sevro opened this issue · 3 comments
I am trying to setup a development, staging, production CI/CD pipeline for cortex services and if I try to spin up multiple clusters with the same cluster.yaml
even in different environments I get:
error: a cluster named "$MY_CLUSTER" already created and updated in $MY_REGION
I see that this was at least considered before in "Consider how to merge CLI environment config with cluster config for multiple clusters #712" but I do not see it reflected as resolved in the docs which still has an example of multiple clusters using different cluster.yaml
files. It will definitely be unnecessarily confusing to have cluster-dev.yaml
, cluster-staging.yaml
, and cluster-prod.yaml
on all three branches all out of sync with eachother any of which could be accidentally deployed/updated breaking things.
Or was this resolved and it is just not reflected in the docs? Or am I missing some other better way to set this up?
Also I am currently on version 0.35
if that makes a difference, but I see no difference in the docs about this.
@sevro the best way to accomplish what you're trying to do would be do use some sort of templating to generate cluster.yaml
files. There are a few ways you can do this. For example you could have a cluster.yaml
that looks like this:
cluster_name: cortex-${ENV_NAME}
region: us-west-2
...
And then in your CI environment, you can set the ENV_NAME
environment variable to dev/staging/prod, and then use envsubst
to generate the files (e.g. something like envsubst < cluster-template.yaml > cluster-prod.yaml
.
Alternatively, you can use something like Jinja, or you could write a Python script which takes in an argument for the name of your environment and writes the appropriate cluster.yaml
file (or it could take no args and just write all three).
That is a solid solution, I was worried about the complexity of pulling in a whole templeting engine but envsubst
would be elegant for what I'm trying to do. Thanks!