Generating an SSH key
An SSH key consists of a pair of files. One is the private key, which should never be shared with anyone. The other is the public key. The other file is a public key which allows you to log into the containers and VMs you provision. When you generate the keys, you will use ssh-keygen to store the keys in a safe location so you can bypass the login prompt when connecting to your instances.
To generate SSH keys in macOS, follow these steps:
Enter the following command in the Terminal window.
ssh-keygen -t rsa
This starts the key generation process. When you execute this command, the ssh-keygen utility prompts you to indicate where to store the key.
Press the ENTER key to accept the default location. The ssh-keygen utility prompts you for a passphrase.
Type in a passphrase. You can also hit the ENTER key to accept the default (no passphrase). However, this is not recommended. Warning! You will need to enter the passphrase a second time to continue.
After you confirm the passphrase, the system generates the key pair.
Your identification has been saved in /Users/myname/.ssh/id_rsa. Your public key has been saved in /Users/myname/.ssh/id_rsa.pub. Your private key is saved to the id_rsa file in the .ssh directory and is used to verify the public key you use belongs to the same Triton Compute Service account.
Install tfswitch to specify Terraform version
brew install tfswitch
Supply Terraform version 0.11.11
tfswitch 0.11.11
Install kubectl
brew install kubectl
terraform workspace new my-namespace
terraform init
The current terraform script needs that some environment variables to be defined to run, you can pass the variables via command line or by editing the variables.tf
script.
Here is how to run terraform using command line variables:
Important: The command must be executed under same directory as Terraform scripts.
terraform apply \
-var scaleway_organization={{SCALEWAY_ORGANIZATION_ID}} \
-var scaleway_access={{SCALEWAY_ACCESS_ID}} \
-var scaleway_token={{SCALEWAY_ACCESS_TOKEN}} \
-var private_key=~/.ssh/rsa_key
If you edited the variables.tf
script simply run
terraform apply
export KUBECONFIG=~/my-namespace.conf
my-namespace = terraform workspace name (default if not defined)
kubectl -n kube-system port-forward deployment/kubernetes-dashboard 8888:9090 --kubeconfig=./my-namespace.conf
my-namespace = terraform workspace name (default if not defined)
terraform destroy \
-var scaleway_organization={{SCALEWAY_ORGANIZATION_ID}} \
-var scaleway_access={{SCALEWAY_ACCESS_ID}} \
-var scaleway_token={{SCALEWAY_ACCESS_TOKEN}} \
-var private_key=~/.ssh/rsa_key