how do I reference the cluster I created as an inp...
# general
o
how do I reference the cluster I created as an input for the creation of the namespace object
c
@orange-tailor-85423 not 100% sure I understand, but I think you’re asking how you put the namespace into your GKE cluster. You can do something like this: https://github.com/pulumi/examples/blob/master/azure-ts-aks-helm/index.ts#L14
Basically you want to pass the k8sProvider generated by the GKE code, and pass that in at the end, there.
That will tell Pulumi to deploy the namespace in that GKE cluster.
o
interesting
so this is what I'm passing
// Create some namespaces export const k8sNamespace = new k8s.core.v1.Namespace("casey-robertson")
and get this error
Diagnostics: kubernetescoreNamespace (casey-robertson): error: Plan apply failed: unable to fetch resource description for v1: Get https://173.255.117.3/api/v1: x509: certificate signed by unknown authority
it's trying to go to an IP to hit the Kubernetes API??
c
It’s picking up whatever your active context in the kubeconfig file is.
So that’s the IP you have listed in your kubeconfig file.
export const k8sNamespace = new k8s.core.v1.Namespace("casey-robertson", undefined, { providers: { kubernetes: yourGkeProvider } })
try that.
o
maybe this is a chicken and egg?
so my kubens output fails because I have no cluster in the project currently
c
what happens when you run
kubectl get po
I’m actually not sure what state everything is in. Do you have code to boot a GKE cluster?
o
kubectl get pods Unable to connect to the server: x509: certificate signed by unknown authority
c
Right. Makes sense.
So you do or don’t have a GKE cluster?
o
yeah, planned to build cluster using Pulumi
c
Ok, does that code exist yet?
Here’s what I’d do. Copy this example: https://github.com/pulumi/examples/tree/master/gcp-ts-gke
replace the deployment in this file: https://github.com/pulumi/examples/blob/master/gcp-ts-gke/index.ts with the code I gave you above.
namely
const k8sNamespace = new k8s.core.v1.Namespace("casey-robertson", undefined, { provider: k8sProvider })
That should work.
That will build the GKE cluster, and then put your namespace into that GKE cluster.
Remember, Pulumi by default will just deploy resources to whatever is in your active kubeconfig file. In order to deploy to the GKE cluster, you have to give it the provider for that cluster.
Make sense?
o
yep
will work on that
creating the cluster now - it was nice enough to tell me I had missing params
🙂
I'm lame - new cluster called 'alpha'. Same name, not same cluster. Hence 'kubens' fails
whoops
c
mmm
o
just pulled down the creds again
still working on figuring out F12 and what the 2nd param would be
c
I’d take a look at the Kubuernetes docs.
o
I don't want it to append the random string to my namespace name
yeah
will do
c
Whatever YAML you write, is what youu’d put in there.
o
ha - found a sample in sockshop
const sockShopNs = new k8s.core.v1.Namespace("sock-shop", { metadata: { name: "sock-shop" } });
tacked on the provider part as the third param and it works!
c
great!