-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[wip] Alibaba recommitted #5291
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b69ed83
pkg/types: add Alibaba platform
bd233 41764eb
pkg/asset: add assets for Alibaba platform
bd233 74418c3
pkg/terraform, pkg/tfvars: add support for Alibaba
bd233 1f96dd1
data/data/alibabacloud: Terraform configuration
bd233 067e5b4
pkg/destroy: add Alibaba destroy code
bd233 230a171
go.mod: required modules for Alibaba
bd233 e1d3c17
Alibaba: update vendor
bd233 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| locals { | ||
| description = "Created By OpenShift Installer" | ||
| prefix = var.cluster_id | ||
| tags = merge( | ||
| { | ||
| "OCP" = "ISV Integration", | ||
| "kubernetes.io/cluster/${var.cluster_id}" = "owned" | ||
| }, | ||
| var.ali_resource_tags, | ||
| ) | ||
| system_disk_size = 120 | ||
| system_disk_category = "cloud_essd" | ||
| } | ||
|
|
||
| provider "alicloud" { | ||
| access_key = var.ali_access_key | ||
| secret_key = var.ali_secret_key | ||
| region = var.ali_region_id | ||
| } | ||
|
|
||
| data "alicloud_instances" "bootstrap_data" { | ||
| ids = [alicloud_instance.bootstrap.id] | ||
| } | ||
|
|
||
| # Using this data source can enable OSS service automatically. | ||
| data "alicloud_oss_service" "open" { | ||
| enable = "On" | ||
| } | ||
|
|
||
| resource "alicloud_oss_bucket" "bucket" { | ||
| bucket = var.ali_ignition_bucket | ||
| acl = "private" | ||
| tags = merge( | ||
| { | ||
| "Name" = "${local.prefix}-bucket" | ||
| }, | ||
| local.tags, | ||
| ) | ||
| } | ||
|
|
||
| resource "alicloud_oss_bucket_object" "ignition_file" { | ||
| bucket = alicloud_oss_bucket.bucket.id | ||
| key = "bootstrap.ign" | ||
| source = var.ignition_bootstrap_file | ||
| acl = "private" | ||
| } | ||
|
|
||
| resource "alicloud_ram_role" "role" { | ||
| name = "${local.prefix}-role-bootstrap" | ||
| document = <<EOF | ||
| { | ||
| "Statement": [ | ||
| { | ||
| "Action": "sts:AssumeRole", | ||
| "Effect": "Allow", | ||
| "Principal": { | ||
| "Service": [ | ||
| "ecs.aliyuncs.com" | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "Version": "1" | ||
| } | ||
| EOF | ||
| description = local.description | ||
| } | ||
|
|
||
| resource "alicloud_ram_policy" "role_policy" { | ||
| policy_name = "${local.prefix}-policy-bootstrap" | ||
| policy_document = <<EOF | ||
| { | ||
| "Statement": [ | ||
| { | ||
| "Action": [ | ||
| "ecs:Describe*", | ||
| "ecs:AttachDisk", | ||
| "ecs:DetachDisk" | ||
| ], | ||
| "Effect": "Allow", | ||
| "Resource": [ | ||
| "*" | ||
| ] | ||
| } | ||
| ], | ||
| "Version": "1" | ||
| } | ||
| EOF | ||
| } | ||
|
|
||
| resource "alicloud_ram_role_policy_attachment" "attach" { | ||
| policy_name = alicloud_ram_policy.role_policy.name | ||
| policy_type = alicloud_ram_policy.role_policy.type | ||
| role_name = alicloud_ram_role.role.name | ||
| } | ||
|
|
||
| resource "alicloud_security_group" "sg_bootstrap" { | ||
| resource_group_id = var.ali_resource_group_id | ||
| name = "${local.prefix}_sg_bootstrap" | ||
| description = local.description | ||
| vpc_id = var.vpc_id | ||
| tags = merge( | ||
| { | ||
| "Name" = "${local.prefix}-sg-bootstrap" | ||
| }, | ||
| local.tags, | ||
| ) | ||
| } | ||
|
|
||
| resource "alicloud_security_group_rule" "sg_rule_ssh" { | ||
| description = local.description | ||
| security_group_id = alicloud_security_group.sg_bootstrap.id | ||
| type = "ingress" | ||
| ip_protocol = "tcp" | ||
| nic_type = "intranet" | ||
| policy = "accept" | ||
| port_range = "22/22" | ||
| cidr_ip = "0.0.0.0/0" | ||
| } | ||
|
|
||
| resource "alicloud_security_group_rule" "sg_rule_journald_gateway" { | ||
| description = local.description | ||
| security_group_id = alicloud_security_group.sg_bootstrap.id | ||
| type = "ingress" | ||
| ip_protocol = "tcp" | ||
| nic_type = "intranet" | ||
| policy = "accept" | ||
| port_range = "19531/19531" | ||
| cidr_ip = "0.0.0.0/0" | ||
| } | ||
|
|
||
| resource "alicloud_instance" "bootstrap" { | ||
| resource_group_id = var.ali_resource_group_id | ||
|
|
||
| host_name = "${local.prefix}-bootstrap" | ||
| instance_name = "${local.prefix}-bootstrap" | ||
| instance_type = var.ali_bootstrap_instance_type | ||
| image_id = var.ali_image_id | ||
| vswitch_id = var.vswitch_ids[0] | ||
| security_groups = [alicloud_security_group.sg_bootstrap.id, var.sg_master_id] | ||
| internet_max_bandwidth_out = 5 | ||
| role_name = alicloud_ram_role.role.name | ||
|
|
||
| system_disk_name = "${local.prefix}_sys_disk-bootstrap" | ||
| system_disk_description = local.description | ||
| system_disk_category = local.system_disk_category | ||
| system_disk_size = local.system_disk_size | ||
|
|
||
| user_data = var.ali_bootstrap_stub_ignition | ||
| tags = merge( | ||
| { | ||
| "Name" = "${local.prefix}-bootstrap" | ||
| }, | ||
| local.tags, | ||
| ) | ||
| } | ||
|
|
||
| resource "alicloud_slb_backend_server" "slb_attachment_bootstraps" { | ||
| count = length(var.slb_ids) | ||
|
|
||
| load_balancer_id = var.slb_ids[count.index] | ||
| backend_servers { | ||
| server_id = alicloud_instance.bootstrap.id | ||
| weight = 90 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| output "bootstrap_public_ip" { | ||
| value = data.alicloud_instances.bootstrap_data.instances.0.public_ip | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| variable "vpc_id" { | ||
| type = string | ||
| description = "The VPC id of the bootstrap ECS." | ||
| } | ||
|
|
||
| variable "vswitch_ids" { | ||
| type = list(string) | ||
| description = "The VSwitch id of the bootstrap ECS." | ||
| } | ||
|
|
||
| variable "slb_ids" { | ||
| type = list(string) | ||
| description = "The load balancer IDs of the bootstrap ECS." | ||
| } | ||
|
|
||
| variable "sg_master_id" { | ||
| type = string | ||
| description = "The security group ID of the master ECS." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| locals { | ||
| description = "Created By OpenShift Installer" | ||
| tags = merge( | ||
| { | ||
| "OCP" = "ISV Integration", | ||
| "kubernetes.io/cluster/${var.cluster_id}" = "owned" | ||
| }, | ||
| var.ali_resource_tags, | ||
| ) | ||
| } | ||
|
|
||
| provider "alicloud" { | ||
| access_key = var.ali_access_key | ||
| secret_key = var.ali_secret_key | ||
| region = var.ali_region_id | ||
| } | ||
|
|
||
| module "vpc" { | ||
| source = "./vpc" | ||
| cluster_id = var.cluster_id | ||
| region_id = var.ali_region_id | ||
| zone_ids = var.ali_zone_ids | ||
| nat_gateway_zone_id = var.ali_nat_gateway_zone_id | ||
| resource_group_id = var.ali_resource_group_id | ||
| vpc_cidr_block = var.machine_v4_cidrs[0] | ||
| tags = local.tags | ||
| } | ||
|
|
||
| module "pvtz" { | ||
| source = "./privatezone" | ||
| cluster_id = var.cluster_id | ||
| resource_group_id = var.ali_resource_group_id | ||
| vpc_id = module.vpc.vpc_id | ||
| cluster_domain = var.cluster_domain | ||
| base_domain = var.base_domain | ||
| slb_external_ip = module.vpc.slb_external_ip | ||
| slb_internal_ip = module.vpc.slb_internal_ip | ||
| master_count = length(var.ali_zone_ids) | ||
| master_ips = module.master.master_ecs_private_ips | ||
| tags = local.tags | ||
| } | ||
|
|
||
| module "ram" { | ||
| source = "./ram" | ||
| cluster_id = var.cluster_id | ||
| tags = local.tags | ||
| } | ||
|
|
||
| module "master" { | ||
| source = "./master" | ||
| cluster_id = var.cluster_id | ||
| resource_group_id = var.ali_resource_group_id | ||
| vpc_id = module.vpc.vpc_id | ||
| vswitch_ids = module.vpc.vswitch_ids | ||
| sg_id = module.vpc.sg_master_id | ||
| slb_ids = module.vpc.slb_ids | ||
| instance_type = var.ali_master_instance_type | ||
| image_id = var.ali_image_id | ||
| system_disk_size = var.ali_system_disk_size | ||
| system_disk_category = var.ali_system_disk_category | ||
| user_data_ign = var.ignition_master | ||
| role_name = module.ram.role_master_name | ||
| tags = local.tags | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| locals { | ||
| description = "Created By OpenShift Installer" | ||
| prefix = var.cluster_id | ||
| } | ||
|
|
||
| data "alicloud_instances" "master_data" { | ||
| ids = alicloud_instance.master.*.id | ||
| } | ||
|
|
||
| resource "alicloud_instance" "master" { | ||
| count = length(var.vswitch_ids) | ||
| resource_group_id = var.resource_group_id | ||
|
|
||
| host_name = "${local.prefix}-master-${count.index}" | ||
| instance_name = "${local.prefix}-master-${count.index}" | ||
| instance_type = var.instance_type | ||
| image_id = var.image_id | ||
| internet_max_bandwidth_out = 0 | ||
|
|
||
| vswitch_id = var.vswitch_ids[count.index] | ||
| security_groups = [var.sg_id] | ||
| role_name = var.role_name | ||
|
|
||
| system_disk_name = "${local.prefix}_sys_disk-master-${count.index}" | ||
| system_disk_description = local.description | ||
| system_disk_category = var.system_disk_category | ||
| system_disk_size = var.system_disk_size | ||
|
|
||
| user_data = base64encode(var.user_data_ign) | ||
| tags = merge( | ||
| { | ||
| "Name" = "${local.prefix}-master-${count.index}" | ||
| }, | ||
| var.tags, | ||
| ) | ||
| } | ||
|
|
||
| resource "alicloud_slb_backend_server" "slb_attachment_masters" { | ||
| count = "${length(var.slb_ids) * length(alicloud_instance.master.*.id)}" | ||
| load_balancer_id = "${element(var.slb_ids, ceil(count.index / length(alicloud_instance.master.*.id)))}" | ||
| backend_servers { | ||
| server_id = "${element(alicloud_instance.master.*.id, count.index)}" | ||
| weight = 90 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| output "master_ecs_ids" { | ||
| value = alicloud_instance.master.*.id | ||
| } | ||
|
|
||
| output "master_ecs_private_ips" { | ||
| value = { for ecs in data.alicloud_instances.master_data.instances : ecs.name => ecs.private_ip } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| variable "cluster_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "resource_group_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "vpc_id" { | ||
| type = string | ||
| description = "The VPC ID of the master ECS." | ||
| } | ||
|
|
||
| variable "vswitch_ids" { | ||
| type = list(string) | ||
| description = "The VSwitch IDs of the master ECS. Example: [vsw-xxx1, vsw-xxx2, vsw-xxx3]" | ||
| } | ||
|
|
||
| variable "sg_id" { | ||
| type = string | ||
| description = "The security group ID of the master ECS." | ||
| } | ||
|
|
||
| variable "slb_ids" { | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "instance_type" { | ||
| type = string | ||
| description = "The instance type of the master ECS." | ||
| } | ||
|
|
||
| variable "image_id" { | ||
| type = string | ||
| description = "The image ID of the master ECS." | ||
| } | ||
|
|
||
| variable "system_disk_size" { | ||
| type = number | ||
| description = "The system disk size of the master ECS." | ||
| } | ||
|
|
||
| variable "system_disk_category" { | ||
| type = string | ||
| description = "The system disk category of the master ECS.Valid values are cloud_efficiency, cloud_ssd, cloud_essd. Default value is cloud_essd." | ||
| default = "cloud_essd" | ||
| } | ||
|
|
||
| variable "role_name" { | ||
| type = string | ||
| description = "Instance RAM role name. The name is provided and maintained by RAM." | ||
| } | ||
|
|
||
| variable "user_data_ign" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "tags" { | ||
| type = map(string) | ||
| default = {} | ||
| description = "Tags to be applied to created resources." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| output "vpc_id" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need an output named "control_plane_ips", too. |
||
| value = module.vpc.vpc_id | ||
| } | ||
|
|
||
| output "vswitch_ids" { | ||
| value = module.vpc.vswitch_ids | ||
| } | ||
|
|
||
| output "slb_ids" { | ||
| value = module.vpc.slb_ids | ||
| } | ||
|
|
||
| output "sg_master_id" { | ||
| value = module.vpc.sg_master_id | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "pvtz" a very common abbreviation in the alibaba domain? If not, then I would rather see this module named without abbreviations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "pvtz" is only used in some development fields, and I think it is more appropriate to modify it to "dns".