Guest User

Untitled

a guest
Nov 3rd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 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. ```bash
  62. $ kubectl create -f local-pv.yml
  63. persistentvolume "pv0001" created
  64. ```
  65.  
  66. Deploy application
  67. ```bash
  68. $ kompose --opencompose services.yml up
  69. We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application.
  70. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
  71.  
  72. INFO[0000] Successfully created service: frontend
  73. INFO[0000] Successfully created service: backend
  74. INFO[0000] Successfully created service: mongodb
  75. INFO[0000] Successfully created persistentVolumeClaim: db-store
  76. INFO[0000] Successfully created deployment: frontend
  77. INFO[0000] Successfully created deployment: backend
  78. INFO[0000] Successfully created deployment: mongodb
  79.  
  80. Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
  81. ```
  82.  
  83. All `deployments` are created and in desired state
  84.  
  85. ```bash
  86. $ kubectl get deployments
  87. NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
  88. backend 1 1 1 1 2m
  89. frontend 1 1 1 1 2m
  90. mongodb 1 1 1 1 2m
  91. ```
  92.  
  93. All `services` have been created
  94. ```bash
  95. $ kubectl get svc
  96. NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  97. backend 10.0.0.247 <none> 3000/TCP 2m
  98. frontend 10.0.0.217 <pending> 8080/TCP 2m
  99. kubernetes 10.0.0.1 <none> 443/TCP 15d
  100. mongodb 10.0.0.166 <none> 27017/TCP 2m
  101. ```
  102.  
  103. All `pods` are running as well
  104.  
  105. ```bash
  106. $ kubectl get pods -o wide
  107. NAME READY STATUS RESTARTS AGE IP NODE
  108. backend-1215184120-hfji7 1/1 Running 0 3m 172.17.0.4 minikube
  109. frontend-2479999252-tpzff 1/1 Running 0 3m 172.17.0.5 minikube
  110. mongodb-254926443-c1rba 1/1 Running 0 3m 172.17.0.3 minikube
  111. ```
Add Comment
Please, Sign In to add comment