Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
terraform_module
/
svc_deploy_tf
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a501a71b
authored
Oct 23, 2023
by
chenxx
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update and fix deploy file
1 parent
34e12d46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
30 deletions
main.tf
variables.tf
main.tf
View file @
a501a71
...
...
@@ -9,34 +9,34 @@ terraform {
#provider "kubernetes" {
# config_path = "~/.kube/config"
#}
#resource "kubernetes_namespace" "test
" {
#
metadata {
# name = "test"
#
}
#
}
resource "kubernetes_deployment" "
test
" {
resource "kubernetes_namespace" "CUS
" {
metadata {
name = var.namespace
}
}
resource "kubernetes_deployment" "
CUS
" {
metadata {
name =
"nginx5"
name =
var.name
#namespace = kubernetes_namespace.test.metadata.0.name
namespace =
"default"
namespace =
var.namespace
}
spec {
replicas = 1
selector {
match_labels = {
app = "ng
inx5
"
app = "ng
6
"
}
}
template {
metadata {
labels = {
app = "ng
inx5
"
app = "ng
6
"
}
}
spec {
container {
image = var.image
name =
"nginx5"
name =
var.name
port {
container_port = 80
}
...
...
@@ -45,33 +45,33 @@ resource "kubernetes_deployment" "test" {
}
}
}
resource "kubernetes_service" "
test
" {
resource "kubernetes_service" "
CUS
" {
metadata {
name = "
nginx5
-svc"
name = "
${var.name}
-svc"
#namespace = kubernetes_namespace.test.metadata.0.name
namespace =
"default"
namespace =
var.namespace
}
spec {
selector = {
app = kubernetes_deployment.
test
.spec.0.template.0.metadata.0.labels.app
app = kubernetes_deployment.
CUS
.spec.0.template.0.metadata.0.labels.app
}
type = "NodePort"
# port = [
# for p in var.ports :
# {
# name = "port-${p}"
# protocol = "TCP"
# target_port = "${p}"
# port = "${p}"
# }
# ]
port = [
for p in var.ports :
{
name = "port-${p}"
protocol = "TCP"
target_port = "${p}"
port = "${p}"
}
]
port {
node_port = 30222
port = 80
target_port = 80
}
#
# port {
# node_port = 30222
# port = 80
# target_port = 80
# }
}
}
\ No newline at end of file
variables.tf
View file @
a501a71
...
...
@@ -3,4 +3,38 @@
variable "image" {
type = string
description = "Docker image name"
}
# @label "Ports"
# @group "Basic"
variable "ports" {
type = list(number)
description = "Service ports to expose"
default = []
}
# @label "Deployment Name"
# @group "Advanced"
variable "name" {
type = string
description = "Name of the deployment resource. Auto-generated if empty."
default = ""
}
# @label "Namespace"
# @group "Advanced"
variable "namespace" {
type = string
description = "Namespace to deploy. Auto-generated if empty."
default = "default"
}
# @label "Label"
# @group "Advanced"
variable "label" {
type = list(string)
description = "user label"
default = []
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment