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. JAVA 对象序列化(二)——Externalizable

    Java默认的序列化机制非常简单,而且序列化后的对象不需要再次调用构造器重新生成,但是在实际中,我们可以会希望对象的某一部分不需要被序列化,或者说一个对象被还原之后,其内部的某些子对象需要重新创建,从 ...

  2. delphi Image 处理

    procedure ResizeBmp(Src,Dst:String);var SrcBM,DstBM:TBitMap; Rect:TRect; NewW,NewH,PicW,PicH:Integer ...

  3. 阅读Linux内核源码时建立tags索引

    比如在阅读arm架构的Linux内核代码时想建立arm架构相关的索引,可以使用下面的命令: make ARCH=arm tags

  4. 使用jQuery和Bootstrap实现多层、自适应模态窗口

    本篇实践一个多层模态窗口,而且是自适应的. 点击页面上的一个按钮,弹出第一层自适应模态窗口. 在第一层模态窗口内包含一个按钮,点击该按钮弹出第二层模态窗口,弹出的第二层模态窗口会挡住第一层模态窗口,即 ...

  5. 一个最简单的Delphi2010的PNG异形窗口方法

    同事演示了一个.NET的的PNG异形窗口.挺漂亮.于是也想用Delphi显摆一个. 关于Delphi用PNG做异形窗口的资料有不少.都是用GDIPlus或者TPNGImage组件加载PNG图像做的.但 ...

  6. FreeCommander 学习手册

    概述 转载请注明出处:http://www.cnblogs.com/skywang12345/p/3470728.html FreeCommander(下文简称FC),是Windows下面比较强大的文 ...

  7. 跟踪EBS客户端的IP地址

    Meterlink参考文档: How to Track IP Address of the Form Session in Oracle application 11i (文档 ID 878931.1 ...

  8. 数位dp(求1-n中数字1出现的个数)

    题意:求1-n的n个数字中1出现的个数. 解法:数位dp,dp[pre][now][equa] 记录着第pre位为now,equa表示前边是否有降数字(即后边可不能够任意取,true为没降,true为 ...

  9. 使用 STHTTPRequest 框架解析 Soap1.2 教程

    1.STHTTPRequest框架地址 https://github.com/nst/STHTTPRequest 将 STHTTPRequest .h  STHTTPRequest.m 文件拖入工程中 ...

  10. 哥谭第四季/全集Gotham迅雷下载

    <哥谭>(Gotham)第三季刚刚结束,第四季首集的集名就公布了.<Pax Penguina>这个集名在拉丁语中意味着「Pax Romana」,也就是「罗马式的和平」(Roma ...