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 0682db05
authored
Oct 24, 2023
by
chenxx
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update labels
1 parent
870b1d36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
main.tf
variables.tf
main.tf
View file @
0682db0
...
@@ -11,17 +11,17 @@ terraform {
...
@@ -11,17 +11,17 @@ terraform {
#}
#}
#判断namespace是否存在,不存在则创建
#判断namespace是否存在,不存在则创建
data "kubernetes_namespace" "existing_namespace" {
metadata {
name = var.namespace
}
}
resource "kubernetes_namespace" "new_namespace" {
resource "kubernetes_namespace" "new_namespace" {
count = data.kubernetes_namespace.existing_namespace.metadata.0.name != var.namespace ? 1 : 0
metadata {
metadata {
name = var.namespace
name = var.namespace
}
}
lifecycle {
ignore_changes = [
metadata
]
}
}
}
...
@@ -34,14 +34,12 @@ resource "kubernetes_deployment" "CUS" {
...
@@ -34,14 +34,12 @@ resource "kubernetes_deployment" "CUS" {
replicas = 1
replicas = 1
selector {
selector {
match_labels = {
match_labels = {
app = var.name
labels = {for label in var.labels: label => label}
}
}
}
}
template {
template {
metadata {
metadata {
labels = {
labels = {for label in var.labels: label => label}
app = var.name
}
}
}
spec {
spec {
container {
container {
...
...
variables.tf
View file @
0682db0
...
@@ -33,8 +33,8 @@ variable "namespace" {
...
@@ -33,8 +33,8 @@ variable "namespace" {
# @label "Label"
# @label "Label"
# @group "Advanced"
# @group "Advanced"
variable "label" {
variable "label
s
" {
type = list(string)
type = list(string)
description = "
user label
"
description = "
labels list
"
default = []
default = []
}
}
\ No newline at end of file
\ 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