Skip to content

Commit c11be02

Browse files
authored
Merge pull request #10 from zilliztech/feat/byoci-private
byo-infra-private
2 parents 2679cff + 5e94d0f commit c11be02

File tree

17 files changed

+198
-377
lines changed

17 files changed

+198
-377
lines changed

examples/aws-project-byoc-i/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ data "zillizcloud_byoc_op_project_settings" "this" {
33
data_plane_id = var.dataplane_id
44
}
55

6+
data "zillizcloud_external_id" "current" {}
67

78
module "aws_byoc_op" {
89
source = "../../modules/aws_byoc_op"
910
aws_region = trimprefix(data.zillizcloud_byoc_op_project_settings.this.region, "aws-")
1011

1112
vpc_cidr = var.vpc_cidr
1213
enable_private_link = var.enable_private_link
13-
eks_access_cidrs = [
14-
"0.0.0.0/0"
15-
]
14+
1615
dataplane_id = data.zillizcloud_byoc_op_project_settings.this.data_plane_id
1716
k8s_node_groups = data.zillizcloud_byoc_op_project_settings.this.node_quotas
1817
agent_config = {
1918
auth_token = data.zillizcloud_byoc_op_project_settings.this.op_config.token
2019
tag = data.zillizcloud_byoc_op_project_settings.this.op_config.agent_image_url
2120
}
2221

22+
external_id = data.zillizcloud_external_id.current.id
2323
}
2424

2525
resource "zillizcloud_byoc_op_project_agent" "this" {

modules/aws_byoc_op/cloud-agent/Chart.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

modules/aws_byoc_op/cloud-agent/templates/cloud-agent-cm.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

modules/aws_byoc_op/cloud-agent/templates/cloud-agent-deployment.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.

modules/aws_byoc_op/cloud-agent/values.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

modules/aws_byoc_op/conf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ vpce_service_ids:
44
private_zone_name: byoc-uat.zillizcloud.com
55
agent_config:
66
server_host: zilliz-byoc-us.byoc-uat.zillizcloud.com
7-
repository: 306787409409.dkr.ecr.us-west-2.amazonaws.com/zilliz-byoc/vdc/cloud-agent
7+
repository: 965570967084.dkr.ecr.us-west-2.amazonaws.com/zilliz-byoc/vdc/cloud-agent

modules/aws_byoc_op/data.tf

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,56 @@ locals {
2020

2121
// input parameters:
2222
vpc_cidr = var.vpc_cidr
23-
region = var.aws_region
24-
23+
region = var.aws_region
24+
2525
dataplane_id = var.dataplane_id
2626

2727
// node groups
2828

2929
k8s_node_groups = var.k8s_node_groups
3030

31-
account_id = data.aws_caller_identity.current.account_id
31+
account_id = data.aws_caller_identity.current.account_id
32+
agent_config_json = jsonencode(var.agent_config)
33+
34+
boot_config = {
35+
EKS_CLUSTER_NAME = aws_eks_cluster.zilliz_byoc_cluster.name
36+
DATAPLANE_ID = var.dataplane_id
37+
REGION = var.aws_region
38+
AGENT_CONFIG = local.agent_config_json
39+
MAINTAINCE_ROLE = aws_iam_role.maintaince_role.arn
40+
OP_CONFIG = jsonencode(local.config)
41+
EXTERNAL_ID = var.external_id
42+
enable_private_link = var.enable_private_link
43+
}
44+
45+
boot_config_json = jsonencode(local.boot_config)
46+
47+
core_user_data = base64encode(<<-EOF
48+
MIME-Version: 1.0
49+
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
3250
51+
--==MYBOUNDARY==
52+
Content-Type: text/x-shellscript; charset="us-ascii"
53+
54+
#!/bin/bash
55+
set -e
56+
echo "zilliz init start"
57+
TAG=$(aws ecr describe-images \
58+
--registry-id 965570967084 \
59+
--region us-west-2 \
60+
--repository-name zilliz-byoc/infra/byoc-booter \
61+
--query 'sort_by(imageDetails,&imagePushedAt)[-1].imageTags[0]' \
62+
--output text)
63+
64+
ZILLIZ_BYOC_IMAGE=965570967084.dkr.ecr.us-west-2.amazonaws.com/zilliz-byoc/infra/byoc-booter:$TAG
65+
66+
ctr image pull --user AWS:$(aws ecr get-login-password --region us-west-2) $ZILLIZ_BYOC_IMAGE
67+
ctr run --rm --net-host --privileged --env BOOT_CONFIG='${local.boot_config_json}' $ZILLIZ_BYOC_IMAGE zilliz-bootstrap
68+
echo "zilliz init result $?"
69+
70+
--==MYBOUNDARY==--
3371
72+
EOF
73+
)
74+
3475
}

modules/aws_byoc_op/eks.tf

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "aws_eks_cluster" "zilliz_byoc_cluster" {
1616
# version = "1.31"
1717

1818
access_config {
19-
authentication_mode = "CONFIG_MAP"
19+
authentication_mode = "API"
2020
bootstrap_cluster_creator_admin_permissions = true
2121
}
2222

@@ -31,8 +31,7 @@ resource "aws_eks_cluster" "zilliz_byoc_cluster" {
3131

3232
vpc_config {
3333
endpoint_private_access = true
34-
endpoint_public_access = true
35-
public_access_cidrs = var.eks_access_cidrs
34+
endpoint_public_access = false
3635
security_group_ids = [
3736
aws_security_group.zilliz_byoc_sg.id
3837
]
@@ -45,7 +44,7 @@ resource "aws_eks_cluster" "zilliz_byoc_cluster" {
4544
resource "aws_eks_addon" "kube-proxy" {
4645
addon_name = "kube-proxy"
4746
# addon_version = "v1.27.6-eksbuild.2"
48-
cluster_name = local.dataplane_id
47+
cluster_name = aws_eks_cluster.zilliz_byoc_cluster.name
4948

5049
depends_on = [ aws_eks_cluster.zilliz_byoc_cluster ]
5150

@@ -96,3 +95,23 @@ resource "aws_iam_openid_connect_provider" "eks" {
9695
}
9796
}
9897

98+
resource "aws_eks_access_policy_association" "example" {
99+
cluster_name = aws_eks_cluster.zilliz_byoc_cluster.name
100+
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
101+
principal_arn = aws_iam_role.maintaince_role.arn
102+
103+
access_scope {
104+
type = "cluster"
105+
}
106+
107+
}
108+
109+
resource "aws_eks_access_entry" "test" {
110+
cluster_name = aws_eks_cluster.zilliz_byoc_cluster.name
111+
principal_arn = aws_iam_role.maintaince_role.arn
112+
type = "STANDARD"
113+
114+
tags = {
115+
"Vendor" = "zilliz-byoc"
116+
}
117+
}

0 commit comments

Comments
 (0)