Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. The `services.yml` file
  2.  
  3. ```yaml
  4. $ cat services.yml
  5. version: "0.2"
  6.  
  7. services:
  8. frontend:
  9. image: docker.io/surajd/frontend:v1
  10. ports:
  11. - 8080:8080
  12. type: external
  13.  
  14. backend:
  15. image: docker.io/surajd/backend:v1
  16. ports:
  17. - 3000:3000
  18. environment:
  19. MONGODB_PASSWORD: pass
  20. MONGODB_USER: user
  21. MONGODB_DATABASE: db
  22. MONGODB_SERVER: mongodb:27017
  23.  
  24. mongodb:
  25. image: tomaskral/mongodb-centos7
  26. ports:
  27. - 27017:27017
  28. volumes:
  29. - db-store:/var/lib/mongodb/data
  30. environment:
  31. MONGODB_PASSWORD: pass
  32. MONGODB_USER: user
  33. MONGODB_DATABASE: db
  34. MONGODB_ADMIN_PASSWORD: root
  35.  
  36. volumes:
  37. db-store:
  38. size: "2Gi"
  39. mode: ReadWriteOnce
  40. ```
  41.  
  42. `pv` definition to be used for this example
  43.  
  44. ```yaml
  45. $ cat local-pv.yml
  46. apiVersion: "v1"
  47. kind: "PersistentVolume"
  48. metadata:
  49. name: "pv0001"
  50. spec:
  51. capacity:
  52. storage: "5Gi"
  53. accessModes:
  54. - "ReadWriteOnce"
  55. persistentVolumeReclaimPolicy: Recycle
  56. hostPath:
  57. path: /tmp/pv0001
  58. ```
  59.  
  60. Create a `pv`
  61.  
  62. ```bash
  63. $ kubectl create -f local-pv.yml
  64. persistentvolume "pv0001" created
  65. ```
  66.  
  67. Deploy application
  68.  
  69. ```bash
  70. $ kompose --opencompose services.yml up
  71. We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application.
  72. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
  73.  
  74. INFO[0000] Successfully created service: frontend
  75. INFO[0000] Successfully created service: backend
  76. INFO[0000] Successfully created service: mongodb
  77. INFO[0000] Successfully created persistentVolumeClaim: db-store
  78. INFO[0000] Successfully created deployment: frontend
  79. INFO[0000] Successfully created deployment: backend
  80. INFO[0000] Successfully created deployment: mongodb
  81.  
  82. Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
  83. ```
  84.  
  85. Undeploy the application
  86.  
  87. ```bash
  88. $ kompose --opencompose services.yml down
  89. INFO[0000] Successfully deleted service: frontend
  90. INFO[0000] Successfully deleted service: backend
  91. INFO[0000] Successfully deleted service: mongodb
  92. INFO[0000] Successfully deleted PersistentVolumeClaim: db-store
  93. INFO[0003] Successfully deleted deployment: frontend
  94. INFO[0006] Successfully deleted deployment: backend
  95. INFO[0009] Successfully deleted deployment: mongodb
  96. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement