Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The `services.yml` file
- ```yaml
- $ cat services.yml
- version: "0.2"
- services:
- frontend:
- image: docker.io/surajd/frontend:v1
- ports:
- - 8080:8080
- type: external
- backend:
- image: docker.io/surajd/backend:v1
- ports:
- - 3000:3000
- environment:
- MONGODB_PASSWORD: pass
- MONGODB_USER: user
- MONGODB_DATABASE: db
- MONGODB_SERVER: mongodb:27017
- mongodb:
- image: tomaskral/mongodb-centos7
- ports:
- - 27017:27017
- volumes:
- - db-store:/var/lib/mongodb/data
- environment:
- MONGODB_PASSWORD: pass
- MONGODB_USER: user
- MONGODB_DATABASE: db
- MONGODB_ADMIN_PASSWORD: root
- volumes:
- db-store:
- size: "2Gi"
- mode: ReadWriteOnce
- ```
- `pv` definition to be used for this example
- ```yaml
- $ cat local-pv.yml
- apiVersion: "v1"
- kind: "PersistentVolume"
- metadata:
- name: "pv0001"
- spec:
- capacity:
- storage: "5Gi"
- accessModes:
- - "ReadWriteOnce"
- persistentVolumeReclaimPolicy: Recycle
- hostPath:
- path: /tmp/pv0001
- ```
- Create a `pv`
- ```bash
- $ kubectl create -f local-pv.yml
- persistentvolume "pv0001" created
- ```
- Deploy application
- ```bash
- $ kompose --opencompose services.yml up
- We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application.
- If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
- INFO[0000] Successfully created service: frontend
- INFO[0000] Successfully created service: backend
- INFO[0000] Successfully created service: mongodb
- INFO[0000] Successfully created persistentVolumeClaim: db-store
- INFO[0000] Successfully created deployment: frontend
- INFO[0000] Successfully created deployment: backend
- INFO[0000] Successfully created deployment: mongodb
- Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
- ```
- All `deployments` are created and in desired state
- ```bash
- $ kubectl get deployments
- NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
- backend 1 1 1 1 2m
- frontend 1 1 1 1 2m
- mongodb 1 1 1 1 2m
- ```
- All `services` have been created
- ```bash
- $ kubectl get svc
- NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
- backend 10.0.0.247 <none> 3000/TCP 2m
- frontend 10.0.0.217 <pending> 8080/TCP 2m
- kubernetes 10.0.0.1 <none> 443/TCP 15d
- mongodb 10.0.0.166 <none> 27017/TCP 2m
- ```
- All `pods` are running as well
- ```bash
- $ kubectl get pods -o wide
- NAME READY STATUS RESTARTS AGE IP NODE
- backend-1215184120-hfji7 1/1 Running 0 3m 172.17.0.4 minikube
- frontend-2479999252-tpzff 1/1 Running 0 3m 172.17.0.5 minikube
- mongodb-254926443-c1rba 1/1 Running 0 3m 172.17.0.3 minikube
- ```
Add Comment
Please, Sign In to add comment