Use Terraform and the SAS IaC tools to create a Kubernetes cluster for your SAS Viya deployment.
When using the Terraform CLI, make sure you have all the necessary tools installed on your workstation.
Follow either one of the authentication methods described in Authenticating Terraform to Access Azure and set all TF_VAR_name environment variables using the export TF_VAR_*=<value>
command. If you are unsure which Terraform environment variables are required, review the commands that are included in the optional bash script that is described in Tip: Alternative Option 2.
Tip: Alternative Option 1: The commands to set the TF_VAR_name environment variables can be securely stored in a file outside of this repository, for example
$HOME/.azure_creds.sh.
Remember to protect that file so that only you have Read access to it.
Then source your credentials into your shell environment:
. $HOME/.azure_creds.sh
Tip: Alternative Option 2: Once you have authenticated to the
az cli
, you can source the following bash (code) script, which can be used to assign or reassign the Terraform environment variables:
# source the bash script, presuming the file path
source files/tools/terraform_env_variable_helper.sh
Create a file named terraform.tfvars
to customize any input variable value. To get started, copy one of the example variable definition files that are provided
in the ./examples
folder:
# Example copy command
cp examples/sample-input.tfvars terraform.tfvars
For more information about the variables that are declared in variables.tf, refer to CONFIG-VARS.md.
When using a variable definition file other than terraform.tfvars
, see Advanced Terraform Usage for additional command options.
Initialize the Terraform environment for this project by running the following command:
terraform init
This creates a .terraform
directory locally and initializes the Terraform plug-ins and modules that are used in this project.
Note: The terraform init
command only needs to be run once unless new Terraform plug-ins or modules are added.
To preview the cloud resources before creating them, run:
terraform plan
# alternative to store your plan for later: terraform plan -out=~/tf-plan.out
To create cloud resources, run:
terraform apply -auto-approve
This command can take a few minutes to complete. Once it has completed, Terraform output values are written to the console. The 'KUBECONFIG' file for the cluster is written to [prefix]-aks-kubeconfig.conf
in the current directory, $(pwd)
.
When the cloud resources have been created with the apply
command, run the following command to display Terraform output values:
terraform output
After provisioning the infrastructure, you might find that additional changes are required. Update terraform.tfvars
with the desired modifications and run terrafom apply
again.
To destroy all the cloud resources created with the previous commands, run:
terraform destroy
NOTE: The "destroy" action is irreversible.
The command to create the cloud resources writes the kube_config
output value to a file, ./[prefix]-aks-kubeconfig.conf.
When the Kubernetes cluster is ready, use kubectl
to interact with the cluster and perform the SAS Viya deployment.
IMPORTANT The value for cluster_endpoint_public_access_cidrs
must be set to your local IP address or CIDR range.
export KUBECONFIG=$(pwd)/<your prefix>-aks-kubeconfig.conf
kubectl get nodes