Я пытаюсь развернуть новый кластер на DigitalOcean с помощью Terraform, основная идея - развернуть Fission для создания безсерверной среды, вот мои файлы:
do_provider.tf
provider "digitalocean" {
token = "${var.do_token}"
}
variables.tf
variable region {
description = "Region for cloud resources."
default = "lon1"
}
k8s_cluster.tf
resource "random_id" "fission-cluster" {
byte_length = 8
}
resource "digitalocean_kubernetes_cluster" "fission-cluster" {
name = "k8s-fission-${var.region}-${random_id.fission-cluster.hex}"
region = "${var.region}"
version = "1.15.3-do.3"
node_pool {
name = "k8s-fission-${var.region}-${random_id.fission-cluster.hex}-worker"
size = "s-1vcpu-2gb"
node_count = "3"
tags = ["fission", "worker"]
}
tags = ["fission"]
}
resource "local_file" "config" {
content = "${digitalocean_kubernetes_cluster.fission-cluster.kube_config.0.raw_config}"
filename = "${path.module}/config"
}
provider "kubernetes" {
host = "${digitalocean_kubernetes_cluster.fission-cluster.endpoint}"
client_certificate = "${base64decode(digitalocean_kubernetes_cluster.fission-cluster.kube_config.0.client_certificate)}"
client_key = "${base64decode(digitalocean_kubernetes_cluster.fission-cluster.kube_config.0.client_key)}"
cluster_ca_certificate = "${base64decode(digitalocean_kubernetes_cluster.fission-cluster.kube_config.0.cluster_ca_certificate)}"
}
helm. tf
provider "helm" {
service_account = "tiller"
install_tiller = true
namespace = "kube-system"
kubernetes {
config_path = "${path.module}/config"
load_config_file = true
}
}
data "helm_repository" "stable" {
name = "stable"
url = "https://kubernetes-charts.storage.googleapis.com"
}
resource "kubernetes_service_account" "tiller" {
metadata {
name = "tiller"
namespace = "kube-system"
}
depends_on = [ "kubernetes_cluster_role_binding.tiller" ]
}
resource "kubernetes_cluster_role_binding" "tiller" {
metadata {
name = "tiller"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "cluster-admin"
}
subject {
kind = "User"
name = "admin"
api_group = "rbac.authorization.k8s.io"
}
subject {
kind = "ServiceAccount"
name = "tiller"
namespace = "kube-system"
}
subject {
kind = "Group"
name = "system:masters"
api_group = "rbac.authorization.k8s.io"
}
}
Когда я запускаю terrarform plan
, он корректно отображает изменения, а также когда я запускаю terraform apply
, создается кластер и выводится как правильный
random_id.fission-cluster: Creating...
random_id.fission-cluster: Creation complete after 0s [id=dag8ooN_yVg]
digitalocean_kubernetes_cluster.fission-cluster: Creating...
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m0s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [1m50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m0s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [2m50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m0s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [3m50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m0s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [4m50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m0s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m10s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m20s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m30s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m40s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Still creating... [5m50s elapsed]
digitalocean_kubernetes_cluster.fission-cluster: Creation complete after 5m52s [id=a2dbf847-a273-41c0-a5f7-5aab8ab21407]
local_file.config: Creating...
local_file.config: Creation complete after 0s [id=bab7483e4abd5e02e473464556055c80ec952826]
kubernetes_service_account.tiller: Creating...
kubernetes_service_account.tiller: Creation complete after 2s [id=kube-system/tiller]
Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
Проблема заключается в том, что после всего процесса фермер не развертывается внутри кластера, и команда helm cli запрашивает сначала инициализацию фермера.
UPDATE
Шлем. TF файл был неправильным