Skip to content

Latest commit

 

History

History
90 lines (69 loc) · 3.29 KB

architecture.md

File metadata and controls

90 lines (69 loc) · 3.29 KB
layout permalink title redirect_from
default
/architecture/
Architecture
/docs/architecture.md/
/docs/architecture/

Architecture and Internal Design

  • TOC {:toc}

kompose has 3 stages: Loader, Transformer and Outputter. Each stage should have a well-defined interface, so it is easy to write a new Loader, Transformer, or Outputters and plug it in. Currently, only Loader and Transformer interfaces are defined.

Design Diagram

Loader

The Loader reads the input file now kompose supports Docker Compose v1, v2 and converts it to KomposeObject.

Loader is represented by a Loader interface:

type Loader interface {
      LoadFile(file string) kobject.KomposeObject
}

Every loader “implementation” should be placed into kompose/pkg/loader (like compose). More input formats will be supported in the future. You can take a look for more details at:

KomposeObject

KomposeObject is Kompose internal representation of all containers loaded from input file. First version of KomposeObject looks like this (source: kobject.go):

// KomposeObject holds the generic struct of Kompose transformation
type KomposeObject struct {
    ServiceConfigs map[string]ServiceConfig
}

// ServiceConfig holds the basic struct of a container
type ServiceConfig struct {
    ContainerName string
    Image         string
    Environment   []EnvVar
    Port          []Ports
    Command       []string
    WorkingDir    string
    Args          []string
    Volumes       []string
    Network       []string
    Labels        map[string]string
    Annotations   map[string]string
    CPUSet        string
    CPUShares     int64
    CPUQuota      int64
    CapAdd        []string
    CapDrop       []string
    Entrypoint    []string
    Expose        []string
    Privileged    bool
    Restart       string
    User          string
}

Transformer

The Transformer takes KomposeObject and converts it to target/output format (currently, there are sets of Kubernetes/OpenShift objects). Similar to the Loader, Transformer is represented by a Transformer interface:

type Transformer interface {
     Transform(kobject.KomposeObject, kobject.ConvertOptions) []runtime.Object
}

If you wish to add more providers containing different kinds of objects, the Transformer would be the place to look into. Currently, Kompose supports Kubernetes (by default) and OpenShift providers. More details at:

Outputter

The Outputter takes the Transformer result and executes the given action. For example, action can display results to stdout or directly deploy artifacts to Kubernetes/OpenShift.