https://pulumi.com logo
o

orange-tailor-85423

10/19/2018, 7:11 PM
how do I reference the cluster I created as an input for the creation of the namespace object
c

creamy-potato-29402

10/19/2018, 7:33 PM
@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

orange-tailor-85423

10/19/2018, 7:40 PM
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

creamy-potato-29402

10/19/2018, 7:42 PM
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

orange-tailor-85423

10/19/2018, 7:44 PM
maybe this is a chicken and egg?
so my kubens output fails because I have no cluster in the project currently
c

creamy-potato-29402

10/19/2018, 7:45 PM
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

orange-tailor-85423

10/19/2018, 7:46 PM
kubectl get pods Unable to connect to the server: x509: certificate signed by unknown authority
c

creamy-potato-29402

10/19/2018, 7:46 PM
Right. Makes sense.
So you do or don’t have a GKE cluster?
o

orange-tailor-85423

10/19/2018, 7:46 PM
yeah, planned to build cluster using Pulumi
c

creamy-potato-29402

10/19/2018, 7:47 PM
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

orange-tailor-85423

10/19/2018, 7:50 PM
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

creamy-potato-29402

10/19/2018, 8:01 PM
mmm
o

orange-tailor-85423

10/19/2018, 8:06 PM
just pulled down the creds again
still working on figuring out F12 and what the 2nd param would be
c

creamy-potato-29402

10/19/2018, 8:06 PM
I’d take a look at the Kubuernetes docs.
o

orange-tailor-85423

10/19/2018, 8:06 PM
I don't want it to append the random string to my namespace name
yeah
will do
c

creamy-potato-29402

10/19/2018, 8:06 PM
Whatever YAML you write, is what youu’d put in there.
o

orange-tailor-85423

10/19/2018, 8:32 PM
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

creamy-potato-29402

10/19/2018, 8:34 PM
great!
2 Views