When you first spin up VMs in an Openstack + Contrail environment you don’t have many choices on how to access your VM. You can go through the Openstack Webui to access via the console.
But that method is not ideal as you cannot do things such as copy and paste.
Another method is to access the VM from the Contrail compute node. All VMs are stored on the compute node of the Contrail cluster.
Or you can inject an ssh-key into your VM so you can access the VM from the compute node.
First you create your ssh-key.
Select the Access and Security tab in Openstack.
Choose Keypairs
You will then be able to download the "key" to your local computer. You will need to copy this key onto the Compute node.
MyComputer$ scp ssh-key.pem root@172.16.100.104:~/.ssh
I chose to place this key in the .ssh directory of the Compute node.
Compute-Node:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub known_hosts ssh-key.pem
Next you create your VM.
You can see if your ssh-key was injected from the horizon dashboard.
Note: One of the problems I see in Horizon is the inability of injecting the ssh-key after the VM was created. There is no was to edit and do this post-creation. Pretty annoying especially if there are many ssh-keys and you forget to choose the correct one.
Next go back to your compute node.
Issue the netstat -rn command.
When a VM is created the Compute node generates a 169.254.x.x link local address. It's similar to a loopback address and is only accessible on the local machine and cannot be accessed over the network.
Compute-Node$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 172.16.100.1 0.0.0.0 UG 0 0 0 vhost0
169.254.0.3 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.4 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.6 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.7 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.8 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
169.254.0.9 0.0.0.0 255.255.255.255 UH 0 0 0 vhost0
172.16.100.0 0.0.0.0 255.255.255.0 U 0 0 0 vhost0
Then you can ssh into the vm of your choice with -i parameter and path-to/ssh-key. For example:
Compute-Node$ssh -i ~/.ssh/ssh-key.pem cirros@169.254.0.3
Cirros-VM1$ whoami
cirros
You can see the ssh-key authorized hosts file in the .ssh directory of the VM
$ more authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCe9TjQfiVTiidtt2qUICwK/7DArACsjLWDkx7Esvu6vWS8MahyrlgNkeQtaFDx7wub5LaHesqq6wj2pKDX07RWxylAkxShqy2+ZIoOgJqMBr0vfq4xpp2qU7fPiAq4YV3CdqTwOggnNHQNeGgpM6406IJSJcVYJVqTC3/3SsFgxzva4UqNgA3mjRQxSsmVxc6jVHVKfAYQ8+fDFNniNjY+q9qvihtAXwmLGfv/gxE/N01aMC+MH1b5cmj2o7WNpbt5qGDyrf3jB6rqz5CI95XS0MjvaScTWKb5ul0yuWTkp1zcPY4vzDaFjc0Fl7627Lm2IuQZg76dgKl3rnnPtXbv Generated by Nova
No comments:
Post a Comment