https://pulumi.com logo
#general
Title
# general
i

incalculable-diamond-5088

02/22/2019, 7:12 PM
I'm trying to accomplish something like:
Copy code
const eksCluster = aws.eks.getCluster({name: 'cluster-name'})
const ns = new k8s.core.v1.Namespace('pulumi-test', {}, { provider: eksCluster.getProvider() })
However the
getCluster
fails with
Error: Missing required property 'roleArn'
s

stocky-spoon-28903

02/22/2019, 7:20 PM
Hmmm, that’s not particularly good.
Does it fail during compilation or execution?
i

incalculable-diamond-5088

02/22/2019, 7:22 PM
not sure.
Copy code
error: Running program '/pulumi' failed with an unhandled exception:
    error: Error: Missing required property 'roleArn'
s

stocky-spoon-28903

02/22/2019, 7:47 PM
Hmm, I’ll see if I can reproduce this shortly - it’s definitely on the getCluster call?
i

incalculable-diamond-5088

02/22/2019, 7:51 PM
Sorry, it happens on
aws.eks.Cluster.get
const eksCluster = aws.eks.Cluster.get({ name: 'cluster-name' })
s

stocky-spoon-28903

02/22/2019, 7:51 PM
Aha - that’s easier to diagnose I think
i

incalculable-diamond-5088

02/22/2019, 7:52 PM
I'm not sure however if I'm using the correct route. I'm trying to build the provider for K8S
and do it dynamically from existing cluster. Is that possible?
s

stocky-spoon-28903

02/22/2019, 7:54 PM
I think either @breezy-hamburger-69619 or @creamy-potato-29402 might be the best person to help with that specifically
Ahh I see the issue - one sec let me look up the way to use that function
b

breezy-hamburger-69619

02/22/2019, 7:57 PM
To create a k8s provider from an eks Cluster object e.g. named
cluster
, do the following:
Copy code
const k8sProvider = new k8s.Provider("myKubernetesCluster", {
    kubeconfig: cluster.kubeconfig.apply(JSON.stringify),
});
then in your ns declaration, set
{ provider: k8sProvider }
s

stocky-spoon-28903

02/22/2019, 8:04 PM
To fix the
cluster.get
, use this:
aws.eks.Cluster.get("pulumi-name", "aws-cluster-name")
(Instead of passing in an object)
i

incalculable-diamond-5088

02/22/2019, 8:06 PM
@stocky-spoon-28903 @breezy-hamburger-69619 Thank you, checking now
It seems like
cluster
does not contain
kubeconfig
property
btw, the doc also doesn't say anything about kubeconfig: https://pulumi.io/reference/pkg/nodejs/@pulumi/aws/eks/#Cluster
s

stocky-spoon-28903

02/22/2019, 8:14 PM
@breezy-hamburger-69619 ?
b

breezy-hamburger-69619

02/22/2019, 8:34 PM
@incalculable-diamond-5088 use the
@pulumi/eks
package instead of `pulumi/aws/eks`: https://pulumi.io/reference/pkg/nodejs/@pulumi/eks/index.html#Cluster-kubeconfig
i

incalculable-diamond-5088

02/22/2019, 8:35 PM
Sure, but how do I use it with an existing cluster?
I'm trying something like:
Copy code
const eksCluster = new eks.Cluster('eks-cluster', {}, { id: ... })
and I get:
Copy code
Error: Cannot read an existing resource unless it has a custom provider
        at new Resource (/Users/igor/work/pulumi/node_modules/@pulumi/pulumi/resource.js:91:23)
        at new ComponentResource (/Users/igor/work/pulumi/node_modules/@pulumi/pulumi/resource.js:208:9)
b

breezy-hamburger-69619

02/22/2019, 8:50 PM
@creamy-potato-29402
@incalculable-diamond-5088 so i dont think there’s currently a way to pull the kubeconfig on an existing cluster. however, you have the data to recreate it:
Copy code
const cluster = aws.eks.Cluster.get("myCluster", "nebula-eksCluster-efc46c2")
you can use the
cluster
props:
certificateAuthority
,
name
, and
endpoint
to fill in the blanks in https://gist.github.com/b01eeecacccc3e284771463ed626af5e
c

creamy-potato-29402

02/22/2019, 8:58 PM
You should be able to, why not?
It’s a member of the EKS object, right?
Are you sure that that line corresponds to that error, though?
i

incalculable-diamond-5088

02/22/2019, 9:01 PM
@creamy-potato-29402 yep. It's the line. Will try to compose the object
c

creamy-potato-29402

