terraform-provider-kubernetes: Error creating persistent volume.
Hi,
I’m seeing an issue when creating the persistent volume. The disk gets created in GCE, the Cluster gets created in GKE. But when it runs the kubernetes_persistent_volume function, it fails with the following error:
* kubernetes_persistent_volume_claim.artifact: 1 error(s) occurred:
* kubernetes_persistent_volume_claim.artifacty Post http://localhost/api/v1/namespaces/default/persistentvolumeclaims: dial tcp [::1]:80: connectex: No connection could be made because the target machine actively refused it.
* kubernetes_persistent_volume.artifact: 1 error(s) occurred:
* kubernetes_persistent_volume.artifact: Post http://localhost/api/v1/persistentvolumes: dial tcp [::1]:80: connectex: No connection could be made because the target machine actively refused it.
Terraform Version
$ terraform -v Terraform v0.11.10
- provider.google v1.19.1
- provider.kubernetes v1.3.0
Affected Resource(s)
kubernetes_persistent_volume kubernetes_persistent_volume_claim
Terraform Configuration Files
terraform {
required_version = ">= 0.11.0"
}
provider "google" {
credentials = "${file("../creds/staging.json")}"
project = "${var.gcp_project}"
region = "${var.gcp_region}"
zone = "${var.gcp_zone}"
}
resource "google_compute_disk" "artifact" {
name = "pd-artifact"
type = "pd-standard"
zone = "europe-west2-a"
size = "10"
}
resource "kubernetes_persistent_volume" "artifact" {
metadata {
name = "pv-artifact"
}
spec {
storage_class_name = ""
capacity {
storage = "10Gi"
}
access_modes = ["ReadWriteOnce"]
persistent_volume_source {
gce_persistent_disk {
pd_name = "pd-artifact"
fs_type = "ext4"
}
}
}
}
resource "google_container_cluster" "default-cluster" {
name = "${var.cluster_name}"
description = "default-cluster"
zone = "${var.gcp_zone}"
initial_node_count = "${var.initial_node_count}"
enable_kubernetes_alpha = "false"
enable_legacy_abac = "true"
master_auth {
username = "${var.master_username}"
password = "${var.master_password}"
}
node_config {
machine_type = "${var.node_machine_type}"
disk_size_gb = "${var.node_disk_size}"
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
]
}
}
resource "kubernetes_persistent_volume_claim" "artifact" {
metadata {
name = "pv-claim-artifact"
labels {
app = "artifact-app"
}
}
spec {
storage_class_name = ""
volume_name = "pv-artifact"
access_modes = ["ReadWriteOnce"]
resources {
requests {
storage = "10Gi"
}
}
}
}
Expected Behavior
I was hoping it would work 😃
Actual Behavior
It doesn’t
Steps to Reproduce
Actually, I just cloned this repo and hit apply on the wordpress/mysql pv files and got the same error.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (7 by maintainers)
Nice, so with the above we don’t need to use separate resources to create the disk and volume? It’s all one by the class and the claim? Testing this as we speak. (As I type it worked great.)
I think regarding the other issue, I’ll break it down into cluster and storage, and then have them ran separately as part of the pipeline.