• Stars
    star
    1,395
  • Rank 33,684 (Top 0.7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Transforms docker-compose, ECS, and Marathon configurations
https://travis-ci.org/micahhausler/container-transform.png https://coveralls.io/repos/micahhausler/container-transform/badge.png?branch=master Documentation Status

container-transform

container-transform is a small utility to transform various docker container formats to one another.

Currently, container-transform can parse and convert:

  • Kubernetes Pod specs
  • ECS task definitions
  • Docker-compose configuration files
  • Marathon Application Definitions or Groups of Applications
  • Chronos Task Definitions

and it can output to:

  • Systemd unit files

Examples

Compose to Kubernetes

$ cat docker-compose.yaml
version: '2'
services:
  etcd:
    cpu_shares: 102.4
    entrypoint: /usr/local/bin/etcd -data-dir /var/etcd/data -listen-client-urls http://127.0.0.1:2379,http://127.0.0.1:4001
      -advertise-client-urls http://127.0.0.1:2379,http://127.0.0.1:4001 -initial-cluster-token
      skydns-etcd
    image: gcr.io/google_containers/etcd-amd64:2.2.1
    mem_limit: 524288000b
  healthz:
    command: -cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 >/dev/null
      -port=8080
    cpu_shares: 10.24
    image: gcr.io/google_containers/exechealthz:1.0
    mem_limit: 20971520b
    ports:
    - '8080'
  kube2sky:
    command: --kubecfg-file=/etc/kubernetes/worker-kubeconfig.yaml --domain=cluster.local
    cpu_shares: 102.4
    image: gcr.io/google_containers/kube2sky:1.14
    mem_limit: 209715200b
    volumes:
    - /usr/share/ca-certificates:/etc/ssl/certs
    - /etc/kubernetes/worker-kubeconfig.yaml:/etc/kubernetes/worker-kubeconfig.yaml:ro
    - /etc/kubernetes/ssl:/etc/kubernetes/ssl:ro
  skydns:
    command: -machines=http://127.0.0.1:4001 -addr=0.0.0.0:53 -ns-rotate=false -domain=cluster.local.
    cpu_shares: 102.4
    image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c
    mem_limit: 209715200b
    ports:
    - 53/udp
    - '53'
$ container-transform -i compose -o kubernetes docker-compose.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: null
    version: latest
  name: null
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: null
      version: latest
  template:
    metadata:
      labels:
        app: null
        version: latest
    spec:
      containers:
      - command:
        - /usr/local/bin/etcd
        - -data-dir
        - /var/etcd/data
        - -listen-client-urls
        - http://127.0.0.1:2379,http://127.0.0.1:4001
        - -advertise-client-urls
        - http://127.0.0.1:2379,http://127.0.0.1:4001
        - -initial-cluster-token
        - skydns-etcd
        image: gcr.io/google_containers/etcd-amd64:2.2.1
        name: etcd
        resources:
          limits:
            cpu: 100.0m
            memory: 500Mi
      - args:
        - -cmd=nslookup
        - kubernetes.default.svc.cluster.local
        - 127.0.0.1
        - '>/dev/null'
        - -port=8080
        image: gcr.io/google_containers/exechealthz:1.0
        name: healthz
        ports:
        - containerPort: 8080
          protocol: TCP
        resources:
          limits:
            cpu: 10.0m
            memory: 20Mi
      - args:
        - --kubecfg-file=/etc/kubernetes/worker-kubeconfig.yaml
        - --domain=cluster.local
        image: gcr.io/google_containers/kube2sky:1.14
        name: kube2sky
        resources:
          limits:
            cpu: 100.0m
            memory: 200Mi
        volumeMounts:
        - mountPath: /etc/ssl/certs
          name: usr-share-ca-certificates
        - mountPath: /etc/kubernetes/worker-kubeconfig.yaml
          name: etc-kubernetes-worker-kubeconfig.yaml
          readOnly: true
        - mountPath: /etc/kubernetes/ssl
          name: etc-kubernetes-ssl
          readOnly: true
      - args:
        - -machines=http://127.0.0.1:4001
        - -addr=0.0.0.0:53
        - -ns-rotate=false
        - -domain=cluster.local.
        image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c
        name: skydns
        ports:
        - containerPort: 53
          protocol: UDP
        - containerPort: 53
          protocol: TCP
        resources:
          limits:
            cpu: 100.0m
            memory: 200Mi
      volumes:
      - hostPath:
          path: /etc/kubernetes/ssl
        name: etc-kubernetes-ssl
      - hostPath:
          path: /etc/kubernetes/worker-kubeconfig.yaml
        name: etc-kubernetes-worker-kubeconfig.yaml
      - hostPath:
          path: /usr/share/ca-certificates
        name: usr-share-ca-certificates

Compose to ECS

$ cat docker-compose.yml | container-transform  -v
{
    "family": "python-app",
    "volumes": [
        {
            "name": "host_logs",
            "host": {
                "sourcePath": "/var/log/myapp"
            }
        }
    ],
    "containerDefinitions": [
        {
            "memory": 1024,
            "image": "postgres:9.3",
            "name": "db",
            "essential": true
        },
        {
            "memory": 128,
            "image": "redis:latest",
            "name": "redis",
            "essential": true
        },
        {
            "name": "web",
            "memory": 64,
            "command": [
                "uwsgi",
                "--json",
                "uwsgi.json"
            ],
            "mountPoints": [
                {
                    "sourceVolume": "host_logs",
                    "containerPath": "/var/log/uwsgi/"
                }
            ],
            "environment": [
                {
                    "name": "AWS_ACCESS_KEY_ID",
                    "value": "AAAAAAAAAAAAAAAAAAAA"
                },
                {
                    "name": "AWS_SECRET_ACCESS_KEY",
                    "value": "1111111111111111111111111111111111111111"
                }
            ],
            "essential": true
        }
    ]
}
Container web is missing required parameter "image".
Container web is missing required parameter "cpu".

Quick Help

Usage: container-transform [OPTIONS] [INPUT_FILE]

  container-transform is a small utility to transform various docker
  container formats to one another.

  Default input type is compose, default output type is ECS

  Default is to read from STDIN if no INPUT_FILE is provided

  All options may be set by environment variables with the prefix "CT_"
  followed by the full argument name.

Options:
  -i, --input-type [ecs|compose|marathon|chronos|kubernetes]
  -o, --output-type [ecs|compose|systemd|marathon|chronos|kubernetes]
  -v, --verbose / --no-verbose    Expand/minify json output
  -q, --quiet                     Silence error messages
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Docker Image

To get the docker image, run:

docker pull micahhausler/container-transform:latest

To run the docker image:

docker run --rm -v $(pwd):/data/ micahhausler/container-transform  docker-compose.yml

# or
cat docker-compose.yml | docker run --rm -i micahhausler/container-transform

Installation

To install the latest release (Python 3 only), type:

pip install container-transform

To install the latest code directly from source, type:

pip install git+git://github.com/micahhausler/container-transform.git

Documentation

Full documentation is available at http://container-transform.readthedocs.org

License

MIT License (see LICENSE)

More Repositories

1

k8s-oidc-helper

Helper tool for authenticating to Kubernetes using Google's OpenID Connect
Go
201
star
2

rabbitmq-compose

RabbitMQ running on docker
145
star
3

graylog-compose

Graylog running on docker
70
star
4

go-ftp

A simple ftp server written in go
Go
43
star
5

homelab

Homelab setup
Go
33
star
6

consul-demo

A demo for consul
Jupyter Notebook
31
star
7

logspout-gelf

Logspout Adapter for Graylog's GELF
Go
28
star
8

aws-iam-policy

AWS IAM policy in Go
Go
12
star
9

container-tx

container-transform in go
Go
11
star
10

loco

Docker Login Compressor
Go
7
star
11

reinvent23-con335

AWS re:Invent CON335: Securing Kubernetes Workloads in Amazon EKS
TypeScript
7
star
12

consul-uwsgi-healthcheck

A health check script for consul to PING/PONG a uwsgi server
Go
7
star
13

jwtdecode

CLI JWT Decoder
Go
6
star
14

reinforce-grc302

re:Inforce 2019 EKS Workshop
Shell
5
star
15

mesos-docker

Mesos running in Docker
Shell
4
star
16

docker-postgres-cert

A Dockerfile with a certificate generation script
Shell
3
star
17

route53-dynamic-dns

A simple DNS updater
Go
3
star
18

rpi-automation

RaspberryPi Automation
Shell
3
star
19

k8s-signal-logger

A tool for observing Kubernetes healthchecks and signals
Go
2
star
20

chadev-prometheus-demo

2
star
21

aws-monitor

AWS Cloudwatch Monitor script
Python
2
star
22

go-template

A template for new golang projects
Go
1
star
23

es-proxy

Go
1
star
24

python3-utils

A collection of useful python3 utilities
Python
1
star
25

lightning

Lightning Talks
Python
1
star
26

docker-zk-exhibitor

Exhibitor + Zookeeper in Docker
Shell
1
star
27

ssh2ec2

SSH to EC2 instances using tags and metadata to select the target instance
Python
1
star
28

django-app-upgrade-guide

A guide for upgrading 3rd party django apps from 1.6 to 1.7
1
star
29

avayafmt

Quick and dirty listener for Avaya's "unformatted" CDR report
Go
1
star
30

vagrant-demo

Demo Vagrant project
Shell
1
star
31

debate-word-cloud

A word cloud generator for presidential debates
1
star
32

youngprogrammer.ninja

Where young programming ninjas are born
Go
1
star
33

utmptail

Emit utmp files as JSON
Go
1
star
34

ipython-go-kernel

A play.golang.org kernel for IPython
Python
1
star
35

ipython_notebook_docker

ipython notebook running in docker
Shell
1
star
36

pycharm-coverage

Pycharm coverage demo
Python
1
star
37

httpsig-scratch

Scratch project for RFC9421 prototyping
Go
1
star
38

docker-saltminion

Dockerfile for bootstrapping a salt minion that runs in a docker container
Shell
1
star
39

consul-registration

A container for registering consul
Go
1
star