feat(probe): support readiness path
This commit is contained in:
parent
ae29216252
commit
c3fb551904
1
main.go
1
main.go
@ -19,6 +19,7 @@ func main() {
|
|||||||
Image: "nginx",
|
Image: "nginx",
|
||||||
Path: "/api",
|
Path: "/api",
|
||||||
Health: "/",
|
Health: "/",
|
||||||
|
Ready: "/",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Env: map[string]string{
|
Env: map[string]string{
|
||||||
|
@ -26,6 +26,7 @@ type ImagesConfiguration struct {
|
|||||||
Image string
|
Image string
|
||||||
Path string
|
Path string
|
||||||
Health string
|
Health string
|
||||||
|
Ready string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreatedApplication struct {
|
type CreatedApplication struct {
|
||||||
@ -53,6 +54,7 @@ type service struct {
|
|||||||
Image string
|
Image string
|
||||||
Path string
|
Path string
|
||||||
Health string
|
Health string
|
||||||
|
Ready string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*CreatedApplication, error) {
|
func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*CreatedApplication, error) {
|
||||||
@ -72,6 +74,7 @@ func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*Created
|
|||||||
Image: image.Image,
|
Image: image.Image,
|
||||||
Path: image.Path,
|
Path: image.Path,
|
||||||
Health: image.Health,
|
Health: image.Health,
|
||||||
|
Ready: image.Ready,
|
||||||
}
|
}
|
||||||
if image.Path == "" {
|
if image.Path == "" {
|
||||||
serviceConfiguration.Path = "/"
|
serviceConfiguration.Path = "/"
|
||||||
@ -79,6 +82,9 @@ func NewApplication(ctx *pulumi.Context, configuration *Configuration) (*Created
|
|||||||
if image.Health == "" {
|
if image.Health == "" {
|
||||||
serviceConfiguration.Health = "/"
|
serviceConfiguration.Health = "/"
|
||||||
}
|
}
|
||||||
|
if image.Ready == "" {
|
||||||
|
serviceConfiguration.Ready = "/"
|
||||||
|
}
|
||||||
if slices.Contains(preventDuplicatePath, serviceConfiguration.Path) {
|
if slices.Contains(preventDuplicatePath, serviceConfiguration.Path) {
|
||||||
return nil, errors.New("duplicate path in ingress applicationConfiguration")
|
return nil, errors.New("duplicate path in ingress applicationConfiguration")
|
||||||
}
|
}
|
||||||
@ -140,6 +146,7 @@ func (application *application) createResources(ctx *pulumi.Context) (*CreatedAp
|
|||||||
ImageReference: &workload.ImageReference{
|
ImageReference: &workload.ImageReference{
|
||||||
Image: service.Image,
|
Image: service.Image,
|
||||||
Health: service.Health,
|
Health: service.Health,
|
||||||
|
Ready: service.Ready,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
deployment, err := deploymentConfiguration.CreateDeployment(ctx, namespace, application, appLabels)
|
deployment, err := deploymentConfiguration.CreateDeployment(ctx, namespace, application, appLabels)
|
||||||
|
@ -18,6 +18,7 @@ type DeploymentConfiguration struct {
|
|||||||
type ImageReference struct {
|
type ImageReference struct {
|
||||||
Image string
|
Image string
|
||||||
Health string
|
Health string
|
||||||
|
Ready string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (deployment *DeploymentConfiguration) CreateDeployment(
|
func (deployment *DeploymentConfiguration) CreateDeployment(
|
||||||
@ -72,6 +73,12 @@ func (deployment *DeploymentConfiguration) CreateDeployment(
|
|||||||
InitialDelaySeconds: pulumi.Int(70),
|
InitialDelaySeconds: pulumi.Int(70),
|
||||||
PeriodSeconds: pulumi.Int(15),
|
PeriodSeconds: pulumi.Int(15),
|
||||||
},
|
},
|
||||||
|
ReadinessProbe: &v1.ProbeArgs{
|
||||||
|
HttpGet: &v1.HTTPGetActionArgs{
|
||||||
|
Path: pulumi.String(deployment.ImageReference.Ready),
|
||||||
|
Port: pulumi.Int(80),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user