Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): fix terraform scripts #13

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chart/templates/cello-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data:
],
{{- end -}}
{{- if .Values.cello.iamRole }}
"ramRole: "{{.Values.cello.iamRole | quote }}",
"ramRole": "{{.Values.cello.iamRole | quote }}",
{{- end }}
"credentialAccessKeyId": "{{ .Values.cello.accessKey }}",
"credentialAccessKeySecret": "{{ .Values.cello.secretKey }}",
Expand Down
4 changes: 2 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Edit cluster variables in file `ci/tf/example.tfvars` and run:
``` bash
./provision.sh
```
kubectl config file locates at `ci/kube/config-public`.
kubectl config file locates at `ci/playbook/kube/config-public`.

```bash
export KUBECONFIG=ci/kube/config-public
export KUBECONFIG=ci/playbook/kube/config-public
kubectl get nodes -A -o wide
```

Expand Down
1 change: 0 additions & 1 deletion ci/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pushd tf > /dev/null
terraform init $extra_args
terraform apply -auto-approve -var-file=example.tfvars
popd > /dev/null

pushd playbook > /dev/null
ansible-playbook -i ../tf/hosts.yaml k8s.yaml
popd > /dev/null
2 changes: 2 additions & 0 deletions ci/tf/example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ key_pair_name=""
key_pair_path=""
zone_id=""
region=""
instance_type="ecs.g3i.xlarge"
vpc_name="my-ci-test"
vpc_cidr="172.16.0.0/16"
node_subnet_name="my-ci-node-subnet"
Expand All @@ -14,3 +15,4 @@ control_plane_node_name="my-ci-control-plane"
worker_node_name="my-ci-worker"
worker2_node_name="my-ci-worker2"
control_eip_name="my-ci-eip"
project_name="default"
1 change: 1 addition & 0 deletions ci/tf/hosts.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ all:
ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p -q -i ${key_pair_path} root@${jump_host}"
ansible_ssh_private_key_file: ${key_pair_path}
host_key_checking: false
ansible_python_interpreter: python3
ansible_user: root
k8s_api_server_ip: ${jump_host}
21 changes: 17 additions & 4 deletions ci/tf/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ variable "zone_id" {
type = string
}

variable "instance_type" {
type = string
}

variable "vpc_name" {
type = string
}
Expand Down Expand Up @@ -72,6 +76,11 @@ variable "control_eip_name" {
type = string
}


variable "project_name" {
type = string
}

# Configure the Volcengine Provider
provider "volcengine" {
access_key = var.access_key
Expand All @@ -82,6 +91,7 @@ provider "volcengine" {
resource "volcengine_vpc" "vpc_cello" {
vpc_name = var.vpc_name
cidr_block = var.vpc_cidr
project_name = var.project_name
enable_ipv6 = true
}

Expand Down Expand Up @@ -121,7 +131,7 @@ resource "volcengine_security_group_rule" "sg_rule_allow_api_server" {
resource "volcengine_ecs_instance" "control_plane" {
zone_id = var.zone_id
image_id = "image-ybqi99s7yq8rx7mnk44b"
instance_type = "ecs.g2i.xlarge"
instance_type = var.instance_type
instance_name = var.control_plane_node_name
description = var.control_plane_node_name
host_name = var.control_plane_node_name
Expand All @@ -132,13 +142,13 @@ resource "volcengine_ecs_instance" "control_plane" {
subnet_id = volcengine_subnet.subnet_node.id
ipv6_address_count = 1
security_group_ids = [data.volcengine_security_groups.sg_default.security_groups[0].id]

project_name = var.project_name
}

resource "volcengine_ecs_instance" "worker" {
zone_id = var.zone_id
image_id = "image-ybqi99s7yq8rx7mnk44b"
instance_type = "ecs.g2i.xlarge"
instance_type = var.instance_type
instance_name = var.worker_node_name
description = var.worker_node_name
host_name = var.worker_node_name
Expand All @@ -149,12 +159,13 @@ resource "volcengine_ecs_instance" "worker" {
subnet_id = volcengine_subnet.subnet_node.id
ipv6_address_count = 1
security_group_ids = [data.volcengine_security_groups.sg_default.security_groups[0].id]
project_name = var.project_name
}

resource "volcengine_ecs_instance" "worker2" {
zone_id = var.zone_id
image_id = "image-ybqi99s7yq8rx7mnk44b"
instance_type = "ecs.g2i.xlarge"
instance_type = var.instance_type
instance_name = var.worker2_node_name
description = var.worker2_node_name
host_name = var.worker2_node_name
Expand All @@ -165,13 +176,15 @@ resource "volcengine_ecs_instance" "worker2" {
subnet_id = volcengine_subnet.subnet_node.id
ipv6_address_count = 1
security_group_ids = [data.volcengine_security_groups.sg_default.security_groups[0].id]
project_name = var.project_name
}

resource "volcengine_eip_address" "control_plane" {
billing_type = "PostPaidByBandwidth"
bandwidth = 10
name = var.control_eip_name
description = "EIP for control-plane node"
project_name = var.project_name
}

resource "volcengine_eip_associate" "foo" {
Expand Down
Loading