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

最新文章

  1. 一个简单的servlet的demo
  2. CabArc to create or extract a cab file
  3. 如何写BaseDomain
  4. [CareerCup] 10.7 Simplified Search Engine 简单的搜索引擎
  5. 一小时学会Markdown写作
  6. Android中GC_EXTERNAL_ALLOC的含义
  7. (Android)View.getHeight或getWidth为0时的一些解决方案
  8. Excel教程(8) - 财务函数
  9. 把Wordpress集成到zen-cart里方法 各种修改 经典机制
  10. JAVA_Lock
  11. 手写token解析器、语法解析器、LLVM IR生成器(GO语言)
  12. Eclipse切换工作空间(Workspace)
  13. CF939D Love Rescue 并查集
  14. Hibernate c3p0的整合
  15. 2016.5.24——Intersection of Two Linked Lists
  16. python中 .write 无法向文件写入内容
  17. BIEE多层表头报表的制作方法
  18. Python 求“元组、列表、字典、数组和矩阵”的大小
  19. LSTM java 实现
  20. TCP_DB_中间件_数据打包格式

热门文章

  1. What is OpenOCD?
  2. mysql exists 如何使用
  3. Spring Boot 2中对于CORS跨域访问的快速支持
  4. UINavigationController 、UINavigationBar 、UINavigationItem 超清晰直观详解(扩展)
  5. C#编程(二十五)----------接口
  6. 【Devops】【Jenkins】Jenkins插件安装失败处理方法
  7. SharePoint JavaScript API in application pages
  8. 毒枭第一季/全集Narcos迅雷下载
  9. Android之设备唯一识别
  10. TabHost的初步使用