繁体   English   中英

在 vSphere 中自动创建 Kubernetes 集群

[英]Automate Kubernetes Cluster creation in vSphere

我想要一个可用于在 vSphere 中自动创建 kubernetes 集群的脚本/工具/插件。 我想创建 3 个虚拟机,一个主节点和两个工作节点。 有没有一种方法可以使这种创建自动化? 或者有没有一种方法我不需要单独配置每个虚拟机?

自动化 vSphrere 集群创建/管理的方法之一是使用terraform

有一个名为Terraform vSphere 模块的模块 - 它包含资源vsphere_virtual_machine中可用的大部分高级功能

Terraform vSphere 模块

此 Terraform 模块可部署单个或多个虚拟机类型(Linux/Windows),具有以下功能:

  • 能够指定 Linux 或 Windows VM 自定义。
  • 能够为 VM 添加多个网卡 能够分配标签和自定义变量。
  • 能够为 vm 配置高级功能。
  • 能够部署数据存储或数据存储集群。 向 VM 添加额外的数据磁盘(最多 15 个)。 数据磁盘的不同数据存储 (datastore_id)。 每个磁盘不同的 scsi_controllers,包括数据磁盘。
  • 使用变量 vm_depends_on 和 tag_depends_on 定义依赖的能力

注意:要使模块正常工作,它需要与 vSphere 中现有资源相对应的所需变量数量。 请参阅变量部分以获取所需变量的列表。

例子:

# Configure the VMware vSphere Provider
provider "vsphere" {
  user           = "fill"
  password       = "fill"
  vsphere_server = "fill" 

  # if you have a self-signed cert
  allow_unverified_ssl = true
}

# Deploy 2 linux VMs
module "example-server-linuxvm" {
  source        = "Terraform-VMWare-Modules/vm/vsphere"
  version       = "X.X.X"
  vmtemp        = "VM Template Name (Should Alrerady exist)"
  instances     = 2
  vmname        = "example-server-linux"
  vmrp          = "esxi/Resources - or name of a resource pool"
  network = {
    "Name of the Port Group in vSphere" = ["10.13.113.2", "10.13.113.3"] # To use DHCP create Empty list ["",""]
  }
  vmgateway         = "10.13.113.1"
  dc        = "Datacenter"
  datastore = "Data Store name(use ds_cluster for datastore cluster)"
}

更多信息和示例:

1. 使用基础架构即代码自动化 VMware 部署

2. 用Terraform构建vSphere虚拟机

3.如何安装 Terraform 以用于 vSphere

4. vsphere_virtual_machine terraform 模块


您还可以查看Hashicorp Packer方面,将其与 Terraform 一起使用。

打包机是:

一个免费的开源工具,用于在多个平台(Azure、AWS、Google Cloud、VMware、OpenShift 等)创建镜像或虚拟机,非常适合创建模板、在多个环境或演示中构建相同的镜像

你的初步计划是:

1. Create VM templates with packer (You are here)
2. Create nodes with terraform
3. Create clusters with kubeadm

更多信息在这里:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM