CloudWiki
Resource

Namespace

Kubernetes
Kubernetes
Namespaces provides a mechanism for isolating groups of resources within a single cluster.
Terraform Name
terraform
kubernetes_namespace
Namespace
attributes:
  • metadata - (Required) Standard namespace's metadata.

Timeouts

kubernetes_namespace provides the following Timeouts configuration options:

  • delete - Default 5 minutes

Nested Blocks

metadata

Arguments

  • annotations - (Optional) An unstructured key value map stored with the namespace that may be used to store arbitrary metadata.

Note

By default, the provider ignores any annotations whose key names end with kubernetes.io. This is necessary because such annotations can be mutated by server-side components and consequently cause a perpetual diff in the Terraform plan output. If you explicitly specify any such annotations in the configuration template then Terraform will consider these as normal resource attributes and manage them as expected (while still avoiding the perpetual diff problem). For more info see Kubernetes reference

  • generate_name - (Optional) Prefix, used by the server, to generate a unique name ONLY IF the name field has not been provided. This value will also be combined with a unique suffix. Read more about name idempotency.
  • labels - (Optional) Map of string keys and values that can be used to organize and categorize (scope and select) namespaces. May match selectors of replication controllers and services.

Note

By default, the provider ignores any labels whose key names end with kubernetes.io. This is necessary because such labels can be mutated by server-side components and consequently cause a perpetual diff in the Terraform plan output. If you explicitly specify any such labels in the configuration template then Terraform will consider these as normal resource attributes and manage them as expected (while still avoiding the perpetual diff problem). For more info see Kubernetes reference

Attributes

  • generation - A sequence number representing a specific generation of the desired state.
  • resource_version - An opaque value that represents the internal version of this namespace that can be used by clients to determine when namespaces have changed. Read more about concurrency control and consistency.
  • uid - The unique in time and space value for this namespace. For more info see Kubernetes reference

Associating resources with a
Namespace
Resources do not "belong" to a
Namespace
Rather, one or more Security Groups are associated to a resource.
Create
Namespace
via Terraform:
The following HCL creates a namespace resource
Syntax:

resource "kubernetes_namespace" "example" {
 metadata {
   annotations = {
     name = "example-annotation"
   }

   labels = {
     mylabel = "label-value"
   }

   name = "terraform-example-namespace"
 }
}

Create
Namespace
via CLI:
Parameters:

apiVersion: v1
kind: Namespace
metadata:
 name: <insert-namespace-name-here>

Example:

kubectl create -f ./my-namespace.yaml

aws cost
Costs
Direct Cost
Indirect Cost
No items found.
Best Practices for
Namespace

Categorized by Availability, Security & Compliance and Cost

Low
Access allowed from VPN
No items found.
Low
Auto Scaling Group not in use
No items found.
Medium
Connections towards DynamoDB should be via VPC endpoints
No items found.
Medium
Container in CrashLoopBackOff state
No items found.
Low
EC2 with GPU capabilities
No items found.
Medium
EC2 with high privileged policies
No items found.
Medium
ECS cluster delete alarm
No items found.
Critical
ECS task with Admin access (*:*)
Medium
ECS task with high privileged policies
No items found.
Critical
EKS cluster delete alarm
No items found.
Medium
ElastiCache cluster delete alarm
No items found.
Medium
Ensure Container liveness probe is configured
No items found.
Medium
Ensure ECS task definition has memory limit
No items found.
Critical
Ensure EMR cluster master nodes are not publicly accessible
No items found.
More from
Kubernetes