Auto Deployment with Docker Image (2)

Setup QA Deployment and Service

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: XXX
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app:XXX
    spec:
      containers:
      - image: mongo
        name: XXX
        ports:
        - name: mongo
          containerPort: 27017
          hostPort: 27017
        volumeMounts:
            - name: mongo-persistent-storage
              mountPath: /data/db
      volumes:
        - name: mongo-persistent-storage
          gcePersistentDisk:
            pdName: XXX
            fsType: ext4

#db-service.yml
apiVersion: v1
kind: Service
metadata:
  labels:
    name: XXX
  name: XXX
spec:
  ports:
    - port: 27017
      targetPort: 27017
  selector:
    name: XXX

# web-deployment.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: XXX-deployment
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: XXX
    spec:
      containers:
      - image: gcr.io/XXX/XXX
        name: XXX
        ports:
        - containerPort: 8080
          name: http-server
# web-service.yml
apiVersion: v1
kind: Service
metadata:
  name: XXX
  labels:
    name: XXXX
spec:
  type: LoadBalancer
  loadBalancerIP: XXX
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
  selector:
    app: XXX

Setup the persistent storage

Tips: if the cluster only have one node and the performace is not good enough, there may be a issue about “failed to fit in any node fit failure on node “

Leave a Reply

Your email address will not be published. Required fields are marked *