feature: set missing service and Path information on ingress
This commit is contained in:
parent
b190bb68a5
commit
11d6b0e9b3
@ -68,13 +68,13 @@ func NewApplication(ctx *pulumi.Context, publicConfiguration *Configuration) (*A
|
|||||||
configuration.ShouldCreateCertificate = true
|
configuration.ShouldCreateCertificate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return createResource(ctx, configuration)
|
return createResources(ctx, configuration)
|
||||||
} else {
|
} else {
|
||||||
return nil, errors.New("missing required value Name or Image during generic application construction")
|
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{}
|
application := &Application{}
|
||||||
err := ctx.RegisterComponentResource("pkg:application:Application", configuration.Name, application)
|
err := ctx.RegisterComponentResource("pkg:application:Application", configuration.Name, application)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,7 +95,7 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o
|
|||||||
}
|
}
|
||||||
application.DeploymentName = deployment.Metadata.Name().Elem()
|
application.DeploymentName = deployment.Metadata.Name().Elem()
|
||||||
|
|
||||||
_, err = createService(ctx, configuration, namespace, appLabels, application)
|
service, err := createService(ctx, configuration, namespace, appLabels, application)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = createIngress(ctx, configuration, namespace, certificate, application)
|
_, err = createIngress(ctx, configuration, namespace, certificate, service, application)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -126,7 +126,10 @@ func createResource(ctx *pulumi.Context, configuration *internalConfiguration, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createIngress(
|
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) {
|
) (*netv1.Ingress, error) {
|
||||||
if configuration.ShouldCreateIngress {
|
if configuration.ShouldCreateIngress {
|
||||||
host := pulumi.String(configuration.Dns)
|
host := pulumi.String(configuration.Dns)
|
||||||
@ -147,7 +150,22 @@ func createIngress(
|
|||||||
Rules: &netv1.IngressRuleArray{
|
Rules: &netv1.IngressRuleArray{
|
||||||
netv1.IngressRuleArgs{
|
netv1.IngressRuleArgs{
|
||||||
Host: host,
|
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{
|
Tls: &netv1.IngressTLSArray{
|
||||||
@ -233,6 +251,7 @@ func createService(
|
|||||||
Selector: appLabels,
|
Selector: appLabels,
|
||||||
Ports: corev1.ServicePortArray{
|
Ports: corev1.ServicePortArray{
|
||||||
corev1.ServicePortArgs{
|
corev1.ServicePortArgs{
|
||||||
|
Name: pulumi.String("exposed-port"),
|
||||||
Port: pulumi.Int(8090),
|
Port: pulumi.Int(8090),
|
||||||
TargetPort: pulumi.String("http"),
|
TargetPort: pulumi.String("http"),
|
||||||
Protocol: pulumi.String("TCP"),
|
Protocol: pulumi.String("TCP"),
|
||||||
|
Loading…
Reference in New Issue
Block a user