feature: support liveness pobe path

This commit is contained in:
RouxAntoine 2023-10-06 00:23:14 +02:00
parent db693aab26
commit e147b8d3c8
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
2 changed files with 13 additions and 2 deletions

View File

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

View File

@ -20,8 +20,9 @@ const (
) )
type ImagesConfiguration struct { type ImagesConfiguration struct {
Image string Image string
Path string Path string
Health string
} }
type Configuration struct { type Configuration struct {
@ -88,6 +89,9 @@ func NewApplication(ctx *pulumi.Context, publicConfiguration *Configuration) (*A
if publicImageConfiguration.Path == "" { if publicImageConfiguration.Path == "" {
localImagesConfiguration.Path = "/" localImagesConfiguration.Path = "/"
} }
if publicImageConfiguration.Health == "" {
localImagesConfiguration.Health = "/"
}
if slices.Contains(preventDuplicatePath, localImagesConfiguration.Path) { if slices.Contains(preventDuplicatePath, localImagesConfiguration.Path) {
return nil, errors.New("duplicate path in ingress configuration") return nil, errors.New("duplicate path in ingress configuration")
} }
@ -416,6 +420,12 @@ func createDeployment(
}, },
}, },
Env: env, Env: env,
LivenessProbe: &corev1.ProbeArgs{
HttpGet: &corev1.HTTPGetActionArgs{
Path: pulumi.String(configuration.ImageReference.Health),
Port: pulumi.Int(80),
},
},
}, },
}, },
}, },