List down all namespaces in minikube using Terraform

0 votes

Hi Guys,

I am new to the Terraform platform. I want to list down all the namespaces available in the Minikube cluster using Terraform. How can I do that?

Jun 30, 2020 in Terraform by akhtar
• 38,260 points
1,073 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use data source in Terraform. This data source provides a mechanism for listing the names of all available namespaces in a Kubernetes cluster. You can also go through the below code.

provider "kubernetes" {
  config_context_cluster   = "minikube"
}
data "kubernetes_all_namespaces" "allns" {}
output "all-ns" {
  value = data.kubernetes_all_namespaces.allns.namespaces
}

Execute this code in your terraform platform, you will get your output.

C:\Users\NADIM AKTHAR\Desktop\terraform\kuberenetes>terraform apply
data.kubernetes_all_namespaces.allns: Refreshing state...
kubernetes_namespace.example: Refreshing state... [id=my-first-namespace]
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
all-ns = [
  "default",
  "kube-node-lease",
  "kube-public",
  "kube-system",
  "my-first-namespace",
]
answered Jun 30, 2020 by MD
• 95,460 points

Related Questions In Terraform

0 votes
1 answer

How to create one key in AWS using terraform?

Hi@akhtar, You can use aws_key_pair resource n terraform. ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,460 points
1,557 views
0 votes
1 answer

How to create a folder in S3 bucket using terraform?

Hi@akhtar, You can use aws_s3_bucket_object resource to create one ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,460 points
10,965 views
0 votes
1 answer

How to do ssh in EC2 instance using Terraform?

Hi@akhtar, To ssh in your EC2 instance, you ...READ MORE

answered Jun 15, 2020 in Terraform by MD
• 95,460 points
7,195 views
0 votes
1 answer

How to create a rds snapshot from running rds instance in AWS using terraform?

Hi, I think you can use aws_db_instance resource to ...READ MORE

answered Jul 20, 2020 in Terraform by MD
• 95,460 points
2,665 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,477 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
0 votes
1 answer

How to launch one Pod in Minikube using Terraform?

Hi@akhtar, You can use kubernetes_pod resource to launch ...READ MORE

answered Jun 16, 2020 in Terraform by MD
• 95,460 points
3,392 views
0 votes
1 answer

How to create a namespace in minikube using Terraform?

Hi@akhtar, You can use kubernetes_namespace resource. It is used ...READ MORE

answered Jun 30, 2020 in Terraform by MD
• 95,460 points
1,696 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP