This module supports creating multiple Kubernetes namespaces / OpenShift projects with optional annotations and labels.
##############################################################################
# Init cluster config for kubernetes providers
##############################################################################
data "ibm_container_cluster_config" "cluster_config" {
cluster_name_id = var.cluster_id
}
##############################################################################
# Config providers
##############################################################################
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key # pragma: allowlist secret
}
provider "kubernetes" {
host = data.ibm_container_cluster_config.cluster_config.host
token = data.ibm_container_cluster_config.cluster_config.token
cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate
}
##############################################################################
# Namespace module
##############################################################################
module "namespace" {
source = "terraform-ibm-modules/namespace/ibm"
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific
namespaces = [
{
name = "my-namespace"
metadata = {
labels = {
"istio-injection" = "enabled"
}
annotations = {
"name" = "example-annotation"
}
}
},
{
name = "my-namespace-2"
metadata = {
labels = {
"istio-injection" = "enabled"
}
annotations = {
"name" = "example-annotation"
}
}
}
]
}
You need the following permissions to run this module.
- IAM Services
- Kubernetes service
Viewer
platform accessManager
service access
- Kubernetes service
Name | Version |
---|---|
terraform | >= 1.3.0 |
kubernetes | >= 2.16.1, < 3.0.0 |
No modules.
Name | Type |
---|---|
kubernetes_namespace.create_namespace | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
namespaces | Set of namespaces to create | list(object({ |
n/a | yes |
No outputs.
You can report issues and request features for this module in GitHub issues in the module repo. See Report an issue or request a feature.
To set up your local development environment, see Local development setup in the project documentation.