feat(probe): support readiness path

This commit is contained in:
RouxAntoine 2024-10-07 00:40:51 +02:00
parent ae29216252
commit c3fb551904
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
3 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,7 @@ func main() {
Image: "nginx",
Path: "/api",
Health: "/",
Ready: "/",
},
},
Env: map[string]string{

View File

@ -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)

View File

@ -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),
},
},
},
},
},