Answer the question
In order to leave comments, you need to log in
How to create a kubernetes cluster using terraform and fill it with entities?
Greetings, I started using terraform when deploying a cluster, and immediately ran into several problems. Namely, the execution order. In my case, the kubernetes classter must be created first, and then users and rights. But terraforms are not keeping order now. According to the proposed plan, first kubernetes entities are created and then a cluster is created
provider "some provider" {
access_key = "svssddsdffsd"
secret_key = "fsdfsdds"
organization_id = "fsdfsds"
zone = "dfsdf"
region = "sdf"
}
resource "scaleway_k8s_cluster_beta" "emcorp" {
name = "emcorp"
description = "test cluster"
version = "1.16.10"
cni = "cilium"
enable_dashboard = true
ingress = "none"
tags = [
"emcorp",
"thisroot",
"test"]
}
resource "scaleway_k8s_pool_beta" "emcorp_pool" {
cluster_id = scaleway_k8s_cluster_beta.emcorp.id
name = "emcorp_pool"
node_type = "DEV1-M"
size = 1
autoscaling = true
autohealing = true
min_size = 1
max_size = 2
wait_for_pool_ready = true
}
output "kubeconfig" {
value = "${scaleway_k8s_cluster_beta.emcorp.kubeconfig}"
}
output "kube-connections" {
value = {
load_config_file = "false"
host = scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].host
token = scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].token
cluster_ca_certificate = base64decode(
scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].cluster_ca_certificate
)
}
}
provider "kubernetes" {
load_config_file = "false"
host = scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].host
token = scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].token
cluster_ca_certificate = base64decode(
scaleway_k8s_cluster_beta.emcorp.kubeconfig[0].cluster_ca_certificate
)
}
resource "kubernetes_service_account" "gitlab-admin" {
metadata {
name = "gitlab-admin"
namespace = "kube-system"
}
secret {
name = "${kubernetes_secret.gitlab-admin-secret.metadata.0.name}"
}
depends_on = [
scaleway_k8s_pool_beta.emcorp_pool
]
}
resource "kubernetes_secret" "gitlab-admin-secret" {
metadata {
name = "gitlab-admin-secret"
}
}
resource "kubernetes_cluster_role_binding" "gitlab-admin" {
metadata {
name = "gitlab-admin"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "cluster-admin"
}
subject {
kind = "ServiceAccount"
name = "gitlab-admin"
namespace = "kube-system"
}
}
//provider "helm" {
// version = "~> 0.9"
// install_tiller = true
//}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question