https://github.com/terraform-ibm-modules/terraform-ibm-namespace
Configures a Kubernetes namespace or Openshift project.
https://github.com/terraform-ibm-modules/terraform-ibm-namespace
core-team graduated ibm-cloud kubernetes namespace openshift project supported terraform terraform-module
Last synced: about 2 months ago
JSON representation
Configures a Kubernetes namespace or Openshift project.
- Host: GitHub
- URL: https://github.com/terraform-ibm-modules/terraform-ibm-namespace
- Owner: terraform-ibm-modules
- License: apache-2.0
- Created: 2024-02-02T10:56:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-21T11:18:16.000Z (5 months ago)
- Last Synced: 2024-12-26T15:04:07.416Z (5 months ago)
- Topics: core-team, graduated, ibm-cloud, kubernetes, namespace, openshift, project, supported, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 212 KB
- Stars: 1
- Watchers: 17
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Namespace module
[-brightgreen)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
[](https://github.com/terraform-ibm-modules/terraform-ibm-namespace/releases/latest)
[](https://github.com/pre-commit/pre-commit)
[](https://renovatebot.com/)
[](https://github.com/semantic-release/semantic-release)This module supports creating multiple Kubernetes namespaces / OpenShift projects with optional annotations and labels.
## Overview
* [terraform-ibm-namespace](#terraform-ibm-namespace)
* [Examples](./examples)
* [Basic example](./examples/basic)
* [Create Namespace on the existing cluster example](./examples/create-namespaces-existing-cluster)
* [Contributing](#contributing)## terraform-ibm-namespace
### Usage
```hcl
##############################################################################
# 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"
}
}
}
]
}
```### Required IAM access policies
You need the following permissions to run this module.
- IAM Services
- **Kubernetes** service
- `Viewer` platform access
- `Manager` service access### Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.3.0 |
| [kubernetes](#requirement\_kubernetes) | >= 2.16.1, < 3.0.0 |### Modules
No modules.
### Resources
| Name | Type |
|------|------|
| [kubernetes_namespace.create_namespace](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |### Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [namespaces](#input\_namespaces) | Set of namespaces to create |list(object({| n/a | yes |
name = string
metadata = optional(object({
labels = map(string)
annotations = map(string)
}))
}))### Outputs
No outputs.
## Contributing
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](https://github.com/terraform-ibm-modules/.github/blob/main/.github/SUPPORT.md).
To set up your local development environment, see [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation.