|
| 1 | +#Installing Micro bosh on a VM |
| 2 | + |
| 3 | +##<b>Prerequisites:-</b> |
| 4 | + |
| 5 | + <ol> |
| 6 | + <li>Install the OpenStack. Please |
| 7 | +<a href="https://github.com/rajdeepd/bosh-oss-docs/tree/master/bosh/documentation/install_openstack.md">Click here</a> to know how to install.</li> |
| 8 | +</ol> |
| 9 | + |
| 10 | +Create a VM using horizon and you should be able to SSH into that VM- this is also called inception VM. |
| 11 | + |
| 12 | + |
| 13 | +##Step 1: Create Inception VM |
| 14 | + |
| 15 | +1. Login to dashboard as admin. |
| 16 | +2. Select Project tab - > admin project. |
| 17 | +3. Click on Access & Security - > Click on Create Keypair button. |
| 18 | +4. Enter keypair name as “admin-keypair” and click on Create Keypair. |
| 19 | +5. Save the keypair to some location like: /home/<username>/openstack/admin-keypair.pem |
| 20 | +6. Copy the admin-keypair.pem to Inception VM. |
| 21 | + |
| 22 | + scp -i /root/.ssh/admin-keypair.pem /root/.ssh/admin-keypair.pem [email protected]:/home/ubuntu |
| 23 | + |
| 24 | +<b>Note:-</b> Remember the keypair location. we would use this pair many times later. |
| 25 | + |
| 26 | +##Step 2: Login to vm |
| 27 | + |
| 28 | + $ sudo su |
| 29 | + (Enter password and hit Enter) |
| 30 | + |
| 31 | +Check whether SSH Installed or not |
| 32 | + |
| 33 | + $ /etc/init.d/ssh status |
| 34 | + |
| 35 | +If not installed install SSH |
| 36 | + |
| 37 | + $ apt-get install ssh |
| 38 | + |
| 39 | +Create SSH Keys |
| 40 | + |
| 41 | + # ssh-keygen -t rsa |
| 42 | + |
| 43 | +Output |
| 44 | + |
| 45 | + Generating public/private rsa key pair. |
| 46 | + # Enter file in which to save the key (/home/you/.ssh/id_rsa): <Click Enter> |
| 47 | + # Enter passphrase (empty for no passphrase): <Click Enter> |
| 48 | + # Enter same passphrase again: <Click Enter> |
| 49 | + Your identification has been saved in /home/you/.ssh/id_rsa. |
| 50 | + Your public key has been saved in /home/you/.ssh/id_rsa.pub. |
| 51 | + The key fingerprint is: |
| 52 | + 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db |
| 53 | + |
| 54 | +Copy the admin-keypair to /root/.ssh |
| 55 | + |
| 56 | + # cp /home/<username>/openstack/admin-keypair.pem /root/.ssh/. |
| 57 | + |
| 58 | +Change permissions |
| 59 | + |
| 60 | + # chmod -R 600 /root/.ssh/. |
| 61 | + |
| 62 | +Login to vm |
| 63 | + |
| 64 | + # ssh -i /root/.ssh/admin-keypair.pem [email protected] |
| 65 | + |
| 66 | + root@inception-vm:/home/ubuntu/# |
| 67 | + |
| 68 | +<b>Note:-</b> 192.168.22.34 is the Inception VM ip address. |
| 69 | + |
| 70 | + |
| 71 | +##Step 3 : Install Ruby |
| 72 | + |
| 73 | + root@inception-vm:/home/ubuntu/# sudo su |
| 74 | + |
| 75 | +Install some core packages on Ubuntu that the BOSH deployer depends on. |
| 76 | + |
| 77 | + root@inception-vm:/home/ubuntu/# apt-get -y install build-essential libsqlite3-dev curl rsync git-core libmysqlclient-dev libxml2-dev libxslt-dev libpq-dev genisoimage |
| 78 | + |
| 79 | + root@inception-vm:/home/ubuntu/# \curl -L https://get.rvm.io | sudo bash -s stable |
| 80 | + |
| 81 | + root@inception-vm:/home/ubuntu/# source /etc/profile.d/rvm.sh |
| 82 | + |
| 83 | + root@inception-vm:/home/ubuntu/# rvm install 1.9.2-p280 |
| 84 | + |
| 85 | + root@inception-vm:/home/ubuntu/# rvm use 1.9.2 |
| 86 | + |
| 87 | + root@inception-vm:/home/ubuntu/# apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config |
| 88 | + |
| 89 | +Test RVM and Ruby |
| 90 | + |
| 91 | + root@inception-vm:/home/ubuntu/# rvm -v |
| 92 | + root@inception-vm:/home/ubuntu/# ruby -v |
| 93 | + |
| 94 | + Output:- It should show Ruby 1.9.2. |
| 95 | + |
| 96 | +##Step 4 : Install BOSH CLI |
| 97 | + |
| 98 | + root@inception-vm:/home/ubuntu/# gem install bosh_deployer --no-ri --no-rdoc |
| 99 | + |
| 100 | +##Step 5 : Create Custom Micro Bosh Stemcell |
| 101 | + |
| 102 | +Install the below dependencies before you run the below commands. |
| 103 | + root@inception-vm:/home/ubuntu/# apt-get install libpq-dev debootstrap kpartx qemu -y |
| 104 | + |
| 105 | +Download the BOSH release and build it |
| 106 | + |
| 107 | + root@inception-vm:/home/ubuntu/# mkdir -p releases |
| 108 | + root@inception-vm:/home/ubuntu/# cd releases |
| 109 | + root@inception-vm:/home/ubuntu/releases/# git clone git://github.com/frodenas/bosh-release.git |
| 110 | + root@inception-vm:/home/ubuntu/releases/# cd bosh-release |
| 111 | + root@inception-vm:/home/ubuntu/releases/bosh-release/# git submodule update --init |
| 112 | + |
| 113 | + |
| 114 | +<b>Build the BOSH release</b> |
| 115 | + |
| 116 | + |
| 117 | + root@inception-vm:/home/ubuntu/releases/bosh-release/# bosh create release --with-tarball |
| 118 | + |
| 119 | +If this is the first time you run bosh create release in the release repo, it will ask you to name the release, e.g. "bosh". |
| 120 | + |
| 121 | + Output will be like this: |
| 122 | + Release version: x.y-dev |
| 123 | + Release manifest: /home/ubuntu/releases/bosh-release/dev_releases/bosh-x.y-dev.yml |
| 124 | + Release tarball (95.2M): /home/ubuntu/releases/bosh-release/dev_releases/bosh-x.y-dev.tgz |
| 125 | + |
| 126 | +<b>Install BOSH Agent</b> |
| 127 | + |
| 128 | + root@inception-vm:/home/ubuntu/releases/# cd /home/ubuntu/ |
| 129 | + root@inception-vm:/home/ubuntu/# git clone git://github.com/frodenas/bosh.git |
| 130 | + root@inception-vm:/home/ubuntu/# cd bosh/agent/ |
| 131 | + root@inception-vm:/home/ubuntu/bosh/agent/# bundle install --without=development test |
| 132 | + |
| 133 | + root@inception-vm:/home/ubuntu/bosh/agent/# apt-get install libpq-dev |
| 134 | + |
| 135 | +<b>Install openstack registry</b> |
| 136 | + |
| 137 | + root@inception-vm:/home/ubuntu/# cd /home/ubuntu/bosh/openstack_registry |
| 138 | + root@inception-vm:/home/ubuntu/bosh/openstack_registry/# bundle install --without=development test |
| 139 | + root@inception-vm:/home/ubuntu/bosh/openstack_registry/# bundle exec rake install |
| 140 | + |
| 141 | +<b>Build Custom Stemcell</b> |
| 142 | + |
| 143 | + root@inception-vm:/home/ubuntu/bosh/openstack_registry/# cd /home/ubuntu/bosh/agent |
| 144 | + root@inception-vm:/home/ubuntu/bosh/agent/# rake stemcell2:micro["openstack",/home/ubuntu/releases/bosh-release/micro/openstack.yml,/home/ubuntu/releases/bosh-release/dev_releases/bosh-x.y-dev.tgz] |
| 145 | + |
| 146 | +<b>Note:-</b> Replace x.y with actual bosh version numbers. For example: bosh-0.6-dev.tgz |
| 147 | + |
| 148 | + |
| 149 | +<b>Output will be like this:</b> |
| 150 | + |
| 151 | + Generated stemcell: |
| 152 | + /var/tmp/bosh/agent-x.y.z-nnnnn/work/work/micro-bosh-stemcell-openstack-x.y.z.tgz |
| 153 | + |
| 154 | +<b>Copy the generated stemcell to a safe location</b> |
| 155 | + |
| 156 | + root@inception-vm:/home/ubuntu/bosh/agent/# cd /home/ubuntu/ |
| 157 | + root@inception-vm:/home/ubuntu/# mkdir -p stemcells |
| 158 | + root@inception-vm:/home/ubuntu/# cd stemcells |
| 159 | + root@inception-vm:/home/ubuntu/stemcells/# cp /var/tmp/bosh/agent-x.y.z-nnnnn/work/work/micro-bosh-stemcell-openstack-x.y.z.tgz . |
| 160 | + |
| 161 | + |
| 162 | +##Step 7 : Use Bosh CLI on Inception VM to deploy Micro Bosh stemcell to Glance This creates the Micro Bosh VM and it shows up in Horizon |
| 163 | + |
| 164 | + |
| 165 | + root@inception-vm:/home/ubuntu/# mkdir -p deployments/microbosh-openstack |
| 166 | + root@inception-vm:/home/ubuntu/# cd deployments/microbosh-openstack |
| 167 | + |
| 168 | +<b>Create Manifest File</b> |
| 169 | + |
| 170 | + root@inception-vm:/home/ubuntu/deployments/microbosh-openstack/# vim micro-bosh.yml |
| 171 | + |
| 172 | +Copy the below content and paste it in <b>micro-bosh.yml</b> |
| 173 | + |
| 174 | + |
| 175 | + name: microbosh-openstack |
| 176 | + |
| 177 | + env: |
| 178 | + bosh: |
| 179 | + password: $6$u/dxDdk4Z4Q3$MRHBPQRsU83i18FRB6CdLX0KdZtT2ZZV7BLXLFwa5tyVZbWp72v2wp.ytmY3KyBZzmdkPgx9D3j3oHaDZxe6F. |
| 180 | + |
| 181 | + |
| 182 | + level: DEBUG |
| 183 | + |
| 184 | + network: |
| 185 | + name: default |
| 186 | + type: dynamic |
| 187 | + label: private |
| 188 | + ip: 192.168.22.34 |
| 189 | + |
| 190 | + |
| 191 | + resources: |
| 192 | + persistent_disk: 4096 |
| 193 | + cloud_properties: |
| 194 | + instance_type: m1.small |
| 195 | + |
| 196 | + cloud: |
| 197 | + plugin: openstack |
| 198 | + properties: |
| 199 | + openstack: |
| 200 | + auth_url: http://10.0.0.2:5000/v2.0/tokens |
| 201 | + username: admin |
| 202 | + api_key: f00bar |
| 203 | + tenant: admin |
| 204 | + default_key_name: admin-keypair |
| 205 | + default_security_groups: ["default"] |
| 206 | + private_key: /root/.ssh/admin-keypair.pem |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | +<b>Note:-</b> |
| 211 | + |
| 212 | + 1. Replace Only the red colored values with actual ones. |
| 213 | + 2. Generate hashed password for f00bar |
| 214 | + 3. Replace the password with hashed password. |
| 215 | + |
| 216 | +---- |
| 217 | + |
| 218 | + root@inception-vm:/home/ubuntu/deployments/microbosh-openstack/# cd .. |
| 219 | + root@inception-vm:/home/ubuntu/deployments/# bosh micro deployment microbosh-openstack |
| 220 | + |
| 221 | +<b>Output will be:</b> |
| 222 | + |
| 223 | + $ WARNING! Your target has been changed to `http://microbosh-openstack:25555'! |
| 224 | + Deployment set to '/home/ubuntu/deployments/microbosh-openstack/micro_bosh.yml' |
| 225 | + |
| 226 | + |
| 227 | +<b>Deploy the deployment using the custom stemcell image</b> |
| 228 | + |
| 229 | + root@inception-vm:/home/ubuntu/deployments/# bosh micro deploy /home/ubuntu/stemcells/micro-bosh-stemcell-openstack-x.y.z.tgz |
| 230 | + |
| 231 | +<b>Output will be:</b> |
| 232 | + |
| 233 | + Deploying new micro BOSH instance `microbosh-openstack/micro_bosh.yml' to `http://microbosh-openstack:25555' (type 'yes' to continue): yes |
| 234 | + |
| 235 | + Verifying stemcell... |
| 236 | + File exists and readable OK |
| 237 | + Manifest not found in cache, verifying tarball... |
| 238 | + Extract tarball OK |
| 239 | + Manifest exists OK |
| 240 | + Stemcell image file OK |
| 241 | + Writing manifest to cache... |
| 242 | + Stemcell properties OK |
| 243 | + |
| 244 | + Stemcell info |
| 245 | + ------------- |
| 246 | + Name: micro-bosh-stemcell |
| 247 | + Version: 0.6.4 |
| 248 | + |
| 249 | + |
| 250 | + Deploy Micro BOSH |
| 251 | + unpacking stemcell (00:00:43) |
| 252 | + uploading stemcell (00:32:25) |
| 253 | + creating VM from 5aa08232-e53b-4efe-abee-385a7afb9421 (00:04:38) |
| 254 | + waiting for the agent (00:02:19) |
| 255 | + create disk (00:00:15) |
| 256 | + mount disk (00:00:07) |
| 257 | + stopping agent services (00:00:01) |
| 258 | + applying micro BOSH spec (00:01:20) |
| 259 | + starting agent services (00:00:00) |
| 260 | + waiting for the director (00:02:21) |
| 261 | + Done 11/11 00:44:30 |
| 262 | + WARNING! Your target has been changed to `http://192.168.22.34:25555'! |
| 263 | + Deployment set to '/home/ubuntu/deployments/microbosh-openstack/micro_bosh.yml' |
| 264 | + Deployed `microbosh-openstack/micro_bosh.yml' to `http://microbosh-openstack:25555', took 00:44:30 to complete |
| 265 | + |
| 266 | + |
| 267 | +<b>Now Test Bosh by connecting</b> |
| 268 | + |
| 269 | + root@inception-vm:/home/ubuntu/deployments/# bosh target http://192.168.22.34 |
| 270 | + |
| 271 | +<b>Output will be:</b> |
| 272 | + |
| 273 | + Target set to `microbosh-openstack (http://192.168.22.34:25555) Ver: 0.6 (release:ce0274ec bosh:0d9ac4d4)' |
| 274 | + Your username: admin |
| 275 | + Enter password: ***** |
| 276 | + Logged in as `admin' |
| 277 | + |
| 278 | +<b>Note:-</b> It will ask for the username and password, enter admin for both. |
0 commit comments