terraform 使用
1. 下载
wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
2. 创建个测试的tf
provider "kubernetes" {} resource "kubernetes_pod" nginx { metadata { name = "nginx-example-3" labels = { App = "nginx" } } spec { container { image = "nginx:1.7.8" name = "nginx-example-2" port { container_port = 80 } } } }
3. 运行
1. terraform init #初始化,下载k8s的包 2. terraform plan #检查配置文件语法 3. terraform apply -auto-approve # 执行 执行完之后,查看 kubectl get pods | grep nginx-example-3 nginx-example-3 1/1 Running 0 8m
知人难,相知相惜更难