Hi all, Getting this error preventing me to do any...
# getting-started
f
Hi all, Getting this error preventing me to do anything on `pulumi up`:
Copy code
pulumi:pulumi:Stack (internal-flz):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      ...
      File "/home/osboxes/Workspace/pulumi-scripts/internal/venv/lib/python3.11/site-packages/pulumi/runtime/settings.py", line 307, in handle_grpc_error
        raise grpc_error_to_exception(exn)
    Exception: configured Kubernetes cluster is unreachable: unable to load schema information from the API server: Get "<https://34.140.178.210/openapi/v2?timeout=32s>": dial tcp 34.140.178.210:443: i/o timeout

Outputs:
    kubeconfig: output<string>
My config is the following:
Copy code
# Create a GKE Cluster in autopilot mode
cluster = gcp.container.Cluster("gke-cluster",
    location=region,
    enable_autopilot=True,
	deletion_protection=False,
    node_config={
        "oauth_scopes": [
        	"<https://www.googleapis.com/auth/monitoring>",
        	"<https://www.googleapis.com/auth/devstorage.read_only>",
        	"<https://www.googleapis.com/auth/logging.write>",
        	"<https://www.googleapis.com/auth/service.management.readonly>",
        	"<https://www.googleapis.com/auth/servicecontrol>",
        	"<https://www.googleapis.com/auth/trace.append>",
		],
        "reservationAffinity": {
			"consumeReservationType": "NO_RESERVATION",
            "key": "",
            "values": []
		},
        "reservationAffinity": {
			"consumeReservationType": "NO_RESERVATION",
            "key": "",
            "values": []
        }
    }
)

# Create a global static IP
static_ip = gcp.compute.GlobalAddress("app-freelabz",
    name="app-freelabz",
	project=project
)

# Build a Kubeconfig to access the cluster
cluster_kubeconfig = pulumi.Output.all(
    cluster.master_auth.cluster_ca_certificate,
    cluster.endpoint,
    cluster.name).apply(lambda l:
    f"""apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: {l[0]}
    server: https://{l[1]}
  name: {l[2]}
contexts:
- context:
    cluster: {l[2]}
    user: {l[2]}
  name: {l[2]}
current-context: {l[2]}
kind: Config
preferences: {{}}
users:
- name: {l[2]}
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: gke-gcloud-auth-plugin
      installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
        <https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke>
      provideClusterInfo: true
""")

# Get the cluster credentials
k8s_provider = k8s.Provider("gke_k8s", kubeconfig=cluster_kubeconfig)

# Create a namespace
namespace = k8s.core.v1.Namespace("freelabz",
    metadata={"name": "freelabz"},
    opts=pulumi.ResourceOptions(provider=k8s_provider)
)

gke_cert = k8s.yaml.v2.ConfigFile("secator", file="certificate.yaml", opts=pulumi.ResourceOptions(provider=k8s_provider))
I'm starting with an empty stack ...
I found out the culprit: had a raw YAML deployment:
Copy code
gke_cert = k8s.yaml.v2.ConfigFile("secator", file="certificate.yaml")
It seems it tries to do something against the non-created-yet cluster. I've tried adding
opts=pulumi.ResourceOptions(depends_on=[cluster])
to it but that doesn't change anything. Any ideas ?
Also tried adding
opts=pulumi.ResourceOptions(provider=k8s_provider)
to it, getting a new error:
Copy code
error: Program failed with an unhandled exception:
    Traceback (most recent call last):
    ...
    Exception: cannot construct components if the provider is configured with unknown values
Ok I found out a workaround: https://github.com/pulumi/pulumi-kubernetes/issues/2038#issuecomment-1169544108 from related issues: • https://github.com/pulumi/pulumi-kubernetes/issues/2038https://github.com/pulumi/pulumi/issues/10281 don't know why these issues are closed with
resolution/fixed
, they're still very actual. Managed to workaround with:
Copy code
cluster_kubeconfig.apply(lambda _: k8s.yaml.v2.ConfigFile("secator", file="certificate.yaml", opts=pulumi.ResourceOptions(provider=k8s_provider)))
but I don't see my resource in the plan created now..