Welcome to the OpenStack Terraform Configuration project! This guide will help you set up a basic cloud infrastructure using Terraform and OpenStack, on ServerCore cloud.
This project uses Terraform to automatically set up cloud resources using OpenStack provider.
Here's what it creates:
- A virtual machine (we call this a "compute instance")
- A hard drive for the virtual machine (block storage)
- A private network for your resources
- A way for your virtual machine to connect to the internet
- Security settings to keep your virtual machine safe
- frontend: Has the react application
- /.github/workflows: Contains scripts for CI/CD integration and other automation tasks.
- /Docs: Folder contains a solutions architect document with more detailed documentation on ServerCore and openstack.
- main.tf: Main file for infrastructure provisioning- provisioners.tf: provisioning.
You'll need a few things set up on your computer:
- Terraform: This is the tool we use to create our cloud resources. Download and install Terraform (version 0.12.x or later).
- ServerCore: You need an account with ServerCore cloud provider https://my.servercore.com/login.
- openstack: You need to install openstack cli on your local machine.
First, we need to get your OpenStack credentials. These are like a special key that lets Terraform talk to your SrrverCore account.
To get your credentials from ServerCore:
- Log in to your ServerCore dashboard.
- Look for a section called "Access".
- Download the RC file (it should be named something like
project-openrc.sh
). - Open the file with a text editor.
- Look for lines that start with
export OS_
. These are your OpenStack environment variables.
Now, we need to tell your computer about these credentials:
-
Open a terminal (Command Prompt on Windows, Terminal on Mac/Linux).
-
Navigate to the directory where you downloaded the RC file.
-
Run the following command:
source project-openrc.sh
Replace
project-openrc.sh
with the actual name of your RC file. -
When prompted, enter your ServerCore password.
This method automatically sets up all the necessary environment variables for you.
-
Open a terminal (Command Prompt on Windows, Terminal on Mac/Linux).
-
For each line in the RC file that starts with
export OS_
, type it into your terminal and press Enter. For example:export OS_AUTH_URL=https://your-openstack-auth-url export OS_PROJECT_ID=your-project-id export OS_PROJECT_NAME="Your Project Name" export OS_USER_DOMAIN_NAME="Default" export OS_USERNAME="your-username" export OS_PASSWORD="your-password" export OS_REGION_NAME="your-region"
Note: For the
OS_PASSWORD
, you'll need to type in your actual ServerCore password.
-
Open your terminal.
-
Type the following commands:
git clone https://github.com/alvo254/orbit. cd orbit
This downloads the project and moves you into the project folder.
In your terminal, still in the project folder, type:
terraform init
This sets up Terraform to work with OpenStack.
Let's see what Terraform is going to create. Type:
terraform plan
This shows you a list of all the resources Terraform will create.
If the plan looks good, let's create everything! Type:
terraform apply --auto-approve
After everything is created, Terraform will show you some information about your new resources. Look for a line that says something like:
floating_ip = "ip"
This is the public IP address of your new virtual machine. You can use SSH to connect to it:
Copy
ssh -i orbit.pem root@<ip>
Replace ip with instance ip
with the actual IP address Terraform gave you.
Want to change something? Here are some files you can modify:
main.tf
: This is where most of the resource definitions are.variables.tf
: You can change default values here.
For example, to use a different size (flavor) for your virtual machine, find the openstack_compute_instance_v2
resource in main.tf
and change the flavor_id
.
Contributions to improve the configuration or documentation are welcome. Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request