Skip to content

Instantly share code, notes, and snippets.

@lkwg82
Last active January 19, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkwg82/e9434e5d8c5f01f3eac2019e300ab813 to your computer and use it in GitHub Desktop.
Save lkwg82/e9434e5d8c5f01f3eac2019e300ab813 to your computer and use it in GitHub Desktop.
openshift wrapper

Summary:

Have developer friendly wrapper for openshift with an application-centric perspective.

Rationale:

Avoid steep learning curve to initial learn oc .... commands and concepts. Enable self-service by design.

Goals:

  • have the application openshift configuration in the application repository
  • have a common stage-aware config tree at hand like hiera in puppet (see https://puppet.com/docs/puppet/4.10/hiera_intro.html)
  • have a really simple cli for deployment of the openshift config (stages aware)

How should it look like?

this is the directory tree

/
 .openshift/
            global/
                   build.yml
                   ...
                   config.yml
                   ...
                   deployment.yml
                   network-policy.yml
                   project.yml
                   secrets.yml
                   services_and_routes.yml
            stages/
                  dev/
                      config.yml
                  tst/
                      config.yml
                  pro/
                      config.yml
 src/
 Makefile

this is the command ocw (openshift wrapper)

$ ocw help
ocw <command> [<args>]
Openshift wrapper 0.0.1

commands:

help             display help
deploy <STAGE>   merges files from global/ with files from stage/<STAGE>
                 and pushes config to openshift
pull             fetches the current config from openshift for all stages

ocw pull would pull config changes and write those into files into stages/<stage> config named by the type

$ oc types | grep "^*" | sed -e 's#^* ##g; s#:##g; s#\ .*##'| tr '[:upper:]' '[:lower:]' | sort
build
builds
containers
deployment
image
image
labels
nodes
pods
projects
replication
routes
secrets
services
volumes

ocw deploy <STAGE> would merge files from global/ with files from stage/<STAGE>.

behaviour:  - will prevent duplicate configuration in global (any merge which will override any config from other file, will be rejected)

  • will prevent duplicate configuration in stages/<STAGE> (any merge which will override any config from other file, will be rejected)  - config from stages/<STAGE> overrides global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment