From 46068dfe68d54c4aa3b69ec9b89acd89d579ddaa Mon Sep 17 00:00:00 2001 From: zzxwill Date: Mon, 19 Jul 2021 10:19:24 +0800 Subject: [PATCH 1/2] Make more outputs for ack Make more outputs like `cluster_ca_cert`, `client_cert` for ack --- controllers/configuration_controller.go | 4 ++-- examples/alibaba/cs/configuration_ack.yaml | 20 +++++++++++++++++++- examples/tf-native/alibaba/cs/ack.tf | 18 ++++++++++++++++-- examples/tf-native/alibaba/hcl/rds.tf | 6 +++--- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/controllers/configuration_controller.go b/controllers/configuration_controller.go index c73c289b..ed29e59a 100644 --- a/controllers/configuration_controller.go +++ b/controllers/configuration_controller.go @@ -42,9 +42,9 @@ import ( ) const ( - terraformInitContainerImg = "registry.cn-hangzhou.aliyuncs.com/vela/busybox:latest" + terraformInitContainerImg = "busybox:latest" // TerraformImage is the Terraform image which can run `terraform init/plan/apply` - terraformImage = "zzxwill/docker-terraform:1.0.3.alpha-2" + terraformImage = "oamdev/docker-terraform:1.0.3-beta.1" TerraformWorkspace = "default" ) diff --git a/examples/alibaba/cs/configuration_ack.yaml b/examples/alibaba/cs/configuration_ack.yaml index 9f172eaf..3a243e24 100644 --- a/examples/alibaba/cs/configuration_ack.yaml +++ b/examples/alibaba/cs/configuration_ack.yaml @@ -88,7 +88,7 @@ spec: variable "k8s_name_prefix" { description = "The name prefix used to create several kubernetes clusters. Default to variable `example_name`" type = string - default = "poc1023" + default = "poc" } variable "new_nat_gateway" { @@ -212,6 +212,24 @@ spec: 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 + } + + + backend: diff --git a/examples/tf-native/alibaba/cs/ack.tf b/examples/tf-native/alibaba/cs/ack.tf index ebf3fa15..7e97740b 100644 --- a/examples/tf-native/alibaba/cs/ack.tf +++ b/examples/tf-native/alibaba/cs/ack.tf @@ -1,5 +1,3 @@ - - module "kubernetes" { source = "github.com/zzxwill/terraform-alicloud-kubernetes" @@ -207,3 +205,19 @@ output "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 +} diff --git a/examples/tf-native/alibaba/hcl/rds.tf b/examples/tf-native/alibaba/hcl/rds.tf index b62a0efc..82e3ce08 100644 --- a/examples/tf-native/alibaba/hcl/rds.tf +++ b/examples/tf-native/alibaba/hcl/rds.tf @@ -33,12 +33,12 @@ variable "instance_name" { variable "account_name" { description = "RDS instance user account name" - type = "string" + type = string default = "oam" } variable "password" { description = "RDS instance account password" - type = "string" + type = string default = "Xyfff83jfewGGfaked" -} \ No newline at end of file +} From ab68043314247b276d66d6b8a003c3c3ab908c54 Mon Sep 17 00:00:00 2001 From: zzxwill Date: Mon, 19 Jul 2021 11:19:33 +0800 Subject: [PATCH 2/2] add new release --- Makefile | 4 ++-- chart/Chart.yaml | 2 +- chart/templates/tf_controller_role_binding.yaml | 2 +- chart/values.yaml | 6 ++---- controllers/util/validation.go | 2 +- controllers/util/validation_test.go | 1 - hack/prepare-alibaba-credentials.sh | 3 ++- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index b62898c5..e02b197d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Image URL to use all building/pushing image targets -IMG ?= oamdev/terraform-controller:latest +IMG ?= oamdev/terraform-controller:0.1.13 # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) CRD_OPTIONS ?= "crd:trivialVersions=true" @@ -127,4 +127,4 @@ ifeq (, $(shell which goimports)) GOIMPORTS=$(GOBIN)/goimports else GOIMPORTS=$(shell which goimports) -endif \ No newline at end of file +endif diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 62bd17a7..240f012f 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 name: terraform-controller-chart -version: 0.1.12 +version: 0.1.13 description: A Kubernetes Terraform controller home: https://github.com/oam-dev/terraform-controller diff --git a/chart/templates/tf_controller_role_binding.yaml b/chart/templates/tf_controller_role_binding.yaml index d7ced345..9fa8fef3 100644 --- a/chart/templates/tf_controller_role_binding.yaml +++ b/chart/templates/tf_controller_role_binding.yaml @@ -16,7 +16,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: tf-controller-read-provider-creds-rolebinding - namespace: {{ .Values.credentialsNamespace }} + namespace: {{ .Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role diff --git a/chart/values.yaml b/chart/values.yaml index 3160bf01..a41a0688 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1,9 +1,7 @@ replicaCount: 1 -version: 0.1.12 +version: 0.1.13 image: - name: oamdev/terraform-controller:latest + name: oamdev/terraform-controller:0.1.13 imagePullPolicy: Always - -credentialsNamespace: vela-system diff --git a/controllers/util/validation.go b/controllers/util/validation.go index 4077d241..8a777c5e 100644 --- a/controllers/util/validation.go +++ b/controllers/util/validation.go @@ -48,7 +48,7 @@ func ValidConfiguration(configuration *v1beta1.Configuration, controllerNamespac } // CompareTwoContainerEnvs compares two slices of v1.EnvVar -func CompareTwoContainerEnvs(s1 []v1.EnvVar, s2 []v1.EnvVar) bool{ +func CompareTwoContainerEnvs(s1 []v1.EnvVar, s2 []v1.EnvVar) bool { less := func(env1 v1.EnvVar, env2 v1.EnvVar) bool { return env1.Name < env2.Name } diff --git a/controllers/util/validation_test.go b/controllers/util/validation_test.go index 81334507..bb563711 100644 --- a/controllers/util/validation_test.go +++ b/controllers/util/validation_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" v1 "k8s.io/api/core/v1" - ) func TestCompareTwoContainerEnvs(t *testing.T) { diff --git a/hack/prepare-alibaba-credentials.sh b/hack/prepare-alibaba-credentials.sh index e403c779..b0ea2439 100644 --- a/hack/prepare-alibaba-credentials.sh +++ b/hack/prepare-alibaba-credentials.sh @@ -1,5 +1,6 @@ #!/bin/bash echo "accessKeyID: ${ALICLOUD_ACCESS_KEY}\naccessKeySecret: ${ALICLOUD_SECRET_KEY}\nsecurityToken: ${ALICLOUD_SECURITY_TOKEN}" > alibaba-credentials.conf +kubectl create namespace vela-system kubectl create secret generic alibaba-account-creds -n vela-system --from-file=credentials=alibaba-credentials.conf -rm -f alibaba-credentials.conf \ No newline at end of file +rm -f alibaba-credentials.conf