bitter-application-91815
10/08/2020, 11:23 AMgorgeous-egg-16927
10/08/2020, 5:25 PM.get
method that can be used to read resource state.
Something like k8s.networking.v1.Ingress.get('existingResource', 'axiomdb/myIngress')
should do the trickbitter-application-91815
10/09/2020, 7:35 PMfunc GetIngressList(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *IngressListState, opts ...pulumi.ResourceOption) (*IngressList, error) {
// helmchart for ALB
albResource, err := helm.NewChart(ctx, fmt.Sprintf("axiom-alb-charts-%s", w.targetEnv), helm.ChartArgs{
Chart: pulumi.String("aws-alb-ingress-controller"),
Namespace: pulumi.String(namespace),
FetchArgs: helm.FetchArgs{
Repo: pulumi.String("<http://storage.googleapis.com/kubernetes-charts-incubator>"),
},
Values: pulumi.Map{
"clusterName": w.eksCluster.Name,
"awsVpcID": w.vpNetwork.ID(),
"awsRegion": pulumi.String(os.Getenv(PrimaryRegion)),
},
}, pulumi.Provider(k8sProvider))
if err != nil {
return err
}
/*for _, r := range albResource.Resources {
}*/
ingress, err := networking.GetIngress(ctx, fmt.Sprintf("axiom-alb-charts-%s", w.targetEnv), albResource.Resources.ID(), nil)
if err != nil {
return err
}
gorgeous-egg-16927
10/09/2020, 8:24 PM[namespace]/name
, where name is the name of the actual k8s resource that you would see with kubectl get ing
bitter-application-91815
10/09/2020, 8:48 PMingress, err := networking.GetIngress(ctx, "axiomdb-ingress", pulumi.IDInput(pulumi.ID(fmt.Sprintf("%s/axiomdb-ingress", namespace))), nil)
if err != nil {
return err
}
ctx.Export("axiomDBIngress", ingress.Kind)
Type Name Plan Info
pulumi:pulumi:Stack staging-axiom-cloud 1 error
~ ├─ aws:ec2:RouteTable axiom-cloud-private-subnet-2-routetable-staging-g update [diff: ~routes]
~ ├─ aws:ec2:RouteTable axiom-cloud-private-subnet-3-routetable-staging-g update [diff: ~routes]
~ ├─ aws:ec2:RouteTable axiom-cloud-private-subnet-1-routetable-staging-g update [diff: ~routes]
├─ kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart> axiomdb-charts-staging-g
│ └─ kubernetes:extensions/v1beta1:Ingress axiomdb/axiomdb-ingress 1 warning
└─ kubernetes:<http://networking.k8s.io/v1:Ingress|networking.k8s.io/v1:Ingress> axiomdb-ingress 1 error
Diagnostics:
kubernetes:extensions/v1beta1:Ingress (axiomdb/axiomdb-ingress):
warning: extensions/v1beta1/Ingress is deprecated by <http://networking.k8s.io/v1beta1/Ingress|networking.k8s.io/v1beta1/Ingress> and not supported by Kubernetes v1.20+ clusters.
kubernetes:<http://networking.k8s.io/v1:Ingress|networking.k8s.io/v1:Ingress> (axiomdb-ingress):
error: Preview failed: resource 'axiomdb/axiomdb-ingress' does not exist
pulumi:pulumi:Stack (staging-axiom-cloud):
error: preview failed
ronoc@gunther:~/source/watchly/service/cloud/aws/staging$ kubectl get ing -A
NAMESPACE NAME HOSTS ADDRESS PORTS AGE
axiomdb axiomdb-ingress * <http://internal-2fd8be7b-axiomdb-axiomdbin-0378-1435062635.eu-west-2.elb.amazonaws.com|internal-2fd8be7b-axiomdb-axiomdbin-0378-1435062635.eu-west-2.elb.amazonaws.com> 80 2d9h
ronoc@gunther:~/source/watchly/service/cloud/aws/staging$
gorgeous-egg-16927
10/09/2020, 8:55 PMGetResource
method on the Chart to get that.bitter-application-91815
10/09/2020, 8:55 PMgorgeous-egg-16927
10/09/2020, 8:56 PMAnyOutput
bitter-application-91815
10/09/2020, 9:02 PMGetResource(gvk, name, namespace string)
=> GetResource("ingress", "axiomdb-ingress", "axiom")gorgeous-egg-16927
10/09/2020, 9:05 PMnetworking/v1/Ingress
bitter-application-91815
10/09/2020, 9:05 PMgorgeous-egg-16927
10/09/2020, 9:06 PMaxiomdb
bitter-application-91815
10/09/2020, 9:29 PMgorgeous-egg-16927
10/09/2020, 9:37 PMbitter-application-91815
10/09/2020, 9:38 PMgorgeous-egg-16927
10/09/2020, 9:38 PMbitter-application-91815
10/09/2020, 9:40 PMingressIP := ingressChart.GetResource("networking/v1/Ingress", "axiomdb-ingress", "axiomdb").
Apply(func(r interface{}) (interface{}, error) {
svc := r.(*networking.Ingress)
return svc.Status.LoadBalancer.Ingress()[0].Hostname, nil
})
ctx.Export("ingressIP", ingressIP)
<https://raw.githubusercontent.com/pulumi/pulumi-kubernetes/master/sdk/go/kubernetes/core/v1/pulumiTypes.go>
Type Name Plan Info
pulumi:pulumi:Stack staging-axiom-cloud 1 error; 2 messages
Diagnostics:
pulumi:pulumi:Stack (staging-axiom-cloud):
# <http://axicode.axiom.co/watchmakers/watchly/service/cloud/aws|axicode.axiom.co/watchmakers/watchly/service/cloud/aws>
../eks.go:175:34: svc.Status.LoadBalancer.Ingress undefined (type func() "<http://github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/core/v1|github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/core/v1>".LoadBalancerStatusPtrOutput has no field or method Ingress)
error: an unhandled error occurred: program exited with non-zero exit code: 2
ingressIP := ingressChart.GetResource("networking/v1/Ingress", "axiomdb-ingress", "axiomdb").
Apply(func(r interface{}) (interface{}, error) {
svc := r.(*networking.Ingress)
return svc.Status.LoadBalancer().Ingress().Index(<http://pulumi.Int|pulumi.Int>(0)).Hostname, nil
})
ctx.Export("ingressIP", ingressIP)
panic: interface conversion: interface {} is nil, not *v1.Ingress
goroutine 316 [running]:
<http://axicode.axiom.co/watchmakers/watchly/service/cloud/aws.(*worker).buildEks.func1(0x0|axicode.axiom.co/watchmakers/watchly/service/cloud/aws.(*worker).buildEks.func1(0x0>, 0x0, 0x79715c0, 0xc00008aa80, 0xc000501c10, 0x4155f3)
/home/ronoc/source/watchly/service/cloud/aws/eks.go:174 +0x10a
<http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).Apply.func1(0x909b940|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).Apply.func1(0x909b940>, 0xc000056110, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/ronoc/.axiom-dev/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.9.2/go/pulumi/types.go:305 +0x39
reflect.Value.call(0x7930160, 0xc0005bccd0, 0x13, 0x8f07e20, 0x4, 0xc000501f60, 0x2, 0x2, 0xc0003a4ed8, 0x494add, ...)
/home/ronoc/.axiom-dev/go/src/reflect/value.go:460 +0x5f6
reflect.Value.Call(0x7930160, 0xc0005bccd0, 0x13, 0xc0003a4f60, 0x2, 0x2, 0x0, 0x0, 0x1)
/home/ronoc/.axiom-dev/go/src/reflect/value.go:321 +0xb4
<http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).ApplyTWithContext.func1(0xc00044a5b0|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).ApplyTWithContext.func1(0xc00044a5b0>, 0x909b940, 0xc000056110, 0x90f1860, 0xc00044a620, 0x7930160, 0xc0005bccd0, 0x13)
/home/ronoc/.axiom-dev/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.9.2/go/pulumi/types.go:392 +0x23f
created by <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).ApplyTWithContext|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*OutputState).ApplyTWithContext>
/home/ronoc/.axiom-dev/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.9.2/go/pulumi/types.go:380 +0x1e0
exit status 2
panic: interface conversion: interface {} is nil, not *v1.Ingress
goroutine 316 [running]:
gorgeous-egg-16927
10/12/2020, 5:10 PMingressIP := ingressChart.GetResource("<http://networking.k8s.io/v1/Ingress|networking.k8s.io/v1/Ingress>", "axiomdb-ingress", "axiomdb").
It looks like the id field for the Go SDK is using the fully-qualified Group name (i.e., <http://networking.k8s.io|networking.k8s.io>
rather than networking
)bitter-application-91815
10/12/2020, 6:43 PMerror: an unhandled error occurred: program exited with non-zero exit code: 1
panic: interface conversion: interface {} is nil, not *v1.Ingress