Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Latest commit

 

History

History
50 lines (31 loc) · 2.33 KB

README.md

File metadata and controls

50 lines (31 loc) · 2.33 KB

Terraform examples

This directory contains an example on how to create a Kubernetes cluster and deploy an application into it using UpCloud and Kubernetes Terraform providers.

The implementation is split into the following directories:

  • cluster contains configuration to create a Kubernetes cluster and its dependencies. It provides the UUID of the created cluster as its output.
  • cluster-with-private-node-groups contains configuration to create a Kubernetes cluster with private node groups which are connected to the Internet through a Managed NAT GW. Same output as above.
  • deployment contains configuration for creating and exposing an Kubernetes deployment

You can either run these separately by following the instruction in the sub-directories or as a combined setup by running the terraform commands in this directory.

Provider setup

UpCloud

To be able to deploy resources, you will need to configure UPCLOUD_USERNAME and UPCLOUD_PASSWORD environment variables. See the official UpCloud Terraform provider documentation for more details on how to configure the upcloud provider.

Kubernetes

The Kubernetes provider is configured using certificates acquired with upcloud_kubernetes_cluster data source.

Official documentation covers additional information needed to on how use the provider and it's resources.

Provisioning

By default, we create a cluster where all cluster nodes have public IPs attached to them.

Running terraform apply in this directory will configure both cluster and deployment inside the cluster. See configurations in sub-directories for details.

terraform init
terraform plan
terraform apply

Provisoning a cluster with private node groups

You can also create a cluster with private node groups by doing the following:

  • Modify main.tf and uncomment module.cluster_private and module.deployment_private
  • Modify outputs.tf and uncomment the relevant outputs

And then proceed with creating the resources:

terraform init
terraform plan
terraform apply