OCI:在配置bastion代理的Kubernetes nodepool中创建节点



我正在尝试使用Terraform在Oracle Cloud Infrastructure中部署Kubernetes集群。

我希望每个节点部署(在私有子网)有堡垒代理插件在云代理激活。

但是我看不出如何定义实例的细节(在节点池实例中设置agent_config)。

我的代码,到现在为止是:

resource "oci_containerengine_cluster" "generated_oci_containerengine_cluster" {
compartment_id = var.cluster_compartment
endpoint_config {
is_public_ip_enabled = "true"
subnet_id = oci_core_subnet.oke_public_api.id
}
kubernetes_version = var.kubernetes_version
name = "josealbarran_labcloudnative_oke"
options {
kubernetes_network_config {
pods_cidr = "10.244.0.0/16"
services_cidr = "10.96.0.0/16"
}
service_lb_subnet_ids = [oci_core_subnet.oke_public_lb.id]
}
vcn_id = var.cluster_vcn
}
# Check doc: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/containerengine_node_pool
resource "oci_containerengine_node_pool" "node_pool01" {
cluster_id = "${oci_containerengine_cluster.generated_oci_containerengine_cluster.id}"
compartment_id = var.cluster_compartment
initial_node_labels {
key = "name"
value = "pool01"
}
kubernetes_version = var.kubernetes_version
name = "lab_cloud_native_oke_pool01"
node_config_details {
size = "${length(data.oci_identity_availability_domains.ads.availability_domains)}"
dynamic "placement_configs" {
for_each = data.oci_identity_availability_domains.ads.availability_domains[*].name
content {
availability_domain = placement_configs.value
subnet_id = oci_core_subnet.oke_private_worker.id
}
}

}
node_shape = "VM.Standard.A1.Flex"
node_shape_config {
memory_in_gbs = "16"
ocpus = "1"
}
node_source_details {
image_id = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaalgodii3qx3mfasp6ai22bja7mabfwsxiwkzxx7lhdfdbbuyqcznq"
source_type = "IMAGE"
}
ssh_public_key = "ssh-rsa AAAAB3xxxxxxxx......."

timeouts {
create = "60m"
delete = "90m"
}
}

您可以使用">cloudinit_config";在OCI的OKE节点池中运行自定义脚本。

second_script_template = templatefile("${path.module}/cloudinit/second.template.sh",{})

更多类似

的脚本
data "cloudinit_config" "worker" {
gzip          = false
base64_encode = true
part {
filename     = "worker.sh"
content_type = "text/x-shellscript"
content      = local.worker_script_template
}
part {
filename     = "second.sh"
content_type = "text/x-shellscript"
content      = local.second_script_template
}
part {
filename     = "third.sh"
content_type = "text/x-shellscript"
content      = local.third_script_template
}
}

参考:https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/instructions.adoc#14-configuring-cloud-init-for-the-nodepools

如果你想编辑默认脚本:https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/cloudinit.adoc

最新更新