Docker 容器编排

编排工具

Docker Swarm

Kubernetes

部署成本

 

功能集合

 

编排能力

 

可用性

Talk is cheap, show you code ?

version: '3'
services: 
  cnode:
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    #   args:
    #     - env=value
    image: cnode/egg-cnode:latest
    environment:
      - NODE_ENV=production
      - EGG_SERVER_ENV=prod
      - EGG_REDIS_DB=0
      - EGG_REDIS_HOST=redis
      - EGG_REDIS_PORT=6379
      - EGG_REDIS_PASSWORD=egg_cnode
      - EGG_MONGODB_URL=mongodb://egg_cnode:egg_cnode@mongodb:27017/egg_cnode
      - EGG_MINI_ASSETS=true
      - EGG_PASSPORT_GITHUB_CLIENT_ID=test
      - EGG_PASSPORT_GITHUB_CLIENT_SECRET=test
      # - EGG_SITE_STATIC_HOST=${EGG_SITE_STATIC_HOST}
      - EGG_ALINODE_APPID=appid
      - EGG_ALINODE_SECRET=secret
    depends_on:
      - redis
      - mongodb
    networks:
      - docker_cnode
    ports:
      - 7001:7001

  redis:
    image: redis:3.2-alpine
    command: redis-server --appendonly yes --requirepass egg_cnode
    volumes:
      - egg-redis:/data
    networks:
      - docker_cnode
    # ports:
    #   - 6379:6379

  mongodb:
    image: mongo:3.2
    restart: always
    environment:      
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=mongodb
      - MONGO_INITDB_DATABASE=egg_cnode
    volumes:
      - egg-mongo:/data/db
      - ./init.d/mongo:/docker-entrypoint-initdb.d
    networks:
      - docker_cnode
    # ports:
    #   - 27017:27017

volumes:
  egg-mongo:
  egg-redis:

networks:
  docker_cnode:
    driver: bridge    
apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert -f cnode.yml
    kompose.version: 1.13.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: cnode
  name: cnode
spec:
  ports:
  - name: "7001"
    port: 7001
    targetPort: 7001
  selector:
    io.kompose.service: cnode
status:
  loadBalancer: {}

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f cnode.yml
    kompose.version: 1.13.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: cnode
  name: cnode
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: cnode
    spec:
      containers:
      - env:
        - name: EGG_ALINODE_APPID
          value: appid
        - name: EGG_ALINODE_SECRET
          value: secret
        - name: EGG_MINI_ASSETS
          value: "true"
        - name: EGG_MONGODB_URL
          value: mongodb://egg_cnode:egg_cnode@mongodb:27017/egg_cnode
        - name: EGG_PASSPORT_GITHUB_CLIENT_ID
          value: test
        - name: EGG_PASSPORT_GITHUB_CLIENT_SECRET
          value: test
        - name: EGG_REDIS_DB
          value: "0"
        - name: EGG_REDIS_HOST
          value: redis
        - name: EGG_REDIS_PASSWORD
          value: egg_cnode
        - name: EGG_REDIS_PORT
          value: "6379"
        - name: EGG_SERVER_ENV
          value: prod
        - name: NODE_ENV
          value: production
        image: cnode/egg-cnode:latest
        name: cnode
        ports:
        - containerPort: 7001
        resources: {}
      restartPolicy: Always
status: {}

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f cnode.yml
    kompose.version: 1.13.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: mongodb
  name: mongodb
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: mongodb
    spec:
      containers:
      - env:
        - name: MONGO_INITDB_DATABASE
          value: egg_cnode
        - name: MONGO_INITDB_ROOT_PASSWORD
          value: mongodb
        - name: MONGO_INITDB_ROOT_USERNAME
          value: root
        image: mongo:3.2
        name: mongodb
        resources: {}
        volumeMounts:
        - mountPath: /data/db
          name: egg-mongo
        - mountPath: /docker-entrypoint-initdb.d
          name: mongodb-claim1
      restartPolicy: Always
      volumes:
      - name: egg-mongo
        persistentVolumeClaim:
          claimName: egg-mongo
      - name: mongodb-claim1
        persistentVolumeClaim:
          claimName: mongodb-claim1
status: {}

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f cnode.yml
    kompose.version: 1.13.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: redis
  name: redis
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: redis
    spec:
      containers:
      - args:
        - redis-server
        - --appendonly
        - "yes"
        - --requirepass
        - egg_cnode
        image: redis:3.2-alpine
        name: redis
        resources: {}
        volumeMounts:
        - mountPath: /data
          name: egg-redis
      restartPolicy: Always
      volumes:
      - name: egg-redis
        persistentVolumeClaim:
          claimName: egg-redis
status: {}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: egg-redis
  name: egg-redis
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: egg-mongo
  name: egg-mongo
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}

Thanks

Docker 容器编排

By Thonatos.Yang

Docker 容器编排

  • 1,316