Skip to content

Instantly share code, notes, and snippets.

@ctrox
Created May 8, 2023 09:24
Show Gist options
  • Save ctrox/d31751829062d650b6d43443d6f8aed3 to your computer and use it in GitHub Desktop.
Save ctrox/d31751829062d650b6d43443d6f8aed3 to your computer and use it in GitHub Desktop.
Nine Terraform example
resource "kubernetes_manifest" "sample_cluster" {
manifest = {
apiVersion = "infrastructure.nine.ch/v1alpha1"
kind = "KubernetesCluster"
metadata = {
name = "sample-cluster"
namespace = "<cockpit account name>"
}
spec = {
forProvider = {
vcluster = {
version = "1.24"
}
nodePools = []
location = "nine-es34"
}
writeConnectionSecretToRef = {
name = "sample-cluster"
namespace = "<cockpit account name>"
}
}
}
wait {
condition {
type = "Ready"
status = "True"
}
}
}
# read secret that the KubernetesCluster creates
data "kubernetes_secret_v1" "example_sa" {
metadata {
name = kubernetes_manifest.sample_cluster.manifest.spec.writeConnectionSecretToRef.name
namespace = kubernetes_manifest.sample_cluster.manifest.spec.writeConnectionSecretToRef.namespace
}
}
# put token into an output. This could then be used by another module for example.
output "kubeconfig" {
sensitive = true
value = data.kubernetes_secret_v1.sample_cluster.data.kubeconfig
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment