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. High accuracy voltage regulator

    High accuracy voltage regulator Good morning everybody, I want to make a accurate voltage regulator ...

  2. sqlserver 2012 查询时提示“目录名称无效”

    重装系统或者用360等软件清理了相应的临时文件导致解决:在运行中输入 %temp% 回车,会跳出找不到路径的提示,然后到提示的目录建没有找到的目录文件夹即可.

  3. mysql函数的使用

    最近总感觉sql语句不对劲,所以就看了一些官方文档发现了一些以前没有注意的函数:感觉在查询的时候可以用得上,毕竟是内置函数,用起来效率应该会好一些的: FIND_IN_SET(str,strlist) ...

  4. FTP服务器原理(转)

    本文转自https://www.cnblogs.com/Aiapple/p/5955736.html 感谢作者   21.1 FTP服务器原理   使用明码传输方式,且有相当多的安全危机历史.因此一般 ...

  5. 用开源项目RangBar来实现有范围的SeekBar

    RangeBar是一个可以有选择范围的Seekbar,用这个项目其实是很简单的.就是一个自定义控件~ 一.布局文件 这里可以看到有很多属性可以定制,除了通过xml来定义也可以再java代码中进行定义. ...

  6. Java Callable接口、Runable接口、Future接口

    1. Callable与Runable区别 Java从发布的第一个版本开始就可以很方便地编写多线程的应用程序,并在设计中引入异步处理.Thread类.Runnable接口和Java内存管理模型使得多线 ...

  7. JAVAWEB开发之HttpServletResponse和HttpServletRequest详解(下)(各种乱码、验证码、重定向和转发)

    HttpServletRequest获取请求头信息  (1)获取客户机请求头 String getHeader(String name) Enumeration<String> getHe ...

  8. System.Reflection.TargetException:“非静态方法需要一个目标。”

    报错:TargetException, 非静态方法需要一个目标,非静态方法 如果实例为null,调用实例方法会报如上错. 解决办法: 检查实例是否为null,考虑什么情况下实例为null,然后排除实例 ...

  9. 数学图形(1.48)Cranioid curve头颅线

    这是一种形似乎头颅的曲线.这种曲线让我想起读研的时候,搞的医学图像三维可视化.那时的原始数据为脑部CT图像.而三维重建中有一种方式是面绘制,是将每一幅CT的颅骨轮廓提取出来,然后一层层地罗列在一起,生 ...

  10. 析构函数 (C++)

    最近发现自己对析构函数的认知有一定的问题,因为之前有在使用placement new时主动调用对象的析构函数,所以觉得析构函数只是个普通的成员函数,调用的时候只会执行自己方法体内的代码内容,而回收内存 ...