This guide and accompanying terraform script is a template that allows for the deployment of infrastructure on IBM Cloud using VPC and VSIs in preparation of running the Redpanda ansible scripts.
You can update the variables.tf to adjust the number of nodes, region, zone, etc.
brew install tfenv
tfenv install 1.0.0
tfenv use 1.0.0
terraform ## should see it all come to life
-
Creating COS Instance and Bucket:
The Terraform configuration's utilizes a Cloud Object Store (COS) object to store the Terraform state. This allows for the same infrastructure to be managed across Terraform instances enabling collaboration between users. Here are the steps followed to configure this feature.
- On IBM cloud provision a new COS bucket. This can be done through the IBM Cloud Console with more about that being read here
- Create an HMAC service credential for your COS bucket.
- Navigate to IBM Cloud console to the Object Store panel
- On the side panel navigate to Service Credentials. Note the
cos_hmac_keys
values
- Export the environment variables
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
export AWS_ACCESS_KEY_ID=<access_key_id> export AWS_SECRET_ACCESS_KEY=<secret_access_key>
Now when you use the Terraform scripts, the Terraform state file will be saved and pulled from your COS bucket instead of locally
- Declare the following environment variables required for Terraform to connect to your IBM Cloud instance:
ibmcloud_api_key
is the ibmcloud API key you generated in step 2 above. Run the following to set the environment variable:export TF_VAR_ibmcloud_api_key=<your API key>
ssh_key
should be the name of yourssh_key
you created.export TF_VAR_ssh_key=<your API key>
resource_group
needs the resource group ID not the name. You can get that from using the IBM Cloud CLI:ibmcloud resource groups
and grab the ID.export TF_VAR_resource_group=<resource group Id>
Make sure you are logged into the correct account on IBM Cloud and have correct IAM entitlements to provision infrastructure in a VPC.
- Initialize Environment
terraform init
- Check the plan
terraform plan
- Apply the plan
terraform apply
After the above steps, you should have root access tied to the ssh_key
that was specified. This means that you can log in to the boxes using ssh root@<public ip>
.
However, if you would like to create a a separte user for someone else that will install redpanda. Here are the steps.
- Log into the box:
ssh root@<public ip>
. - Create dev user:
adduser dev
- Give dev user sudo access:
usermod -aG sudo dev
- Permit users to access dev from local, by adding public key to
.ssh/authorized_users
- switch user:
su - dev
- make directory:
mkdir .ssh && cd .ssh
- Run
echo [insert your public key from your .ssh/id_rsa.pub] >> authorized_keys
- switch user: