How to expose a Pod in Kubernetes using Terraform

0 votes

Hi Guys,

I have launched one Pod in Kubernetes. I want to expose the Pod using Terraform. How can I do that?

Sep 28, 2020 in Terraform by MD
• 95,300 points
176 views

1 answer to this question.

0 votes

Hi@MD,

You can use kubernetes_service resource to expose the Pod. You need to specify the target port as shown below.

resource "kubernetes_service" "example" {
  metadata {
    name = "example-test"
  }
  spec {
    selector {
      App = "${kubernetes_pod.example.metadata.0.labels.App}"
    }
    port {
      port        = 80
      target_port = 80
    }
    type = "LoadBalancer"
}
}
answered Sep 28, 2020 by akhtar
• 38,210 points

Related Questions In Terraform

0 votes
1 answer

How to create a namespace in the Kubernetes cluster using Terraform?

Hi@akhtar, You can use kubernetes_namespace resource in your ...READ MORE

answered Sep 14, 2020 in Terraform by MD
• 95,300 points
1,262 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,300 points
4,086 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,300 points
1,711 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,300 points
739 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
11,153 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,370 points

reshown Apr 12, 2019 by Kalgi 3,547 views
0 votes
1 answer

How to set an IAM policy for a project in GCP using Terraform?

Hi@akhtar, You can create a policy and give ...READ MORE

answered Sep 13, 2020 in Terraform by akhtar
• 38,210 points
312 views
+2 votes
1 answer

How to create a workspace in terraform?

Hi@MD, Terraform has a command named terraform workspace. ...READ MORE

answered Aug 17, 2020 in Terraform by akhtar
• 38,210 points
247 views