Initial commit: add .gitignore and README
This commit is contained in:
76
terraform/examples/namespace-example/main.tf
Normal file
76
terraform/examples/namespace-example/main.tf
Normal file
@@ -0,0 +1,76 @@
|
||||
# Example: Using Kubernetes Namespace Module
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "kubernetes" {
|
||||
# Configure your Kubernetes provider
|
||||
# config_path = "~/.kube/config"
|
||||
}
|
||||
|
||||
# Namespace Module
|
||||
module "namespace" {
|
||||
source = "../../modules/kubernetes/namespace"
|
||||
|
||||
name = "my-app"
|
||||
|
||||
labels = {
|
||||
app = "my-app"
|
||||
env = "production"
|
||||
managed = "terraform"
|
||||
team = "platform"
|
||||
}
|
||||
|
||||
annotations = {
|
||||
description = "Namespace for my-app production environment"
|
||||
}
|
||||
|
||||
resource_quota = {
|
||||
"requests.cpu" = "4"
|
||||
"requests.memory" = "8Gi"
|
||||
"limits.cpu" = "8"
|
||||
"limits.memory" = "16Gi"
|
||||
"persistentvolumeclaims" = "10"
|
||||
"services.loadbalancers" = "2"
|
||||
}
|
||||
|
||||
limit_range = {
|
||||
default = {
|
||||
"cpu" = "500m"
|
||||
"memory" = "1Gi"
|
||||
}
|
||||
default_request = {
|
||||
"cpu" = "100m"
|
||||
"memory" = "128Mi"
|
||||
}
|
||||
max = {
|
||||
"cpu" = "2"
|
||||
"memory" = "4Gi"
|
||||
}
|
||||
min = {
|
||||
"cpu" = "50m"
|
||||
"memory" = "64Mi"
|
||||
}
|
||||
max_limit_request_ratio = {
|
||||
"cpu" = "4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Outputs
|
||||
output "namespace_name" {
|
||||
value = module.namespace.namespace_name
|
||||
}
|
||||
|
||||
output "namespace_id" {
|
||||
value = module.namespace.namespace_id
|
||||
}
|
||||
|
||||
96
terraform/examples/networking-example/main.tf
Normal file
96
terraform/examples/networking-example/main.tf
Normal file
@@ -0,0 +1,96 @@
|
||||
# Example: Using Azure Networking Module
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
||||
|
||||
# Resource Group
|
||||
resource "azurerm_resource_group" "example" {
|
||||
name = "rg-example"
|
||||
location = "eastus"
|
||||
}
|
||||
|
||||
# Networking Module
|
||||
module "networking" {
|
||||
source = "../../modules/azure/networking"
|
||||
|
||||
resource_group_name = azurerm_resource_group.example.name
|
||||
location = azurerm_resource_group.example.location
|
||||
vnet_name = "vnet-example"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
|
||||
subnets = {
|
||||
frontend = {
|
||||
name = "snet-frontend"
|
||||
address_prefixes = ["10.0.1.0/24"]
|
||||
service_endpoints = ["Microsoft.Storage"]
|
||||
}
|
||||
backend = {
|
||||
name = "snet-backend"
|
||||
address_prefixes = ["10.0.2.0/24"]
|
||||
service_endpoints = []
|
||||
}
|
||||
database = {
|
||||
name = "snet-database"
|
||||
address_prefixes = ["10.0.3.0/24"]
|
||||
service_endpoints = ["Microsoft.Sql"]
|
||||
}
|
||||
}
|
||||
|
||||
network_security_groups = {
|
||||
frontend_nsg = {
|
||||
name = "nsg-frontend"
|
||||
subnet_key = "frontend"
|
||||
security_rules = [
|
||||
{
|
||||
name = "AllowHTTP"
|
||||
priority = 100
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "80"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
},
|
||||
{
|
||||
name = "AllowHTTPS"
|
||||
priority = 110
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "443"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
tags = {
|
||||
Environment = "example"
|
||||
ManagedBy = "Terraform"
|
||||
}
|
||||
}
|
||||
|
||||
# Outputs
|
||||
output "vnet_id" {
|
||||
value = module.networking.vnet_id
|
||||
}
|
||||
|
||||
output "subnet_ids" {
|
||||
value = module.networking.subnet_ids
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user