Excerpts from Randy Barlow's message of 2017-07-05 13:42 -04:00:
On Tue, 2017-07-04 at 11:16 -0600, Kevin Fenzi wrote:
> I am pretty sure you can get it to dump out the json
> of the existing config, so you could in theory set things up, adjust
> via
> the web interface and get it the way you want it, then dump the json
> and
> we can use that in prod.
I think this is the right workflow, but I wanted to point out that the
JSON will have to be "massaged" in some way. I recently took an
OpenShift course at Red Hat and we learned that this JSON export/import
process does require some hand editing, but the course was an intro
course and so we didn't go into the details about what exactly needed
to be edited or in what way.
Speaking only from my very limited experience -- I think the reason it
needs massaging is that when you export an object with oc, it includes
various (read-only) status properties -- ones which reflect the current
state in time and are not configurable. You wouldn't want those to be
tracked in git or posted back when you update the object, because that's
kind of meaningless.
Here is an example below (and btw I suggest YAML over JSON because it's
easier to edit, oc happily deals in either format). You can see large
parts are not configuration, for example the top-level "status" key,
"creationTimestamp", the JSON blob in
"kubectl.kubernetes.io/last-applied-configuration" annotation,
"selfLink", "uid", etc.
I think oc knows to ignore those when you post an object back, but you
would want to edit them out before you commit it to git I guess.
$ oc -n waiverdb-stg get route waiverdb-stg-web -o yaml
apiVersion: v1
kind: Route
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration:
'{"kind":"Route","apiVersion":"v1","metadata":{"name":"waiverdb-stg-web","creationTimestamp":null,"labels":{"app":"waiverdb"}},"spec":{"host":"waiverdb.stage.engineering.redhat.com","to":{"kind":"Service","name":"waiverdb-stg-web","weight":null},"port":{"targetPort":"web"},"tls":{"termination":"edge","insecureEdgeTerminationPolicy":"Redirect"}},"status":{"ingress":null}}'
creationTimestamp: 2017-06-22T00:18:48Z
labels:
app: waiverdb
name: waiverdb-stg-web
namespace: waiverdb-stg
resourceVersion: "6225347"
selfLink: /oapi/v1/namespaces/waiverdb-stg/routes/waiverdb-stg-web
uid: 5cc0dced-56e0-11e7-83a0-009b1a10019b
spec:
host:
waiverdb.stage.engineering.redhat.com
port:
targetPort: web
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: waiverdb-stg-web
weight: 100
wildcardPolicy: None
status:
ingress:
- conditions:
- lastTransitionTime: 2017-06-22T00:18:48Z
status: "True"
type: Admitted
host:
waiverdb.stage.engineering.redhat.com
routerName: router
wildcardPolicy: None
- conditions:
- lastTransitionTime: 2017-06-30T09:50:58Z
status: "True"
type: Admitted
host:
waiverdb.stage.engineering.redhat.com
routerName: storage-project-router
wildcardPolicy: None
--
Dan Callaghan <dcallagh(a)redhat.com>
Senior Software Engineer, Products & Technologies Operations
Red Hat