How to create and Run Instances on OpenStack

In this tutorial, How to create and Run Instances on OpenStack. In previous, My post has How to install OpenStack all in one Centos 7

How to add users in keystone who can use OpenStack System.

# add project
[root@DevopsRoles ~(keystone)]# openstack project create --domain default --description "Huupv Project" huupv 

# add user
[root@DevopsRoles ~(keystone)]# openstack user create --domain default --project huupv --password userpassword devopsroles 

# add role
[root@DevopsRoles ~(keystone)]# openstack role create CloudUser 

# add user to the role
[root@DevopsRoles ~(keystone)]# openstack role add --project huupv --user devopsroles CloudUser

# add flavor
[root@DevopsRoles ~(keystone)]# openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 10 m1.small 

Create and Start Virtual Machine Instance.

The username or password in the config as atop. Also, create and run an Instance.

[cent@DevopsRoles ~]$ vi ~/keystonerc

#The content as below
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=huupv
export OS_USERNAME=devopsroles
export OS_PASSWORD=userpassword
export OS_AUTH_URL=http://10.0.2.15:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export PS1='[\u@\h \W(keystone)]\$ '

[cent@DevopsRoles ~]$ chmod 600 ~/keystonerc 
[cent@DevopsRoles ~]$ source ~/keystonerc 
[cent@DevopsRoles ~(keystone)]$ echo "source ~/keystonerc " >> ~/.bash_profile
# show flavor list
[cent@DevopsRoles ~(keystone)]$ openstack flavor list 

# show image list
[cent@DevopsRoles ~(keystone)]$ openstack image list 


# show network list
[cent@DevopsRoles ~(keystone)]$ openstack network list 

# create a security group for instances
[cent@DevopsRoles ~(keystone)]$ openstack security group create secgroup01 

[cent@DevopsRoles ~(keystone)]$ openstack security group list 

# create a SSH keypair for connecting to instances
[cent@DevopsRoles ~(keystone)]$ ssh-keygen -q -N "" 

# add public-key
[cent@DevopsRoles ~(keystone)]$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey 

[cent@DevopsRoles ~(keystone)]$ openstack keypair list 

[cent@DevopsRoles ~(keystone)]$ netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }') 
# create and boot an instance
[cent@DevopsRoles ~(keystone)]$ openstack server create --flavor m1.small --image CentOS7 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS_7

# show status ([BUILD] status is shown when building instance)
[cent@DevopsRoles ~(keystone)]$ openstack server list 

# when starting noramlly, the status turns to [ACTIVE]
[cent@DevopsRoles ~(keystone)]$ openstack server list 

You Access to the URL via 10.0.2.15:6080

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.