bootstrap.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env bash
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. # Bootstraps a CEPH server.
  17. # It creates two OSDs on local machine, creates RBD pool there
  18. # and imports 'block' device there.
  19. #
  20. # We must create fresh OSDs and filesystem here, because shipping it
  21. # in a container would increase the image by ~300MB.
  22. #
  23. # Create /etc/ceph/ceph.conf
  24. sh ./ceph.conf.sh "$(hostname -i)"
  25. # Configure and start ceph-mon
  26. sh ./mon.sh "$(hostname -i)"
  27. # Configure and start 2x ceph-osd
  28. mkdir -p /var/lib/ceph/osd/ceph-0 /var/lib/ceph/osd/ceph-1
  29. sh ./osd.sh 0
  30. sh ./osd.sh 1
  31. # Configure and start cephfs metadata server
  32. sh ./mds.sh
  33. # Prepare a RBD volume "foo" (only with layering feature, the others may
  34. # require newer clients).
  35. # NOTE: we need Ceph kernel modules on the host that runs the client!
  36. rbd import --image-feature layering block foo
  37. # Prepare a cephfs volume
  38. ceph osd pool create cephfs_data 4
  39. ceph osd pool create cephfs_metadata 4
  40. ceph fs new cephfs cephfs_metadata cephfs_data
  41. # Put index.html into the volume
  42. # It takes a while until the volume created above is mountable,
  43. # 1 second is usually enough, but try indefinetily.
  44. sleep 1
  45. while ! ceph-fuse -m "$(hostname -i):6789" /mnt; do
  46. echo "Waiting for cephfs to be up"
  47. sleep 1
  48. done
  49. echo "Hello Ceph!" > /mnt/index.html
  50. chmod 644 /mnt/index.html
  51. umount /mnt
  52. echo "Ceph is ready"
  53. # Wait forever
  54. while true; do
  55. sleep 10
  56. done