This collection of modules will deploy a bare metal OpenShift consisting of (1) ephemeral bootstrap node, (3) control plane nodes, and a user-configured count of worker nodes1 on Packet. DNS records are automatically configured using Cloudflare.
Terraform is just a single binary. Visit their download page, and follow the link download older versions of Terraform. Choose the latest 0.12.x release and then select the download link that corresponds to your operating system. Unzip the download, move the terraform binary into your path and make the binary executable.
Here is an example for macOS:
curl -LO https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_darwin_amd64.zip
unzip terraform_0.12.29_darwin_amd64.zip
chmod +x terraform
sudo mv terraform /usr/local/bin/
Example for Linux:
wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
unzip terraform_0.12.29_linux_amd64.zip
sudo install terraform /usr/local/bin/
local-exec
provisioners require the use of:
curl
jq
To install jq
on RHEL/CentOS:
wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
sudo install jq-linux64 /usr/local/bin/jq
To install jq
on Debian/Ubuntu:
sudo apt-get install jq
To download this project, run the following command:
git clone https://github.com/heatmiser/openshift-packet-deploy.git
cd openshift-packet-deploy/terraform
-
Follow this to configure your Packet Public Cloud project and collect required parameters.
-
Follow this to configure your Cloudflare account and collect required parameters.
-
Obtain an OpenShift Cluster Manager API Token for pullSecret generation.
-
For variables, you have two options:
- export variables in the currently active shell
or
-
create a tfvars file that contains all of the requisite values
-
If you choose to export variables in the currently active shell: Configure TF_VARs applicable to your Packet project, Cloudflare zone, and OpenShift API Token:
export TF_VAR_project_id="kajs886-l59-8488-19910kj" export TF_VAR_auth_token="lka6702KAmVAP8957Abny01051" export TF_VAR_cf_email="[email protected]" export TF_VAR_cf_api_key="21df29762169c002ca656" export TF_VAR_cf_zone_id="706767511sf7377900" export TF_VAR_cluster_basedomain="domain.com" export TF_VAR_ocp_cluster_manager_token="eyJhbGc...d8Agva"
-
The instructions from here going forward will be using a tfvars file that will be populated with all of the requisite values. If you do not wish to go this route, simply export all necessary variable as outline in (1) above and leave out all of the referals to the tfavrs file in the command line entries that follow.
The base of the project directory contains a couple of example tfvars files:
-
-
00cnvlab.tfvars.example
- good configuration for OpenShift virtualization work -
00small.tfvars.example
- minimal deployment, good for testing deployment automationCopy one of the example files to a tfvars filename, ie:
cp 00cnvlab.tfvars.example 00cnvlab.tfvars
...and then edit
00cnvlab.tfvars
with all of the correct user, authentication, project and settings
-
Initialize and validate terraform:
terraform init terraform validate
-
Produce a terraform deploy plan, which will create .tfplan file (file name with date/time):
terraform plan -out=cnvlab-deploy-$(date +%Y-%m-%d.%H%M).tfplan -var-file="00cnvlab.tfvars"
...followed by applying the plan:
terraform apply "cnvlab-2020-09-14.0217.tfplan" #<== tfplan file name time/date specific
All resources will be created and installation launched. This process takes between 30 and 50 minutes to complete:
-
Once provisioning and installation process is complete, the bootstrap node can be removed by permanently (recommended) or temporarily setting
count_bootstrap=0
terraform plan -out=rm-bootstrap-$(date +%Y-%m-%d.%H%M).tfplan -var-file="00cnvlab.tfvars" -var="count_bootstrap=0" terraform apply "rm-bootstrap-2020-09-14.0309.tfplan"
If you need to obtain any of the output values of the deployment at a later time, for example, your
kubeadmin
credentials:terraform output
-
The entire cluster and all associated Cloudflare DNS entries can be deleted with the following command:
terraform destroy -var-file="00cnvlab.tfvars"
1 As of OpenShift Container Platform 4.5 you can deploy three-node clusters on bare metal. Setting count_compute=0
will support deployment of a 3-node cluster. ↩