diff --git a/pkg/application/generic.go b/pkg/application/generic.go index 888239e..434a76d 100644 --- a/pkg/application/generic.go +++ b/pkg/application/generic.go @@ -68,13 +68,13 @@ func NewApplication(ctx *pulumi.Context, publicConfiguration *Configuration) (*A configuration.ShouldCreateCertificate = true } - return createResource(ctx, configuration) + return createResources(ctx, configuration) } else { return nil, errors.New("missing required value Name or Image during generic application construction") } } -func createResource(ctx *pulumi.Context, configuration *internalConfiguration, opts ...pulumi.ResourceOption) (*Application, error) { +func createResources(ctx *pulumi.Context, configuration *internalConfiguration, opts ...pulumi.ResourceOption) (*Application, error) { application := &Application{} err := ctx.RegisterComponentResource("pkg:application:Application", configuration.Name, application) if err != nil { @@ -95,7 +95,7 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o } application.DeploymentName = deployment.Metadata.Name().Elem() - _, err = createService(ctx, configuration, namespace, appLabels, application) + service, err := createService(ctx, configuration, namespace, appLabels, application) if err != nil { return nil, err } @@ -105,7 +105,7 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o return nil, err } - _, err = createIngress(ctx, configuration, namespace, certificate, application) + _, err = createIngress(ctx, configuration, namespace, certificate, service, application) if err != nil { return nil, err } @@ -126,7 +126,10 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o } func createIngress( - ctx *pulumi.Context, configuration *internalConfiguration, namespace *corev1.Namespace, certificate *v1.Certificate, application *Application, + ctx *pulumi.Context, + configuration *internalConfiguration, + namespace *corev1.Namespace, certificate *v1.Certificate, service *corev1.Service, + application *Application, ) (*netv1.Ingress, error) { if configuration.ShouldCreateIngress { host := pulumi.String(configuration.Dns) @@ -147,7 +150,22 @@ func createIngress( Rules: &netv1.IngressRuleArray{ netv1.IngressRuleArgs{ Host: host, - Http: &netv1.HTTPIngressRuleValueArgs{}, + Http: &netv1.HTTPIngressRuleValueArgs{ + Paths: &netv1.HTTPIngressPathArray{ + netv1.HTTPIngressPathArgs{ + Path: pulumi.String("/"), + PathType: pulumi.String("Prefix"), + Backend: &netv1.IngressBackendArgs{ + Service: &netv1.IngressServiceBackendArgs{ + Name: service.Metadata.Name().Elem(), + Port: &netv1.ServiceBackendPortArgs{ + Name: pulumi.String("exposed-port"), + }, + }, + }, + }, + }, + }, }, }, Tls: &netv1.IngressTLSArray{ @@ -233,6 +251,7 @@ func createService( Selector: appLabels, Ports: corev1.ServicePortArray{ corev1.ServicePortArgs{ + Name: pulumi.String("exposed-port"), Port: pulumi.Int(8090), TargetPort: pulumi.String("http"), Protocol: pulumi.String("TCP"),