From e9ac4bb62fddbae94efcc2968a395191c2516085 Mon Sep 17 00:00:00 2001 From: Zheng Xi Zhou Date: Sun, 24 Oct 2021 10:02:39 +0800 Subject: [PATCH] Fix: add another output `CLUSTER_ID` for Alibaba Cloud ack (#2543) To support sub-path of a git repo which stores HCLs, also update the dependency of Terraform controller --- apis/core.oam.dev/common/types.go | 3 + .../crds/core.oam.dev_traitdefinitions.yaml | 8 + .../core.oam.dev_workloaddefinitions.yaml | 8 + .../core.oam.dev_applicationrevisions.yaml | 32 +++ .../core.oam.dev_componentdefinitions.yaml | 8 + .../core.oam.dev_definitionrevisions.yaml | 16 ++ .../crds/core.oam.dev_policydefinitions.yaml | 4 + .../crds/core.oam.dev_traitdefinitions.yaml | 8 + .../core.oam.dev_workflowstepdefinitions.yaml | 4 + .../core.oam.dev_workloaddefinitions.yaml | 8 + .../vela-core/templates/addons/terraform.yaml | 198 +----------------- .../core.oam.dev_applicationrevisions.yaml | 32 +++ .../core.oam.dev_definitionrevisions.yaml | 16 ++ .../crds/core.oam.dev_policydefinitions.yaml | 4 + .../crds/core.oam.dev_traitdefinitions.yaml | 8 + .../core.oam.dev_workflowstepdefinitions.yaml | 4 + .../core.oam.dev_workloaddefinitions.yaml | 8 + go.mod | 2 +- go.sum | 4 +- .../core.oam.dev_applicationrevisions.yaml | 32 +++ .../core.oam.dev_componentdefinitions.yaml | 8 + .../core.oam.dev_definitionrevisions.yaml | 16 ++ .../crds/core.oam.dev_policydefinitions.yaml | 4 + .../crds/core.oam.dev_traitdefinitions.yaml | 8 + .../core.oam.dev_workflowstepdefinitions.yaml | 4 + .../core.oam.dev_workloaddefinitions.yaml | 8 + pkg/appfile/appfile.go | 1 + vela-templates/addons/auto-gen/terraform.yaml | 198 +----------------- .../definitions/terraform-alibaba-ack.yaml | 196 +---------------- vela-templates/addons/terraform/template.yaml | 2 +- 30 files changed, 267 insertions(+), 585 deletions(-) diff --git a/apis/core.oam.dev/common/types.go b/apis/core.oam.dev/common/types.go index f64a2669d..3d8e70f6e 100644 --- a/apis/core.oam.dev/common/types.go +++ b/apis/core.oam.dev/common/types.go @@ -115,6 +115,9 @@ type Terraform struct { // +kubebuilder:validation:Enum:=hcl;json;remote Type string `json:"type,omitempty"` + // Path is the sub-directory of remote git repository. It's valid when remote is set + Path string `json:"path,omitempty"` + // ProviderReference specifies the reference to Provider ProviderReference *types.Reference `json:"providerRef,omitempty"` } diff --git a/charts/oam-runtime/crds/core.oam.dev_traitdefinitions.yaml b/charts/oam-runtime/crds/core.oam.dev_traitdefinitions.yaml index 6d694258f..3f33343d6 100644 --- a/charts/oam-runtime/crds/core.oam.dev_traitdefinitions.yaml +++ b/charts/oam-runtime/crds/core.oam.dev_traitdefinitions.yaml @@ -188,6 +188,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -468,6 +472,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/oam-runtime/crds/core.oam.dev_workloaddefinitions.yaml b/charts/oam-runtime/crds/core.oam.dev_workloaddefinitions.yaml index 80d37924e..394473b85 100644 --- a/charts/oam-runtime/crds/core.oam.dev_workloaddefinitions.yaml +++ b/charts/oam-runtime/crds/core.oam.dev_workloaddefinitions.yaml @@ -193,6 +193,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -454,6 +458,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml index 075b50992..66f8af181 100644 --- a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml @@ -1248,6 +1248,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1651,6 +1655,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1952,6 +1960,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3392,6 +3404,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3688,6 +3704,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4073,6 +4093,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4337,6 +4361,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4617,6 +4645,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_componentdefinitions.yaml b/charts/vela-core/crds/core.oam.dev_componentdefinitions.yaml index 10530b945..519bb7a93 100644 --- a/charts/vela-core/crds/core.oam.dev_componentdefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_componentdefinitions.yaml @@ -179,6 +179,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -463,6 +467,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml b/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml index 4e81135c2..d09f351d3 100644 --- a/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml +++ b/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml @@ -222,6 +222,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -506,6 +510,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -783,6 +791,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1041,6 +1053,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_policydefinitions.yaml b/charts/vela-core/crds/core.oam.dev_policydefinitions.yaml index 07169c704..16eeb0635 100644 --- a/charts/vela-core/crds/core.oam.dev_policydefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_policydefinitions.yaml @@ -151,6 +151,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml b/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml index 6d694258f..3f33343d6 100644 --- a/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml @@ -188,6 +188,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -468,6 +472,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_workflowstepdefinitions.yaml b/charts/vela-core/crds/core.oam.dev_workflowstepdefinitions.yaml index 025dee2f1..880959871 100644 --- a/charts/vela-core/crds/core.oam.dev_workflowstepdefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_workflowstepdefinitions.yaml @@ -148,6 +148,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/crds/core.oam.dev_workloaddefinitions.yaml b/charts/vela-core/crds/core.oam.dev_workloaddefinitions.yaml index 80d37924e..394473b85 100644 --- a/charts/vela-core/crds/core.oam.dev_workloaddefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_workloaddefinitions.yaml @@ -193,6 +193,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -454,6 +458,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-core/templates/addons/terraform.yaml b/charts/vela-core/templates/addons/terraform.yaml index 32770d7a5..9f29c0156 100644 --- a/charts/vela-core/templates/addons/terraform.yaml +++ b/charts/vela-core/templates/addons/terraform.yaml @@ -23,7 +23,7 @@ data: chart: terraform-controller repoType: helm url: https://charts.kubevela.net/addons - version: 0.2.4 + version: 0.2.5 type: helm - name: alibaba-ack properties: @@ -40,199 +40,9 @@ data: spec: schematic: terraform: - configuration: | - module "kubernetes" { - source = "github.com/zzxwill/terraform-alicloud-kubernetes" - new_nat_gateway = true - vpc_name = var.vpc_name - vpc_cidr = var.vpc_cidr - vswitch_name_prefix = var.vswitch_name_prefix - vswitch_cidrs = var.vswitch_cidrs - master_instance_types = var.master_instance_types - worker_instance_types = var.worker_instance_types - k8s_pod_cidr = var.k8s_pod_cidr - k8s_service_cidr = var.k8s_service_cidr - k8s_worker_number = var.k8s_worker_number - cpu_core_count = var.cpu_core_count - memory_size = var.memory_size - zone_id = var.zone_id - k8s_version = var.k8s_version - k8s_name_prefix = var.k8s_name_prefix - } - ###################### - # Instance types variables - ###################### - variable "cpu_core_count" { - description = "CPU core count is used to fetch instance types." - type = number - default = 4 - } - variable "memory_size" { - description = "Memory size used to fetch instance types." - type = number - default = 8 - } - ###################### - # VPC variables - ###################### - variable "vpc_name" { - description = "The vpc name used to create a new vpc when 'vpc_id' is not specified. Default to variable `example_name`" - type = string - default = "tf-k8s-vpc" - } - variable "vpc_cidr" { - description = "The cidr block used to launch a new vpc when 'vpc_id' is not specified." - type = string - default = "10.0.0.0/8" - } - ###################### - # VSwitch variables - ###################### - variable "vswitch_name_prefix" { - type = string - description = "The vswitch name prefix used to create several new vswitches. Default to variable 'example_name'." - default = "tf-k8s-vsw" - } - variable "number_format" { - description = "The number format used to output." - type = string - default = "%02d" - } - variable "vswitch_ids" { - description = "List of existing vswitch id." - type = list - default = [] - } - variable "vswitch_cidrs" { - description = "List of cidr blocks used to create several new vswitches when 'vswitch_ids' is not specified." - type = list - default = [ - "10.1.0.0/16", - "10.2.0.0/16", - "10.3.0.0/16"] - } - variable "k8s_name_prefix" { - description = "The name prefix used to create several kubernetes clusters. Default to variable `example_name`" - type = string - default = "poc" - } - variable "new_nat_gateway" { - type = bool - description = "Whether to create a new nat gateway. In this template, a new nat gateway will create a nat gateway, eip and server snat entries." - default = true - } - variable "master_instance_types" { - description = "The ecs instance types used to launch master nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c5.xlarge", - "ecs.n4.xlarge", - # "ecs.n1.large", - # "ecs.sn1.large", - # "ecs.s6-c1m2.xlarge", - # "ecs.c6e.xlarge" - ] - } - variable "worker_instance_types" { - description = "The ecs instance types used to launch worker nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c6e.xlarge", - "ecs.n4.xlarge", - // "ecs.n1.large", - // "ecs.sn1.large", - // "ecs.s6-c1m2.xlarge" - ] - } - variable "node_cidr_mask" { - type = number - description = "The node cidr block to specific how many pods can run on single node. Valid values: [24-28]." - default = 24 - } - variable "enable_ssh" { - description = "Enable login to the node through SSH." - type = bool - default = true - } - variable "install_cloud_monitor" { - description = "Install cloud monitor agent on ECS." - type = bool - default = true - } - variable "cpu_policy" { - type = string - description = "kubelet cpu policy. Valid values: 'none','static'. Default to 'none'." - default = "none" - } - variable "proxy_mode" { - description = "Proxy mode is option of kube-proxy. Valid values: 'ipvs','iptables'. Default to 'iptables'." - type = string - default = "iptables" - } - variable "password" { - description = "The password of ECS instance." - type = string - default = "Just4Test" - } - variable "k8s_worker_number" { - description = "The number of worker nodes in kubernetes cluster." - type = number - default = 2 - } - # k8s_pod_cidr is only for flannel network - variable "k8s_pod_cidr" { - description = "The kubernetes pod cidr block. It cannot be equals to vpc's or vswitch's and cannot be in them." - type = string - default = "172.20.0.0/16" - } - variable "k8s_service_cidr" { - description = "The kubernetes service cidr block. It cannot be equals to vpc's or vswitch's or pod's and cannot be in them." - type = string - default = "192.168.0.0/16" - } - variable "k8s_version" { - description = "The version of the kubernetes version. Valid values: '1.16.6-aliyun.1','1.14.8-aliyun.1'. Default to '1.16.6-aliyun.1'." - type = string - default = "1.20.4-aliyun.1" - } - variable "zone_id" { - description = "Availability Zone ID" - type = string - default = "cn-hongkong-b" - # "cn-beijing-a" - } - output "name" { - value = module.kubernetes.name - } - output "kubeconfig" { - value = module.kubernetes.kubeconfig - } - output "cluster_ca_cert" { - value = module.kubernetes.cluster_ca_cert - } - output "client_cert" { - value = module.kubernetes.client_cert - } - output "client_key" { - value = module.kubernetes.client_key - } - output "api_server_internet" { - value = module.kubernetes.api_server_internet - } + configuration: https://github.com/kubevela-contrib/terraform-modules.git + path: alibaba/cs/dedicated-kubernetes + type: remote workload: definition: apiVersion: terraform.core.oam.dev/v1beta1 diff --git a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml index 075b50992..66f8af181 100644 --- a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml @@ -1248,6 +1248,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1651,6 +1655,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1952,6 +1960,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3392,6 +3404,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3688,6 +3704,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4073,6 +4093,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4337,6 +4361,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4617,6 +4645,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml b/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml index 4e81135c2..d09f351d3 100644 --- a/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml @@ -222,6 +222,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -506,6 +510,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -783,6 +791,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1041,6 +1053,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-minimal/crds/core.oam.dev_policydefinitions.yaml b/charts/vela-minimal/crds/core.oam.dev_policydefinitions.yaml index 07169c704..16eeb0635 100644 --- a/charts/vela-minimal/crds/core.oam.dev_policydefinitions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_policydefinitions.yaml @@ -151,6 +151,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml b/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml index 6d694258f..3f33343d6 100644 --- a/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml @@ -188,6 +188,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -468,6 +472,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-minimal/crds/core.oam.dev_workflowstepdefinitions.yaml b/charts/vela-minimal/crds/core.oam.dev_workflowstepdefinitions.yaml index 025dee2f1..880959871 100644 --- a/charts/vela-minimal/crds/core.oam.dev_workflowstepdefinitions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_workflowstepdefinitions.yaml @@ -148,6 +148,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/charts/vela-minimal/crds/core.oam.dev_workloaddefinitions.yaml b/charts/vela-minimal/crds/core.oam.dev_workloaddefinitions.yaml index 80d37924e..394473b85 100644 --- a/charts/vela-minimal/crds/core.oam.dev_workloaddefinitions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_workloaddefinitions.yaml @@ -193,6 +193,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -454,6 +458,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/go.mod b/go.mod index 06936e73b..1b971970d 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/mitchellh/hashstructure/v2 v2.0.1 github.com/oam-dev/cluster-gateway v1.1.2 github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 - github.com/oam-dev/terraform-controller v0.2.4 + github.com/oam-dev/terraform-controller v0.2.5 github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.16.4 github.com/onsi/gomega v1.16.0 diff --git a/go.sum b/go.sum index 52245e12a..970c37304 100644 --- a/go.sum +++ b/go.sum @@ -1207,8 +1207,8 @@ github.com/oam-dev/stern v1.13.0-alpha h1:EVjM8Qvh6LssB6t4RZrjf9DtCq1cz+/cy6OF7f github.com/oam-dev/stern v1.13.0-alpha/go.mod h1:AOkvfFUv0Arz7GBi0jz7S0Jsu4K/kdvSjNsnRt1+BIg= github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 h1:tD8HiFKnt0jnwdTWjeqUnfnUYLD/+Nsmj8ZGIxqDWiU= github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28/go.mod h1:Mu8i0/DdplvnjwRbAYPsc8+LRR27n/mp8VWdkN10GzE= -github.com/oam-dev/terraform-controller v0.2.4 h1:yGgIzm2EWNghuRutnChrRfhMjdlU/jE/cLfBizCgE24= -github.com/oam-dev/terraform-controller v0.2.4/go.mod h1:wd4rnqnJzz274Sg1/qoeIhBx1rvTZ/ECzXoMff0ucR0= +github.com/oam-dev/terraform-controller v0.2.5 h1:ntSyLUZkjvyHPJEuSYGvsa5+Sb3fDXkqoS+iD3avHQo= +github.com/oam-dev/terraform-controller v0.2.5/go.mod h1:wd4rnqnJzz274Sg1/qoeIhBx1rvTZ/ECzXoMff0ucR0= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml index e85c3558d..185c3ac2f 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml @@ -1248,6 +1248,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1651,6 +1655,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1952,6 +1960,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3392,6 +3404,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -3688,6 +3704,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4073,6 +4093,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4337,6 +4361,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -4617,6 +4645,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote + git repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_componentdefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_componentdefinitions.yaml index a29c120d1..c8edcfbc4 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_componentdefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_componentdefinitions.yaml @@ -179,6 +179,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -463,6 +467,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml index a58389fd2..8ffc3eaac 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml @@ -222,6 +222,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -506,6 +510,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -783,6 +791,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -1041,6 +1053,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git + repository. It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_policydefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_policydefinitions.yaml index 8f71e4c52..925e30f5f 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_policydefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_policydefinitions.yaml @@ -151,6 +151,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml index 5cce855a2..3b54c2a6e 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml @@ -188,6 +188,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -468,6 +472,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflowstepdefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflowstepdefinitions.yaml index 91c8228f7..3d2de420f 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflowstepdefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflowstepdefinitions.yaml @@ -148,6 +148,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workloaddefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workloaddefinitions.yaml index 419a9e8f0..9b48f018f 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workloaddefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workloaddefinitions.yaml @@ -193,6 +193,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider @@ -454,6 +458,10 @@ spec: configuration: description: Configuration is Terraform Configuration type: string + path: + description: Path is the sub-directory of remote git repository. + It's valid when remote is set + type: string providerRef: description: ProviderReference specifies the reference to Provider diff --git a/pkg/appfile/appfile.go b/pkg/appfile/appfile.go index 89e78d3c7..32b97801c 100644 --- a/pkg/appfile/appfile.go +++ b/pkg/appfile/appfile.go @@ -669,6 +669,7 @@ func generateTerraformConfigurationWorkload(wl *Workload, ns string) (*unstructu configuration.Spec.JSON = wl.FullTemplate.Terraform.Configuration case "remote": configuration.Spec.Remote = wl.FullTemplate.Terraform.Configuration + configuration.Spec.Path = wl.FullTemplate.Terraform.Path } if wl.FullTemplate.Terraform.ProviderReference != nil { diff --git a/vela-templates/addons/auto-gen/terraform.yaml b/vela-templates/addons/auto-gen/terraform.yaml index 555992068..23eddd8de 100644 --- a/vela-templates/addons/auto-gen/terraform.yaml +++ b/vela-templates/addons/auto-gen/terraform.yaml @@ -20,7 +20,7 @@ spec: chart: terraform-controller repoType: helm url: https://charts.kubevela.net/addons - version: 0.2.4 + version: 0.2.5 type: helm - name: alibaba-ack properties: @@ -37,199 +37,9 @@ spec: spec: schematic: terraform: - configuration: | - module "kubernetes" { - source = "github.com/zzxwill/terraform-alicloud-kubernetes" - new_nat_gateway = true - vpc_name = var.vpc_name - vpc_cidr = var.vpc_cidr - vswitch_name_prefix = var.vswitch_name_prefix - vswitch_cidrs = var.vswitch_cidrs - master_instance_types = var.master_instance_types - worker_instance_types = var.worker_instance_types - k8s_pod_cidr = var.k8s_pod_cidr - k8s_service_cidr = var.k8s_service_cidr - k8s_worker_number = var.k8s_worker_number - cpu_core_count = var.cpu_core_count - memory_size = var.memory_size - zone_id = var.zone_id - k8s_version = var.k8s_version - k8s_name_prefix = var.k8s_name_prefix - } - ###################### - # Instance types variables - ###################### - variable "cpu_core_count" { - description = "CPU core count is used to fetch instance types." - type = number - default = 4 - } - variable "memory_size" { - description = "Memory size used to fetch instance types." - type = number - default = 8 - } - ###################### - # VPC variables - ###################### - variable "vpc_name" { - description = "The vpc name used to create a new vpc when 'vpc_id' is not specified. Default to variable `example_name`" - type = string - default = "tf-k8s-vpc" - } - variable "vpc_cidr" { - description = "The cidr block used to launch a new vpc when 'vpc_id' is not specified." - type = string - default = "10.0.0.0/8" - } - ###################### - # VSwitch variables - ###################### - variable "vswitch_name_prefix" { - type = string - description = "The vswitch name prefix used to create several new vswitches. Default to variable 'example_name'." - default = "tf-k8s-vsw" - } - variable "number_format" { - description = "The number format used to output." - type = string - default = "%02d" - } - variable "vswitch_ids" { - description = "List of existing vswitch id." - type = list - default = [] - } - variable "vswitch_cidrs" { - description = "List of cidr blocks used to create several new vswitches when 'vswitch_ids' is not specified." - type = list - default = [ - "10.1.0.0/16", - "10.2.0.0/16", - "10.3.0.0/16"] - } - variable "k8s_name_prefix" { - description = "The name prefix used to create several kubernetes clusters. Default to variable `example_name`" - type = string - default = "poc" - } - variable "new_nat_gateway" { - type = bool - description = "Whether to create a new nat gateway. In this template, a new nat gateway will create a nat gateway, eip and server snat entries." - default = true - } - variable "master_instance_types" { - description = "The ecs instance types used to launch master nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c5.xlarge", - "ecs.n4.xlarge", - # "ecs.n1.large", - # "ecs.sn1.large", - # "ecs.s6-c1m2.xlarge", - # "ecs.c6e.xlarge" - ] - } - variable "worker_instance_types" { - description = "The ecs instance types used to launch worker nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c6e.xlarge", - "ecs.n4.xlarge", - // "ecs.n1.large", - // "ecs.sn1.large", - // "ecs.s6-c1m2.xlarge" - ] - } - variable "node_cidr_mask" { - type = number - description = "The node cidr block to specific how many pods can run on single node. Valid values: [24-28]." - default = 24 - } - variable "enable_ssh" { - description = "Enable login to the node through SSH." - type = bool - default = true - } - variable "install_cloud_monitor" { - description = "Install cloud monitor agent on ECS." - type = bool - default = true - } - variable "cpu_policy" { - type = string - description = "kubelet cpu policy. Valid values: 'none','static'. Default to 'none'." - default = "none" - } - variable "proxy_mode" { - description = "Proxy mode is option of kube-proxy. Valid values: 'ipvs','iptables'. Default to 'iptables'." - type = string - default = "iptables" - } - variable "password" { - description = "The password of ECS instance." - type = string - default = "Just4Test" - } - variable "k8s_worker_number" { - description = "The number of worker nodes in kubernetes cluster." - type = number - default = 2 - } - # k8s_pod_cidr is only for flannel network - variable "k8s_pod_cidr" { - description = "The kubernetes pod cidr block. It cannot be equals to vpc's or vswitch's and cannot be in them." - type = string - default = "172.20.0.0/16" - } - variable "k8s_service_cidr" { - description = "The kubernetes service cidr block. It cannot be equals to vpc's or vswitch's or pod's and cannot be in them." - type = string - default = "192.168.0.0/16" - } - variable "k8s_version" { - description = "The version of the kubernetes version. Valid values: '1.16.6-aliyun.1','1.14.8-aliyun.1'. Default to '1.16.6-aliyun.1'." - type = string - default = "1.20.4-aliyun.1" - } - variable "zone_id" { - description = "Availability Zone ID" - type = string - default = "cn-hongkong-b" - # "cn-beijing-a" - } - output "name" { - value = module.kubernetes.name - } - output "kubeconfig" { - value = module.kubernetes.kubeconfig - } - output "cluster_ca_cert" { - value = module.kubernetes.cluster_ca_cert - } - output "client_cert" { - value = module.kubernetes.client_cert - } - output "client_key" { - value = module.kubernetes.client_key - } - output "api_server_internet" { - value = module.kubernetes.api_server_internet - } + configuration: https://github.com/kubevela-contrib/terraform-modules.git + path: alibaba/cs/dedicated-kubernetes + type: remote workload: definition: apiVersion: terraform.core.oam.dev/v1beta1 diff --git a/vela-templates/addons/terraform/definitions/terraform-alibaba-ack.yaml b/vela-templates/addons/terraform/definitions/terraform-alibaba-ack.yaml index a0ffa90d0..7458a93ca 100644 --- a/vela-templates/addons/terraform/definitions/terraform-alibaba-ack.yaml +++ b/vela-templates/addons/terraform/definitions/terraform-alibaba-ack.yaml @@ -14,196 +14,6 @@ spec: kind: Configuration schematic: terraform: - configuration: | - module "kubernetes" { - source = "github.com/zzxwill/terraform-alicloud-kubernetes" - new_nat_gateway = true - vpc_name = var.vpc_name - vpc_cidr = var.vpc_cidr - vswitch_name_prefix = var.vswitch_name_prefix - vswitch_cidrs = var.vswitch_cidrs - master_instance_types = var.master_instance_types - worker_instance_types = var.worker_instance_types - k8s_pod_cidr = var.k8s_pod_cidr - k8s_service_cidr = var.k8s_service_cidr - k8s_worker_number = var.k8s_worker_number - cpu_core_count = var.cpu_core_count - memory_size = var.memory_size - zone_id = var.zone_id - k8s_version = var.k8s_version - k8s_name_prefix = var.k8s_name_prefix - } - ###################### - # Instance types variables - ###################### - variable "cpu_core_count" { - description = "CPU core count is used to fetch instance types." - type = number - default = 4 - } - variable "memory_size" { - description = "Memory size used to fetch instance types." - type = number - default = 8 - } - ###################### - # VPC variables - ###################### - variable "vpc_name" { - description = "The vpc name used to create a new vpc when 'vpc_id' is not specified. Default to variable `example_name`" - type = string - default = "tf-k8s-vpc" - } - variable "vpc_cidr" { - description = "The cidr block used to launch a new vpc when 'vpc_id' is not specified." - type = string - default = "10.0.0.0/8" - } - ###################### - # VSwitch variables - ###################### - variable "vswitch_name_prefix" { - type = string - description = "The vswitch name prefix used to create several new vswitches. Default to variable 'example_name'." - default = "tf-k8s-vsw" - } - variable "number_format" { - description = "The number format used to output." - type = string - default = "%02d" - } - variable "vswitch_ids" { - description = "List of existing vswitch id." - type = list - default = [] - } - variable "vswitch_cidrs" { - description = "List of cidr blocks used to create several new vswitches when 'vswitch_ids' is not specified." - type = list - default = [ - "10.1.0.0/16", - "10.2.0.0/16", - "10.3.0.0/16"] - } - variable "k8s_name_prefix" { - description = "The name prefix used to create several kubernetes clusters. Default to variable `example_name`" - type = string - default = "poc" - } - variable "new_nat_gateway" { - type = bool - description = "Whether to create a new nat gateway. In this template, a new nat gateway will create a nat gateway, eip and server snat entries." - default = true - } - variable "master_instance_types" { - description = "The ecs instance types used to launch master nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c5.xlarge", - "ecs.n4.xlarge", - # "ecs.n1.large", - # "ecs.sn1.large", - # "ecs.s6-c1m2.xlarge", - # "ecs.c6e.xlarge" - ] - } - variable "worker_instance_types" { - description = "The ecs instance types used to launch worker nodes." - type = list - default = [ - # hongkong - "ecs.sn1ne.xlarge", - # hongkong - "ecs.c6.xlarge", - # hongkong - "ecs.c4.xlarge", - # hongkong - "ecs.c6e.xlarge", - "ecs.n4.xlarge", - // "ecs.n1.large", - // "ecs.sn1.large", - // "ecs.s6-c1m2.xlarge" - ] - } - variable "node_cidr_mask" { - type = number - description = "The node cidr block to specific how many pods can run on single node. Valid values: [24-28]." - default = 24 - } - variable "enable_ssh" { - description = "Enable login to the node through SSH." - type = bool - default = true - } - variable "install_cloud_monitor" { - description = "Install cloud monitor agent on ECS." - type = bool - default = true - } - variable "cpu_policy" { - type = string - description = "kubelet cpu policy. Valid values: 'none','static'. Default to 'none'." - default = "none" - } - variable "proxy_mode" { - description = "Proxy mode is option of kube-proxy. Valid values: 'ipvs','iptables'. Default to 'iptables'." - type = string - default = "iptables" - } - variable "password" { - description = "The password of ECS instance." - type = string - default = "Just4Test" - } - variable "k8s_worker_number" { - description = "The number of worker nodes in kubernetes cluster." - type = number - default = 2 - } - # k8s_pod_cidr is only for flannel network - variable "k8s_pod_cidr" { - description = "The kubernetes pod cidr block. It cannot be equals to vpc's or vswitch's and cannot be in them." - type = string - default = "172.20.0.0/16" - } - variable "k8s_service_cidr" { - description = "The kubernetes service cidr block. It cannot be equals to vpc's or vswitch's or pod's and cannot be in them." - type = string - default = "192.168.0.0/16" - } - variable "k8s_version" { - description = "The version of the kubernetes version. Valid values: '1.16.6-aliyun.1','1.14.8-aliyun.1'. Default to '1.16.6-aliyun.1'." - type = string - default = "1.20.4-aliyun.1" - } - variable "zone_id" { - description = "Availability Zone ID" - type = string - default = "cn-hongkong-b" - # "cn-beijing-a" - } - output "name" { - value = module.kubernetes.name - } - output "kubeconfig" { - value = module.kubernetes.kubeconfig - } - output "cluster_ca_cert" { - value = module.kubernetes.cluster_ca_cert - } - output "client_cert" { - value = module.kubernetes.client_cert - } - output "client_key" { - value = module.kubernetes.client_key - } - output "api_server_internet" { - value = module.kubernetes.api_server_internet - } + configuration: https://github.com/kubevela-contrib/terraform-modules.git + type: remote + path: alibaba/cs/dedicated-kubernetes diff --git a/vela-templates/addons/terraform/template.yaml b/vela-templates/addons/terraform/template.yaml index 0ffd238ba..00097a854 100644 --- a/vela-templates/addons/terraform/template.yaml +++ b/vela-templates/addons/terraform/template.yaml @@ -33,7 +33,7 @@ spec: repoType: helm url: https://charts.kubevela.net/addons chart: terraform-controller - version: 0.2.4 + version: 0.2.5 {{ range .ResourceFiles }} - name: {{ .Name }} type: raw