Initial commit: add .gitignore and README
This commit is contained in:
81
terraform/modules/kubernetes/namespace/README.md
Normal file
81
terraform/modules/kubernetes/namespace/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Kubernetes Namespace Module
|
||||
|
||||
**Purpose**: Create Kubernetes namespace with resource quotas and limit ranges
|
||||
**Status**: ✅ Complete
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
module "namespace" {
|
||||
source = "../../modules/kubernetes/namespace"
|
||||
|
||||
name = "my-app"
|
||||
|
||||
labels = {
|
||||
app = "my-app"
|
||||
env = "production"
|
||||
managed = "terraform"
|
||||
}
|
||||
|
||||
annotations = {
|
||||
description = "Namespace for my-app"
|
||||
}
|
||||
|
||||
resource_quota = {
|
||||
"requests.cpu" = "4"
|
||||
"requests.memory" = "8Gi"
|
||||
"limits.cpu" = "8"
|
||||
"limits.memory" = "16Gi"
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|----------|
|
||||
| name | Namespace name | string | - | yes |
|
||||
| labels | Labels to apply | map(string) | {} | no |
|
||||
| annotations | Annotations to apply | map(string) | {} | no |
|
||||
| resource_quota | Resource quota limits | map(string) | {} | no |
|
||||
| limit_range | Limit range configuration | object | {} | no |
|
||||
|
||||
---
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| namespace_name | Namespace name |
|
||||
| namespace_id | Namespace UID |
|
||||
| resource_quota_id | Resource quota ID (if created) |
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ Complete - Ready for use
|
||||
55
terraform/modules/kubernetes/namespace/main.tf
Normal file
55
terraform/modules/kubernetes/namespace/main.tf
Normal file
@@ -0,0 +1,55 @@
|
||||
# Kubernetes Namespace Module
|
||||
# Main resources
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Namespace
|
||||
resource "kubernetes_namespace" "main" {
|
||||
metadata {
|
||||
name = var.name
|
||||
labels = var.labels
|
||||
annotations = var.annotations
|
||||
}
|
||||
}
|
||||
|
||||
# Resource Quota (if specified)
|
||||
resource "kubernetes_resource_quota" "quota" {
|
||||
count = length(var.resource_quota) > 0 ? 1 : 0
|
||||
|
||||
metadata {
|
||||
name = "${var.name}-quota"
|
||||
namespace = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
hard = var.resource_quota
|
||||
}
|
||||
}
|
||||
|
||||
# Limit Range (if specified)
|
||||
resource "kubernetes_limit_range" "limits" {
|
||||
count = length(var.limit_range) > 0 ? 1 : 0
|
||||
|
||||
metadata {
|
||||
name = "${var.name}-limits"
|
||||
namespace = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
limit {
|
||||
default = var.limit_range.default
|
||||
default_request = var.limit_range.default_request
|
||||
max = var.limit_range.max
|
||||
min = var.limit_range.min
|
||||
max_limit_request_ratio = var.limit_range.max_limit_request_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
terraform/modules/kubernetes/namespace/outputs.tf
Normal file
17
terraform/modules/kubernetes/namespace/outputs.tf
Normal file
@@ -0,0 +1,17 @@
|
||||
# Kubernetes Namespace Module Outputs
|
||||
|
||||
output "namespace_name" {
|
||||
description = "Namespace name"
|
||||
value = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
output "namespace_id" {
|
||||
description = "Namespace UID"
|
||||
value = kubernetes_namespace.main.metadata[0].uid
|
||||
}
|
||||
|
||||
output "resource_quota_id" {
|
||||
description = "Resource quota ID (if created)"
|
||||
value = length(kubernetes_resource_quota.quota) > 0 ? kubernetes_resource_quota.quota[0].metadata[0].uid : null
|
||||
}
|
||||
|
||||
43
terraform/modules/kubernetes/namespace/variables.tf
Normal file
43
terraform/modules/kubernetes/namespace/variables.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
# Kubernetes Namespace Module Variables
|
||||
|
||||
variable "name" {
|
||||
description = "Namespace name"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
description = "Labels to apply to namespace"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "annotations" {
|
||||
description = "Annotations to apply to namespace"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "resource_quota" {
|
||||
description = "Resource quota limits"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "limit_range" {
|
||||
description = "Limit range configuration"
|
||||
type = object({
|
||||
default = map(string)
|
||||
default_request = map(string)
|
||||
max = map(string)
|
||||
min = map(string)
|
||||
max_limit_request_ratio = map(string)
|
||||
})
|
||||
default = {
|
||||
default = {}
|
||||
default_request = {}
|
||||
max = {}
|
||||
min = {}
|
||||
max_limit_request_ratio = {}
|
||||
}
|
||||
}
|
||||
|
||||
13
terraform/modules/kubernetes/namespace/versions.tf
Normal file
13
terraform/modules/kubernetes/namespace/versions.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Kubernetes Namespace Module - Provider Versions
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user