kompose is a tool to help users who are familiar with docker-compose move to Kubernetes. kompose takes a Docker Compose file and translates it into Kubernetes resources.

kompose is a convenience tool to go from local Docker development to managing your application with Kubernetes. Transformation of the Docker Compose format to Kubernetes resources manifest may not be exact, but it helps tremendously when first deploying an application on Kubernetes.

Install:

curl -L https://github.com/kubernetes/kompose/releases/download/v1.18.0/kompose-darwin-amd64 -o kompose

chmod +x kompose
sudo mv ./kompose /usr/local/bin/kompose

We have a Docker compose file which setup Node, Nginx, Redis, MongoDB.

    # 1. Update config values (localhost --> mongo and localhost --> redis) in config/config.development.json if necessary.
# 2. Set APP_ENV environment variable by running the following command in your commnand window (see the notes below if on Windows). # export APP_ENV=development or export APP_ENV=production
# export DOCKER_ACCT=codewithdan # NOTE: If you're on Windows use one of the following commands to create the environment variables.
# Use 'codewithdan' for the account if you want to run in Kubernetes (see the readme). Otherwise, you can substitute your own
# Docker account for the value if you'd like. # For the standard Windows DOS command shell use `set` instead of `export` for environment variables.
# For Windows Powershell use $env:APP_ENV = "value". # 3. Remove "node" service volume (below) if doing a production build
# 4. Run docker-compose build
# 5. Run docker-compose up
# 6. Live long and prosper version: "3.1" services:
nginx:
container_name: nginx
image: ${DOCKER_ACCT}/nginx
build:
context: .
dockerfile: .docker/nginx.${APP_ENV}.dockerfile
# links are deprecated (networks are used instead for communication and
# depends_on for upstream node name in nginx config)
# links:
# - node1:node1
# - node2:node2
# - node3:node3
depends_on:
- node
ports:
- "80:80"
- "443:443"
networks:
- codewithdan-network node:
container_name: node-codewithdan
image: ${DOCKER_ACCT}/node-codewithdan
build:
context: .
dockerfile: .docker/node-codewithdan.${APP_ENV}.dockerfile
ports:
- "8080"
volumes:
- .:/var/www/codewithdan
working_dir: /var/www/codewithdan
env_file:
- ./.docker/env/app.${APP_ENV}.env
depends_on:
- mongo
- redis
networks:
- codewithdan-network # Removing these for those wanting to run Kubernetes as well (since replica sets would scale pods with containers)
# node2:
# container_name: node-codewithdan-2
# image: ${DOCKER_ACCT}/node-codewithdan
# build:
# context: .
# dockerfile: .docker/node-codewithdan.${APP_ENV}.dockerfile
# ports:
# - "8080"
# volumes:
# - .:/var/www/codewithdan
# working_dir: /var/www/codewithdan
# env_file:
# - ./.docker/env/app.${APP_ENV}.env
# depends_on:
# - mongo
# - redis
# networks:
# - codewithdan-network # node3:
# container_name: node-codewithdan-3
# image: ${DOCKER_ACCT}/node-codewithdan
# build:
# context: .
# dockerfile: .docker/node-codewithdan.${APP_ENV}.dockerfile
# ports:
# - "8080"
# volumes:
# - .:/var/www/codewithdan
# working_dir: /var/www/codewithdan
# env_file:
# - ./.docker/env/app.${APP_ENV}.env
# depends_on:
# - mongo
# - redis
# networks:
# - codewithdan-network mongo:
container_name: mongo
image: ${DOCKER_ACCT}/mongo
build:
context: .
dockerfile: .docker/mongo.dockerfile
ports:
- "27017:27017"
env_file:
- ./.docker/env/mongo.${APP_ENV}.env
networks:
- codewithdan-network redis:
container_name: redis
image: ${DOCKER_ACCT}/redis
build:
context: .
dockerfile: .docker/redis.${APP_ENV}.dockerfile
ports:
- "6379"
networks:
- codewithdan-network # cadvisor:
# container_name: cadvisor
# image: google/cadvisor
# volumes:
# - /:/rootfs:ro
# - /var/run:/var/run:rw
# - /sys:/sys:ro
# - /var/lib/docker/:/var/lib/docker:ro
# ports:
# - "8080:8080"
# networks:
# - codewithdan-network networks:
codewithdan-network:
driver: bridge

Run:

export APP_ENV=development
// or export APP_ENV=production export DOCKER_ACCT=codewithdan

Then, we can convert Docker compose file to Kubernetes files:

kompose conver // create multi yml files for each services
// or output only one file
kompose conver --out test.yml

