Commit 41c0418c by chenxx

new202505

1 parent 83d5f3db
...@@ -30,20 +30,19 @@ ...@@ -30,20 +30,19 @@
|------|-------------|------|---------|:--------:| |------|-------------|------|---------|:--------:|
| <a name="input_app_log_path"></a> [app\_log\_path](#input\_app\_log\_path) | @label "应用日志路径" @group "Advanced" | `string` | `"/data/java_log"` | no | | <a name="input_app_log_path"></a> [app\_log\_path](#input\_app\_log\_path) | @label "应用日志路径" @group "Advanced" | `string` | `"/data/java_log"` | no |
| <a name="input_app_log_path_volume_name"></a> [app\_log\_path\_volume\_name](#input\_app\_log\_path\_volume\_name) | 应用日志挂载卷名,名字只能使用-,例: abc-22 abc-cc | `string` | `"app-log-path"` | no | | <a name="input_app_log_path_volume_name"></a> [app\_log\_path\_volume\_name](#input\_app\_log\_path\_volume\_name) | 应用日志挂载卷名,名字只能使用-,例: abc-22 abc-cc | `string` | `"app-log-path"` | no |
| <a name="input_args"></a> [args](#input\_args) | 属于那个环境,例子:dev,test,beta,release | `list(string)` | <pre>[<br> "release"<br>]</pre> | no | | <a name="input_args"></a> [args](#input\_args) | 属于那个环境,例子:dev,test,beta,release | `string` | `"test"` | no |
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | 域名 | `string` | `""` | no |
| <a name="input_env"></a> [env](#input\_env) | Name and value pairs to set as the environment variables | `map(string)` | `{}` | no | | <a name="input_env"></a> [env](#input\_env) | Name and value pairs to set as the environment variables | `map(string)` | `{}` | no |
| <a name="input_hosts"></a> [hosts](#input\_hosts) | (Optional) host aliases 手动配置域名到hosts | `list(object({ hostname = list(string), ip = string }))` | `[]` | no |
| <a name="input_image"></a> [image](#input\_image) | Docker image name | `string` | n/a | yes | | <a name="input_image"></a> [image](#input\_image) | Docker image name | `string` | n/a | yes |
| <a name="input_limit_cpu"></a> [limit\_cpu](#input\_limit\_cpu) | CPU limit. e.g. 0.5, 1, 2 | `string` | `"0.5"` | no | | <a name="input_ingress_switch"></a> [ingress\_switch](#input\_ingress\_switch) | choise ingress switch | <pre>object({<br> switch = optional(string)<br> path_type = optional(string)<br> path = optional(string)<br> domain_name = optional(string)<br> })</pre> | <pre>{<br> "domain_name": null,<br> "path": "/",<br> "path_type": "ImplementationSpecific",<br> "switch": "off"<br>}</pre> | no |
| <a name="input_limit_memory"></a> [limit\_memory](#input\_limit\_memory) | Memory limit. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi | `string` | `"512Mi"` | no | | <a name="input_limit_cpu"></a> [limit\_cpu](#input\_limit\_cpu) | CPU limit. e.g. 0.5, 1, 2 | `string` | `"1"` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the deployment resource. Auto-generated if empty. | `string` | `""` | no | | <a name="input_limit_memory"></a> [limit\_memory](#input\_limit\_memory) | Memory limit. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi | `string` | `"1G"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to deploy. Auto-generated if empty. | `string` | `"default"` | no | | <a name="input_name"></a> [name](#input\_name) | Name of the deployment resource. Auto-generated if empty. | `string` | n/a | yes |
| <a name="input_path"></a> [path](#input\_path) | 访问路径 | `string` | `"/"` | no | | <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to deploy. Auto-generated if empty. | `string` | n/a | yes |
| <a name="input_path_type"></a> [path\_type](#input\_path\_type) | Path type for ingress rule | `string` | `"ImplementationSpecific"` | no | | <a name="input_ports"></a> [ports](#input\_ports) | Service ports to expose | `list(number)` | <pre>[<br> 6666<br>]</pre> | no |
| <a name="input_ports"></a> [ports](#input\_ports) | Service ports to expose | `list(number)` | n/a | yes |
| <a name="input_replicas"></a> [replicas](#input\_replicas) | Replicas to deploy | `number` | `1` | no | | <a name="input_replicas"></a> [replicas](#input\_replicas) | Replicas to deploy | `number` | `1` | no |
| <a name="input_request_cpu"></a> [request\_cpu](#input\_request\_cpu) | CPU request. e.g. 0.5, 1, 2 | `string` | `"0.1"` | no | | <a name="input_request_cpu"></a> [request\_cpu](#input\_request\_cpu) | CPU request. e.g. 0.5, 1, 2 | `string` | `"0.2"` | no |
| <a name="input_request_memory"></a> [request\_memory](#input\_request\_memory) | Memory request. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi | `string` | `"128Mi"` | no | | <a name="input_request_memory"></a> [request\_memory](#input\_request\_memory) | Memory request. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi | `string` | `"512Mi"` | no |
| <a name="input_restart_policy"></a> [restart\_policy](#input\_restart\_policy) | Restart policy for all containers within the pod. One of Always, OnFailure, Never | `string` | `"Always"` | no | | <a name="input_restart_policy"></a> [restart\_policy](#input\_restart\_policy) | Restart policy for all containers within the pod. One of Always, OnFailure, Never | `string` | `"Always"` | no |
| <a name="input_walrus_metadata_namespace_name"></a> [walrus\_metadata\_namespace\_name](#input\_walrus\_metadata\_namespace\_name) | Walrus metadata namespace name. | `string` | `""` | no | | <a name="input_walrus_metadata_namespace_name"></a> [walrus\_metadata\_namespace\_name](#input\_walrus\_metadata\_namespace\_name) | Walrus metadata namespace name. | `string` | `""` | no |
| <a name="input_walrus_metadata_service_name"></a> [walrus\_metadata\_service\_name](#input\_walrus\_metadata\_service\_name) | Walrus metadata service name. | `string` | `""` | no | | <a name="input_walrus_metadata_service_name"></a> [walrus\_metadata\_service\_name](#input\_walrus\_metadata\_service\_name) | Walrus metadata service name. | `string` | `""` | no |
......
...@@ -25,7 +25,7 @@ module "deployment" { ...@@ -25,7 +25,7 @@ module "deployment" {
image = var.image image = var.image
replicas = var.replicas replicas = var.replicas
restart_policy = var.restart_policy restart_policy = var.restart_policy
args = var.args args = [var.args]
resources = { resources = {
request_cpu = var.request_cpu == "" ? null : var.request_cpu request_cpu = var.request_cpu == "" ? null : var.request_cpu
limit_cpu = var.limit_cpu == "" ? null : var.limit_cpu limit_cpu = var.limit_cpu == "" ? null : var.limit_cpu
...@@ -50,7 +50,14 @@ module "deployment" { ...@@ -50,7 +50,14 @@ module "deployment" {
} }
] ]
#domian map to /etc/hosts
hosts = [
for host_list in var.hosts:
{
hostname = host_list.hostname,
ip = host_list.ip
}
]
} }
module "service" { module "service" {
...@@ -74,6 +81,7 @@ module "service" { ...@@ -74,6 +81,7 @@ module "service" {
} }
module "ingress" { module "ingress" {
count = var.ingress_switch.switch == "on" ? 1 : 0
source = "./modules/ingress/kubernetes" source = "./modules/ingress/kubernetes"
ingress_name = local.name ingress_name = local.name
...@@ -82,10 +90,10 @@ module "ingress" { ...@@ -82,10 +90,10 @@ module "ingress" {
rule = [ rule = [
{ {
domain = var.domain_name domain = var.ingress_switch.domain_name
external_port = var.ports[0] // Service port external_port = var.ports[0] // Service port
path = var.path path = var.ingress_switch.path
path_type = var.path_type path_type = var.ingress_switch.path_type
} }
] ]
......
...@@ -2,6 +2,6 @@ terraform { ...@@ -2,6 +2,6 @@ terraform {
required_version = ">= 0.14.8" required_version = ">= 0.14.8"
required_providers { required_providers {
kubernetes = ">= 2.1.0" kubernetes = "2.27.0"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,7 @@ resource "kubernetes_ingress_v1" "ingress" { ...@@ -10,6 +10,7 @@ resource "kubernetes_ingress_v1" "ingress" {
ingress_class_name = var.ingress_class_name ingress_class_name = var.ingress_class_name
dynamic "rule" { dynamic "rule" {
for_each = var.rule for_each = var.rule
content { content {
host = "${lookup(rule.value, "sub_domain", "")}${lookup(rule.value, "domain", var.domain_name)}" host = "${lookup(rule.value, "sub_domain", "")}${lookup(rule.value, "domain", var.domain_name)}"
......
...@@ -10,5 +10,5 @@ output "ports" { ...@@ -10,5 +10,5 @@ output "ports" {
output "ingress" { output "ingress" {
description = "访问入口ingress" description = "访问入口ingress"
value = var.domain_name value = try(var.ingress_switch.domain_name, "未配置域名")
} }
openapi: 3.0.3
info:
title: OpenAPI schema for template .
components:
schemas:
variables:
type: object
required:
- image
- name
- namespace
properties:
image:
title: Image
type: string
description: Docker image name
x-walrus-ui:
group: Basic
order: 1
namespace:
title: Namespace
type: string
description: Namespace to deploy. Auto-generated if empty.
x-walrus-ui:
group: Basic
order: 2
name:
title: Name
type: string
description: Name of the deployment resource. Auto-generated if empty.
x-walrus-ui:
group: Basic
order: 3
ports:
title: Ports
type: array
description: Service ports to expose
default:
- 6666
items:
type: number
nullable: true
x-walrus-ui:
colSpan: 12
group: Advanced
order: 4
env:
title: Env
type: object
description: Name and value pairs to set as the environment variables
default: {}
nullable: true
additionalProperties:
type: string
x-walrus-ui:
colSpan: 12
group: Advanced
order: 5
replicas:
title: Replicas
type: number
description: Replicas to deploy
default: 1
nullable: true
x-walrus-ui:
group: Advanced
order: 6
request_cpu:
title: Request Cpu
type: string
description: CPU request. e.g. 0.5, 1, 2
default: "0.3"
enum:
- 0.2
- 0.3
- 0.4
- 0.5
- 1
- 2
nullable: true
x-walrus-ui:
group: Resources
order: 7
request_memory:
title: Request Memory
type: string
description: Memory request. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi
default: 512Mi
enum:
- 128Mi
- 512Mi
- 1Gi
- 2Gi
- 3Gi
- 4Gi
nullable: true
x-walrus-ui:
group: Resources
order: 8
limit_cpu:
title: Limit Cpu
type: string
description: CPU limit. e.g. 0.5, 1, 2
default: "0.5"
enum:
- 0.2
- 0.3
- 0.4
- 0.5
- 1
- 2
- 3
nullable: true
x-walrus-ui:
group: Resources
order: 9
limit_memory:
title: Limit Memory
type: string
description: Memory limit. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi
default: 1Gi
enum:
- 128Mi
- 512Mi
- 1Gi
- 2Gi
- 3Gi
- 4Gi
nullable: true
x-walrus-ui:
group: Resources
order: 10
walrus_metadata_service_name:
title: Walrus Metadata Service Name
type: string
description: Walrus metadata service name.
default: ""
nullable: true
x-walrus-ui:
group: Basic
hidden: true
order: 11
walrus_metadata_namespace_name:
title: Walrus Metadata Namespace Name
type: string
description: Walrus metadata namespace name.
default: ""
nullable: true
x-walrus-ui:
group: Basic
hidden: true
order: 12
app_log_path_volume_name:
title: App Log Path Volume Name
type: string
description: '应用日志挂载卷名,名字只能使用-,例: abc-22 abc-cc'
default: app-log-path
nullable: true
x-walrus-ui:
group: Advanced
order: 13
app_log_path:
title: App Log Path
type: string
default: /data/java_log
nullable: true
x-walrus-ui:
group: Advanced
order: 14
restart_policy:
title: Restart Policy
type: string
description: Restart policy for all containers within the pod. One of Always,
OnFailure, Never
default: Always
nullable: true
x-walrus-ui:
group: Advanced
order: 15
args:
title: Args
type: string
description: 属于那个环境,例子:dev,test,beta,release, gh_release, gh_beta, testcdp,
testscrm
default:
- test
enum:
- dev
- test
- beta
- release
- gh_release
- gh_beta
- testcdp
- testscrm
items:
type: string
nullable: true
x-walrus-ui:
colSpan: 12
group: Advanced
order: 16
ingress_switch:
title: Ingress Switch
type: object
description: choise ingress switch
default:
domain_name: null
path: /
path_type: ImplementationSpecific
switch: "off"
nullable: true
properties:
domain_name:
nullable: true
title: Domain Name
type: string
x-walrus-ui:
order: 4
showIf: switch=on
path:
default: /
nullable: true
title: Path
type: string
x-walrus-ui:
order: 3
showIf: switch=on
path_type:
default: ImplementationSpecific
enum:
- ImplementationSpecific
- Exact
- Prefix
nullable: true
title: Path Type
type: string
x-walrus-ui:
order: 2
showIf: switch=on
switch:
enum:
- "off"
- "on"
nullable: true
title: Switch
type: string
x-walrus-ui:
order: 1
x-walrus-ui:
colSpan: 12
group: Ingress
order: 17
hosts:
title: Hosts
type: array
description: (Optional) Add /etc/hosts records to pods
default: []
items:
properties:
hostname:
items:
type: string
title: Hostname
type: array
x-walrus-ui:
colSpan: 12
order: 1
ip:
title: Ip
type: string
x-walrus-ui:
order: 2
required:
- hostname
- ip
type: object
x-walrus-ui:
colSpan: 12
nullable: true
x-walrus-ui:
colSpan: 12
group: Advanced
order: 18
x-walrus-ui:
groupOrder:
- Basic
- Resourced
- Advanced
- Ingress
...@@ -4,11 +4,27 @@ variable "image" { ...@@ -4,11 +4,27 @@ variable "image" {
type = string type = string
description = "Docker image name" description = "Docker image name"
} }
# @label "Namespace"
# @group "Basic"
variable "namespace" {
type = string
description = "Namespace to deploy. Auto-generated if empty."
}
# @label "Deployment Name"
# @group "Advanced"
variable "name" {
type = string
description = "Name of the deployment resource. Auto-generated if empty."
}
# @label "Ports" # @label "Ports"
# @group "Basic" # @group "Basic"
variable "ports" { variable "ports" {
type = list(number) type = list(number)
description = "Service ports to expose" description = "Service ports to expose"
default = [6666]
} }
# @label "Environment Variables" # @label "Environment Variables"
# @options ["dev", "test", "release", "beta"] # @options ["dev", "test", "release", "beta"]
...@@ -31,7 +47,7 @@ variable "replicas" { ...@@ -31,7 +47,7 @@ variable "replicas" {
variable "request_cpu" { variable "request_cpu" {
type = string type = string
description = "CPU request. e.g. 0.5, 1, 2" description = "CPU request. e.g. 0.5, 1, 2"
default = "0.1" default = "0.2"
} }
# @group "Resources" # @group "Resources"
# @options ["128Mi","512Mi", "1G"] # @options ["128Mi","512Mi", "1G"]
...@@ -39,7 +55,7 @@ variable "request_cpu" { ...@@ -39,7 +55,7 @@ variable "request_cpu" {
variable "request_memory" { variable "request_memory" {
type = string type = string
description = "Memory request. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi" description = "Memory request. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi"
default = "128Mi" default = "512Mi"
} }
# @group "Resources" # @group "Resources"
# @options ["0.2","0.3", "0.5","1", "2"] # @options ["0.2","0.3", "0.5","1", "2"]
...@@ -47,7 +63,7 @@ variable "request_memory" { ...@@ -47,7 +63,7 @@ variable "request_memory" {
variable "limit_cpu" { variable "limit_cpu" {
type = string type = string
description = "CPU limit. e.g. 0.5, 1, 2" description = "CPU limit. e.g. 0.5, 1, 2"
default = "0.5" default = "1"
} }
# @group "Resources" # @group "Resources"
# @options ["128Mi","512Mi", "1Gi","2Gi", "3Gi"] # @options ["128Mi","512Mi", "1Gi","2Gi", "3Gi"]
...@@ -55,22 +71,10 @@ variable "limit_cpu" { ...@@ -55,22 +71,10 @@ variable "limit_cpu" {
variable "limit_memory" { variable "limit_memory" {
type = string type = string
description = "Memory limit. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi" description = "Memory limit. e.g. 128Mi, 512Mi, 1Gi, 2Gi, 4Gi"
default = "512Mi" default = "1G"
}
# @label "Namespace"
# @group "Advanced"
variable "namespace" {
type = string
description = "Namespace to deploy. Auto-generated if empty."
default = "default"
}
# @label "Deployment Name"
# @group "Advanced"
variable "name" {
type = string
description = "Name of the deployment resource. Auto-generated if empty."
default = ""
} }
# @hidden # @hidden
variable "walrus_metadata_service_name" { variable "walrus_metadata_service_name" {
type = string type = string
...@@ -85,7 +89,6 @@ variable "walrus_metadata_namespace_name" { ...@@ -85,7 +89,6 @@ variable "walrus_metadata_namespace_name" {
} }
# @label "应用日志挂载卷名" # @label "应用日志挂载卷名"
# @group "Advanced" # @group "Advanced"
variable "app_log_path_volume_name" { variable "app_log_path_volume_name" {
...@@ -114,32 +117,34 @@ variable "restart_policy" { ...@@ -114,32 +117,34 @@ variable "restart_policy" {
# @options ["dev", "test", "beta", "release"] # @options ["dev", "test", "beta", "release"]
# @group "Advanced" # @group "Advanced"
variable "args" { variable "args" {
type = list(string)
description = "属于那个环境,例子:dev,test,beta,release"
default = ["release"]
}
# @label "域名名字"
# @group "ingress"
variable "domain_name" {
type = string type = string
description = "域名" description = "属于那个环境,例子:dev,test,beta,release"
default = "" default = "test"
} }
# @label "path_type" # @label "chiose ingress switch on or off"
# @options ["ImplementationSpecific","Exact","Prefix"] # @options ["on", "off"]
# @group "ingress" # @group "Ingress"
variable "path_type" { variable "ingress_switch" {
type = string type = object({
description = "Path type for ingress rule" switch = optional(string)
default = "ImplementationSpecific" path_type = optional(string)
path = optional(string)
domain_name = optional(string)
})
default = {
switch = "off"
path_type = "ImplementationSpecific"
path = "/"
domain_name = null
}
description = "choise ingress switch"
} }
# @label "path" # @label "host aliases 手动配置域名到hosts"
# @group "ingress" # @group "Advanced"
variable "path" { variable "hosts" {
type = string type = list(object({ hostname = list(string), ip = string }))
description = "访问路径" description = "(Optional) host aliases 手动配置域名到hosts"
default = "/" default = []
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!