K8s Archive - woveon/wovtools GitHub Wiki

include ref=HeaderPageArchive

The K8s Archive (in wovtools/k8s) has templated Kubernetes YAML files in a Wov File Format (which is Handlebars with additions, see below) that are built specifically for a cluster, then archived and versioned for deploiyment with matching database and Docker containers. Conventionally, these files are one for Ingress and one Service and Deployment for each microservice but any .wov file in the directory will be archived and deployed.

Deployment Example:

# Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: apirest
spec:
  template:
    metadata:
      labels:
        app: apirest
    spec:
      containers:
        - image: {{ARCHIVEREPOSITORY}}/{{PROJECT}}/apirest:{{STAGE}}_{{PVER}}
          name: apirest
          imagePullPolicy: Always

Usage

  • Create a Kubernetes file in wovtools/k8s, make sure you append the 'wov' extension.
  • Write the Kubernetes yaml file as needed. Where you want to apply configuration information, insert the variable in double brackets as '{{WOV_PROJECT}}' (yes, include the backslash).
  • The wov-env command will build these for each cluster configuration and archive and deployment as needed.

AWS S3 Location

The archive is in an AWS S3 fileserver, and I use 'wovtools.COMPANY.com' for its name. The directory structure is s3://wovtools.COMPANY.com/archive/CLUSTER/PROJECT/STAGE/PVER_SVER/.

IMPORTANT: You need to be mindful of secrurity and place restrictions at the STAGE level.

Wov File Format

.wov files are a double handlebars template which apply the STAGE, and then the wov-env --envs variables. This is used for the 'wovtools/k8s/*.yaml.wov' files so that the resulting yaml can be designed with stage-specific login in them.

The WovTools variables are also available to use (ex. STAGE, PROVIDER, PROJECT, ME, ARCHIVEREPOSITORY, PVER, SVER).

There is also logic (see how {{STAGE}} is filled in on the first pass and then the '{{ }}' bracketed templated data is filled in):

\{{#if_eq {{STAGE}} "prod"}}
...yaml...
\{{else}}
...yaml...
\{{/if_eq}}

Here's an example from a Kubernetes yaml file for ingress. It defines a route that does not exist in production, but does for all other stages so the routes to the apidata microservice are accessible for testing:

\{{#if_eq {{STAGE}} "prod"}}
\{{else}}
      - path: /apidata/{{apidata.ver}}
        backend:
          serviceName: apidata
          servicePort: 80
\{{/if_eq}}