利用Terraform 部署 Kubernetes集群最佳实践
1. install Terraform
Download the Terraform at ( https://www.terraform.io/downloads.html?spm=a2c4g.11186623.2.4.21DyQW), you can choose the right version and platform. This document takes Terraform installed on Linux as an example. Under the /root/terraform path:
- wget https://releases.hashicorp.com/terraform/0.11.6/terraform_0.11.6_linux_amd64.zip
- unzip the file, you will get a binary file terraform.
- create the following entries under /etc/profile, add the path /root/terraform of binary files to PATH environment variables.
2. install Terraform-provider of aliyun
official download address: https://github.com/alibaba/terraform-provider/releases?spm=a2c4g.11186623.2.5.qK1FGC
Under the /root/terraform path:
1.
[code]wget https://github.com/alibaba/terraform-provider/releases/download/V1.9.1/terraform-provider-alicloud_linux-amd64.tgz
2.
[code]tar -zxvf terraform-provider-alicloud_linux-amd64.tgz
You will get a bin folder, and there is a terraform-provider-alicloud file in the folder.
3. Create .terraformrc file in the /root/terraform directory.
4. Add the following to the file.
5. Run the following command to detect the operation of the Terraform. If installed successfully, you will see
3. Deploying Kubernetes cluster
main.tf (The resources that will be deployed are defined.)
region:
[code]provider "alicloud" { access_key = "${var.access_key}" secret_key = "${var.secret_key}" region = "${var.region}" }
zone:
[code]data "alicloud_zones" "default" { "available_instance_type" = "${data.alicloud_instance_types.instance_type.instance_types.0.id}" "available_disk_category" = "${var.disk_category}" }
security group:
[code]resource "alicloud_security_group" "group" { name = "${var.short_name}" description = "New security group" vpc_id = "xxxxxx" }
Kubernetes cluster:
[code]resource "alicloud_cs_kubernetes" "main" { name_prefix = xxxxx availability_zone = "${data.alicloud_zones.default.zones.0.id}" new_nat_gateway = true master_instance_type = "ecs.n4.small" worker_instance_type = "ecs.n4.small" worker_number = 10 password = xxxxxx pod_cidr = xxxxx service_cidr = xxxx enable_ssh = true install_cloud_monitor = true vswitch_id = xxxxxx }
4. run Terraform
Under root/terraform path:
terraform init
terraform plan
terraform apply
5. view the cluster was created
You can now view the cluster created by the terraform at the container service console.
阅读更多
- kubernetes最佳实践(一) - 集群部署
- Kubernetes部署的最佳安全实践
- 【Kubernetes】最佳实践3:服务部署与弹性伸缩
- Kubernetes部署的最佳安全实践
- Kubernetes集群的监控报警策略最佳实践
- kubernetes核心概念总结和手动集群部署实践 之一
- kubernetes最佳实践(二) - dashboard ui和heapster监控部署
- kubernetes最佳实践(三) - kubedns部署
- Spring Boot 最佳实践(二)集成Jsp与生产环境部署
- Elasticstack 5.1.2 集群日志系统部署及实践
- RHCS集群理论暨最佳实践
- 云上DevOps-CodePipeline,Packer和Terraform集成实践探索
- Kubernetes学习2--集群部署与搭建
- Centos7 下Kubernetes集群安装部署
- kubernetes1.5.2集群部署过程--非安全模式
- RHCS集群理论暨 最佳实践
- Zabbix3.0安装部署最佳实践
- 利用CDH进行spark集群部署