[Docker] Converting from Docker Compose to Kubernetes的更多相关文章

  1. Docker 管理工具的选择:Kubernetes 还是 Swarm?

    [编者的话]选择Kubernetes 或者 Swarm 就像在将 Linux 桌面发行版的范围缩小到两个后选出一个最喜欢的.哪个更满足你的需要如何才是决定因素. [3 天烧脑式基于Docker的CI/ ...

  2. docker、oci、runc以及kubernetes梳理

    容器无疑是近年来云计算中最火热的关键词.随着docker的大热,docker.oci.runc.containerd等等名词也逐渐传播开来.这么多的名词,也容易让人混淆.本文对相关名词和其之间的联系进 ...

  3. Docker(四):Docker 三剑客之 Docker Compose

    前两篇文章我们介绍了 Dockerfile 的使用Docker(二):Dockerfile 使用介绍,我们知道使用一个 Dockerfile 模板文件可以定义一个单独的应用容器,如果需要定义多个容器就 ...

  4. Docker 核心技术之Docker Compose

    Docker Compose 简介 Docker Compose是什么? Docker Compose是一个能一次性定义和管理多个Docker容器的工具. 详细地说: Compose中定义和启动的每一 ...

  5. Docker三剑客之Docker Compose

    一.什么是Docker Compose Compose 项目是Docker官方的开源项目,负责实现Docker容器集群的快速编排,开源代码在https://github.com/docker/comp ...

  6. AspNetCore容器化(Docker)部署(三) —— Docker Compose容器编排

    一.前言 上一篇部署了一个最基础的helloworld应用,创建了两个容器和一个network,还算应付得过来. 如果该应用继续引入mysql.redis.job等若干服务,到时候发布一次得工作量之大 ...

  7. Docker深入浅出系列 | Docker Compose多容器实战

    目录 前期准备 Docker Compose是什么 为什么要用Docker Compose Docker Compose使用场景 Docker Compose安装 Compose Yaml文件结构 C ...

  8. 【云计算】Docker云平台—Docker进阶

    Docker云平台系列共三讲,此为第二讲:Docker进阶 参考资料: 五个Docker监控工具的对比:http://www.open-open.com/lib/view/open1433897177 ...

  9. Docker(六):Docker 三剑客之 Docker Swarm

    实践中会发现,生产环境中使用单个 Docker 节点是远远不够的,搭建 Docker 集群势在必行.然而,面对 Kubernetes, Mesos 以及 Swarm 等众多容器集群系统,我们该如何选择 ...

随机推荐

  1. btrace-dtrace-for-java-ish

    http://dtrace.org/blogs/ahl/2012/04/24/btrace-dtrace-for-java-ish/

  2. JavaScript 实例 | w3cschool菜鸟教程

    JavaScript 实例 | w3cschool菜鸟教程 http://www.w3cschool.cc/js/js-examples.html

  3. 用delphi实现完美屏幕截图

    可以截取layered窗口(包括透明窗口)的代码: procedure CaptureScreen(AFileName: string);const  CAPTUREBLT = $40000000;v ...

  4. SpringBoot配置多数据源

    原文:https://www.jianshu.com/p/033e0ebeb617 项目中用到了两个数据库,分别是Oracle和Mysql,涉及到了多数据源问题,这里做下记录 官方讲解:https:/ ...

  5. Android按键添加和处理的方案

    Android按键添加和处理的方案  版本号 说明 作者 日期  1.0  Android按键添加和处理的方案 Sky Wang  2013/06/18        需求:Android机器上有个W ...

  6. rtorrent - 强大的命令行BT客户端

    NOTE - 文中展示的所有示例和指令都已经在Ubuntu 13.04中测试过. 一.            安装 [root@GY-10000 data]# yum search rtorrent ...

  7. 字符串类型的变量,也要进行alloc内存分配之后才能用

    nss_upperName =[[NSStringalloc]initWithString:labTopTitle.text]; nss_upperName =labTopTitle.text; // ...

  8. Android应用icon和闪屏splash的尺寸

    icon (尺寸为px) 目录 尺寸 (width * height) drawable 72 x 72 drawable-hdpi 72 x 72 drawable-ldpi 36 x 36 dra ...

  9. mac下设置eclipse自动提示

    偏好设置  -> General -> Editors -> File Associations .xml ->  设置XML Editor为default Keys 中查找 ...

  10. Java命令学习系列(六)——jinfo

    jinfo可以输出java进程.core文件或远程debug服务器的配置信息.这些配置信息包括JAVA系统参数及命令行参数,如果进程运行在64位虚拟机上,需要指明-J-d64参数,如:jinfo -J ...