From c3fb55190405b65cb21fb374ce6e67d7641c53bf Mon Sep 17 00:00:00 2001 From: RouxAntoine Date: Mon, 7 Oct 2024 00:40:51 +0200 Subject: [PATCH] feat(probe): support readiness path --- main.go | 1 + pkg/application/generic.go | 7 +++++++ pkg/workload/deployment.go | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/main.go b/main.go index 7a846a1..1a013a9 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ func main() { Image: "nginx", Path: "/api", Health: "/", + Ready: "/", }, }, Env: map[string]string{ diff --git a/pkg/application/generic.go b/pkg/application/generic.go index e532530..7422e56 100644 --- a/pkg/application/generic.go +++ b/pkg/application/generic.go @@ -26,6 +26,7 @@ type ImagesConfiguration struct { Image string Path string Health string + Ready string } type CreatedApplication struct { @@ -53,6 +54,7 @@ type service struct { Image string Path string Health string + Ready string } func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*CreatedApplication, error) { @@ -72,6 +74,7 @@ func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*Created Image: image.Image, Path: image.Path, Health: image.Health, + Ready: image.Ready, } if image.Path == "" { serviceConfiguration.Path = "/" @@ -79,6 +82,9 @@ func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*Created if image.Health == "" { serviceConfiguration.Health = "/" } + if image.Ready == "" { + serviceConfiguration.Ready = "/" + } if slices.Contains(preventDuplicatePath, serviceConfiguration.Path) { return nil, errors.New("duplicate path in ingress applicationConfiguration") } @@ -140,6 +146,7 @@ func (application *application) createResources(ctx *pulumi.Context) (*CreatedAp ImageReference: &workload.ImageReference{ Image: service.Image, Health: service.Health, + Ready: service.Ready, }, } deployment, err := deploymentConfiguration.CreateDeployment(ctx, namespace, application, appLabels) diff --git a/pkg/workload/deployment.go b/pkg/workload/deployment.go index 5936802..ef76032 100644 --- a/pkg/workload/deployment.go +++ b/pkg/workload/deployment.go @@ -18,6 +18,7 @@ type DeploymentConfiguration struct { type ImageReference struct { Image string Health string + Ready string } func (deployment *DeploymentConfiguration) CreateDeployment( @@ -72,6 +73,12 @@ func (deployment *DeploymentConfiguration) CreateDeployment( InitialDelaySeconds: pulumi.Int(70), PeriodSeconds: pulumi.Int(15), }, + ReadinessProbe: &v1.ProbeArgs{ + HttpGet: &v1.HTTPGetActionArgs{ + Path: pulumi.String(deployment.ImageReference.Ready), + Port: pulumi.Int(80), + }, + }, }, }, },