
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,707 Views
Scenario - you are deploying your application, you added environment variables, secrets etc. How do you persist your changes so you do not have to type oc commands again?
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,591 Views
By this time you probably now the answer already, but just in case...
oc commands have as a purpose to interact with the API server, imperatively.
The API server is responsible (among other tasks) for validating, storing and retrieving the configuration to/from etcd. This configuration would basically be stored in etcd as a declarative definition of how your deployed application should look like. You want to recover this final configuration.
Once you have deployed your application (that means, created all necessary resources in one or many namespaces), you can export all these as a list, so they can be redeployed whenever you need.
You would do that with the command: oc get -o yaml|json <list of resources you want to export>
whose output can be redirected to a file. I won't lie to you, it looks ugly and it might need some cleaning.
One step further would be to create a template using those resources. For that you could use: OpenShift Templates, Kustomize, Helm, Jinja2, etc ... That'd make the redeployment much easier.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,592 Views
By this time you probably now the answer already, but just in case...
oc commands have as a purpose to interact with the API server, imperatively.
The API server is responsible (among other tasks) for validating, storing and retrieving the configuration to/from etcd. This configuration would basically be stored in etcd as a declarative definition of how your deployed application should look like. You want to recover this final configuration.
Once you have deployed your application (that means, created all necessary resources in one or many namespaces), you can export all these as a list, so they can be redeployed whenever you need.
You would do that with the command: oc get -o yaml|json <list of resources you want to export>
whose output can be redirected to a file. I won't lie to you, it looks ugly and it might need some cleaning.
One step further would be to create a template using those resources. For that you could use: OpenShift Templates, Kustomize, Helm, Jinja2, etc ... That'd make the redeployment much easier.