02/22/2019, 9:01 PM
oh wait, mike is right, we’re building this in the constructor which is not the right thing to do.
this should be a
.kubeconfig()
method that constructs it on the fly.
@breezy-hamburger-69619 this should be pretty simple, are we doing this soon?
b

breezy-hamburger-69619

02/22/2019, 9:04 PM
Ya seems straight forward enough
c

creamy-potato-29402

02/22/2019, 9:04 PM
@microscopic-florist-22719 does that error look familiar to you?
Copy code
Error: Cannot read an existing resource unless it has a custom provider
        at new Resource (/Users/igor/work/pulumi/node_modules/@pulumi/pulumi/resource.js:91:23)
        at new ComponentResource (/Users/igor/work/pulumi/node_modules/@pulumi/pulumi/resource.js:208:9)
b

breezy-hamburger-69619

02/22/2019, 9:15 PM
opened an issue to track the
kubeconfig()
method: https://github.com/pulumi/pulumi-eks/issues/68
i

incalculable-diamond-5088

02/22/2019, 9:17 PM
Thanks @breezy-hamburger-69619!
👍🏼 1
m

microscopic-florist-22719

02/22/2019, 9:32 PM
@creamy-potato-29402 @breezy-hamburger-69619 it is not currently possible to construct a
@pulumi/eks.Cluster
from an exiting setup, as it encompasses much more than the EKS cluster itself
We should add an overlay in
@pulumi/aws
that can construct a Kubeconfig for a raw
aws.eks.Cluster
b

breezy-hamburger-69619

02/22/2019, 9:34 PM
@microscopic-florist-22719 could you please elaborate on what is missing out of the
cluster
obj returned from doing a
aws.eks.Cluster.get(...)
?
m

microscopic-florist-22719

02/22/2019, 9:34 PM
Not sure what you mean
c

creamy-potato-29402

02/22/2019, 9:34 PM
Why can’t we transitively get all the underlying resources it abstracts?
m

microscopic-florist-22719

02/22/2019, 9:35 PM
We'd need IDs for all of them. We could do that, but it would be quite unwieldy, and it is not necessary if all you want to do is get a kubeconfig for an existing cluster
b

breezy-hamburger-69619

02/22/2019, 9:35 PM
ah i see
m

microscopic-florist-22719

02/22/2019, 9:36 PM
We probably do want to be able to build a
@pulumi/eks.Cluster
out of existing resources in the fullness of time
b

breezy-hamburger-69619

02/22/2019, 9:36 PM
well in this case its just retrieving the kubeconfig, but i see what you mean about not having the full set of objects
m

microscopic-florist-22719

02/22/2019, 9:36 PM
But I think that
@pulumi/aws
is the right place to put the
kubeconfig()
helper
c

creamy-potato-29402

02/22/2019, 9:36 PM
makes sense.
m

microscopic-florist-22719

02/22/2019, 9:36 PM
ideally as an overlaid instance method on
@pulumi/aws.eks.Cluster
b

breezy-hamburger-69619

02/22/2019, 9:36 PM
got it
c

creamy-potato-29402

02/22/2019, 9:37 PM
not the EKS package?
m

microscopic-florist-22719

02/22/2019, 9:37 PM
correct
c

creamy-potato-29402

02/22/2019, 9:37 PM
AWS package doesn’t really understand anything about kubernetes or eks at all, though,right?
Where would it go in there?
c

creamy-potato-29402

02/22/2019, 9:38 PM
I see.
m

microscopic-florist-22719

02/22/2019, 9:38 PM
So you could do this:
Copy code
const cluster = aws.eks.Cluster.get("myCluster", "my-cluster-id");
const kubeconfig = cluster.kubeconfig();
Given that the kubeconfig only relies on information from the cluster, I believe that is the right layer for this method
then the
@pulumi/eks
package can consume that method
c

creamy-potato-29402

02/22/2019, 9:39 PM
I had forgotten that there is an
eks.Cluster
type.
for some reason I thought this was just a special case of
ec2.Instance
m

microscopic-florist-22719

02/22/2019, 9:40 PM
lol
c

creamy-potato-29402

02/22/2019, 9:40 PM
I mean in my defense, everything else is so manual that this is actually not that crazy of an assumption.
b

breezy-hamburger-69619

02/22/2019, 9:41 PM
closed the issue in
pulumi/eks
and moved it to `pulumi/aws`: https://github.com/pulumi/pulumi-aws/issues/478
m

microscopic-florist-22719

02/22/2019, 9:42 PM
@creamy-potato-29402 yeah, I saw how you could have arrived at that conclusion 🙂
2 Views