This repository contains:
-
the minimum
Terraformscaffolding necessary to spin up aKubernetescluster onLinode. -
a
Makefilewith a suite of commands for creating, and tearing down, aKubernetescluster on Linode via these.tffiles on a local machine. -
a Github Action Workflow which runs
terraform applyon this repository's.tffiles when a newReleaseis published, thus either creating a new or updating a pre-existingKubernetescluster onLinodewith thatRelease's changes.
The Makefile must be paired with an .env file containing all necessary credentials, which are:
VAULT_ADDR
VAULT_NAMESPACE
VAULT_TOKEN
CONSUL_HTTP_TOKEN
TF_VAR_LINODE_KUBERNETES_API_TOKEN
KUBECONFIG
GH_TOKEN
initrunsterraform initterraform_fmtrunsterraform fmtplan_destroyrunsterraform plan -destroydestroyrunsterraform destroyget_kube_configgets the kubeconfig file for a newly createdKubernetesclusterplanrunsterraform planapplyrunsterraform applygenerate_new_vault_token_for_githubgenerates a newVAULT_TOKENlist_releaseslists all GithubReleases for this repocreate_releasecreates a new publishedReleaseon github, taking two arguments:tag='v0.0.0'- the version number for the release in Semverdescription='text'- the description string for theRelease
main.tf is configured to use Consul as a backend state store and Linode as its sole Provider.
When triggered by a published release, the GitHub action Workflow reaches out to a Vault server to retrieve credentials for both Consul nd Linode and then runs terraform fmt, terraform plan and terraform apply.
This is the relevant part of the Workflow which must be configured with a Vault endpoint url and API token as well as the precise paths of the secrets to be fetched:
- uses: hashicorp/vault-action@v2.4.0
with:
url: ${{ env.vault_endpoint}}
tlsSkipVerify: true
method: token
namespace: admin/yoyodynecorp
token: ${{ secrets.VAULT_API_TOKEN }}
secrets: |
secret/data/github_action_linode_terraform LINODE_KUBERNETES_API_TOKEN ;
secret/data/github_action_linode_terraform CONSUL_API_TOKEN
Else on all pull requests, terraform fmt and terraform plan are run to verify correctness.