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

xoap-io/terraform-kubernetes-simple-app

Repository files navigation

Maintained Terraform License: MIT

Table of Contents


Introduction

This is a template for Terraform modules.

It is part of our XOAP Automation Forces Open Source community library to give you a quick start into Infrastructure as Code deployments with Terraform.

We have a lot of Terraform modules that are Open Source and maintained by the XOAP staff.

Please check the links for more info, including usage information and full documentation:


Guidelines

We are using the following guidelines to write code and make it easier for everyone to follow a destinctive guideline. Please check these links before starting to work on changes.

Contributor Covenant

Git Naming Conventions are an important part of the development process. They descrtibe how Branched, Commit Messages, Pull Requests and Tags should look like to make the easily understandebla for everybody in the development chain.

Git Naming Conventions

he Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of.

Conventional Commits

The better a Pull Request description is, the better a review can understand and decide on how to review the changes. This improves implementation speed and reduces communication between the requester and the reviewer resulting in much less overhead.

Wiriting A Great Pull Request Description

Versioning is a crucial part for Terraform Stacks and Modules. Without version tags you cannot clearly create a stable environment and be sure that your latest changes won't crash your production environment (sure it still can happen, but we are trying our best to implement everything that we can to reduce the risk)

Semantic Versioning

Naming Conventions for Terraform resources must be used.

Terraform Naming Conventions


Usage

Installation

For the first ime using this template necessary tools need to be installed. A script for PowerShell Core is provided under ./build/init.ps1

This script will install following dependencies:

This script configures:

  • global git template under ~/.git-template
  • global pre-commit hooks for prepare-commit-msg and commit-msg under ~/.git-template/hooks
  • github actions:
    • linting and checks for pull requests from dev to master/main
    • automatic tagging and release creation on pushes to master/main
    • dependabot updates

It currently supports the automated installation for macOS. Support for Windows and Linux will be available soon.

Synchronisation

We provided a script under ./build/sync_template.ps1 to fetch the latest changes from this template repository. Please be aware that this is mainly a copy operation which means all your current changes have to be committed first and after running the script you have to merge this changes into your codebase.

Configuration


Requirements

Name Version
terraform >=1.1.6
aws >= 2.11.0

Providers

Name Version
kubernetes n/a

Modules

No modules.

Resources

Name Type
kubernetes_deployment.this resource
kubernetes_horizontal_pod_autoscaler.this resource
kubernetes_ingress_v1.this resource
kubernetes_pod_disruption_budget.this resource
kubernetes_service.this resource
kubernetes_service_account.this resource

Inputs

Name Description Type Default Required
additional_hosts Map of additional hosts to be added to the ingress. map(string) {} no
context Default environmental context
object({
organization = string
environment = string
account = string
product = string
tags = map(string)
})
n/a yes
environment_variables Map with environment variables injected to the containers. map(any) n/a yes
hpa Object with autoscaler limits and requests.
object({
max_replicas = number
min_replicas = number
target_cpu_utilization_percentage = number
})
n/a yes
image Image name and tag to deploy. string n/a yes
ingress n/a
object({
host = string
ingress_class = optional(string, "kong")
annotations = optional(map(string), {})

})
null no
name Name used to identify deployed container and all related resources. string n/a yes
namespace Kubernetes namespace where resources must be created. string n/a yes
paths Object mapping local paths to container paths map(any) {} no
resource_config Object with resource limits and requests.
object({
limits = object({
cpu = string
memory = string
})

requests = object({
cpu = string
memory = string
})
})
{
"limits": {
"cpu": "0.5",
"memory": "512Mi"
},
"requests": {
"cpu": "250m",
"memory": "50Mi"
}
}
no
service n/a
object({
container_port = number
target_port = number
type = string
https_enabled = bool
annotations = optional(map(string), {})
healthcheck = object({
path = string
initial_delay_seconds = number
timeout_seconds = number
success_threshold = number
failure_threshold = number
period_seconds = number
})
})
null no
service_account_annotations Annotations to be added to the service account resource. map(string) n/a yes

Outputs

Name Description
deployment n/a
ingress n/a
name The name of the resources
namespace The namespace where the resources will be created
service n/a
service_account n/a