Reputation: 541
I have an openshift project with around 20 deploymentconfigs and corresponding services, etc. I have one large template that declares those objects. Because of deployment order dependencies (services need to deploy in a specific order), I can't simply do
oc new-app --template=my-template
because everything starts deploying simultaneously. I would like to do something like
oc new-app --template=my-template --dc=my-specific-dc
Of course that last option doesn't exist. I can't use "--selector=..." either. That would have been nice. This seems like a big limitation. Is there a way to cherry pick deployments from a master template?
I could split up all my services into separate dedicated templates, but my parameter list (which is quite extensive) would need to be repeated in each template as there is no "include" annotation for including common yaml (or JSON). That would be a nightmare to maintain.
Any ideas how to solve the deployment ordering problem?
Upvotes: 0
Views: 578
Reputation: 1779
What Graham suggested is a good solution. Another option I could think of if you are willing to split the templates would be to move all the shared parameters out and use them to populate a ConfigMap which could be used across deployments, and in different files. This is the option I would choose for maintainability. Once the templates are split, from there, scripting deployment is trivial.
Another potential option which I have come across is the "wait-for-ready" annotation, which is in alpha, and according to the docs, will allow you to bring up some deployments before others, although this might not be fine grained enough for you. Have not tried this myself
Upvotes: 0
Reputation: 58563
I would suggest writing a little Python script would give you the most flexibility.
import json
import sys
data = json.loads(sys.stdin.read())
newitems = []
for item in data['items']:
if item['kind'] == 'ConfigMap':
if item['metadata']['name'] == 'poc-kernel-gateway-1-cfg':
newitems.append(item)
data['items'] = newitems
print(data)
Run it like:
oc get templates poc-kernel-gateway-1 -o json | oc process --param A=B -f - | python /tmp/process.py
or if have the template in a file already:
oc process --param A=B -f template.py | python /tmp/process.py
You can then feed the result into oc create
.
As to ordering issues, one approach is to use an init container to pause a deployment until the other services/applications it depends on are ready.
Upvotes: 1