util/kubernetes: add readiness check to deployments (#1923)
This commit is contained in:
parent
959407bad9
commit
1263806a39
@ -321,6 +321,13 @@ func NewDeployment(name, version, typ, namespace string) *Deployment {
|
||||
Name: "service-port",
|
||||
ContainerPort: 8080,
|
||||
}},
|
||||
ReadinessProbe: &Probe{
|
||||
TCPSocket: TCPSocketAction{
|
||||
Port: 8080,
|
||||
},
|
||||
PeriodSeconds: 10,
|
||||
InitialDelaySeconds: 10,
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
|
@ -92,8 +92,22 @@ spec:
|
||||
name: {{ .Name }}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- if .ReadinessProbe }}
|
||||
{{- with .ReadinessProbe }}
|
||||
readinessProbe:
|
||||
{{- with .TCPSocket }}
|
||||
tcpSocket:
|
||||
{{- if .Host }}
|
||||
host: {{ .Host }}
|
||||
{{- end }}
|
||||
port: {{ .Port }}
|
||||
{{- end }}
|
||||
initialDelaySeconds: {{ .InitialDelaySeconds }}
|
||||
periodSeconds: {{ .PeriodSeconds }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
`
|
||||
|
||||
var serviceTmpl = `
|
||||
|
@ -41,6 +41,7 @@ type Container struct {
|
||||
Command []string `json:"command,omitempty"`
|
||||
Args []string `json:"args,omitempty"`
|
||||
Ports []ContainerPort `json:"ports,omitempty"`
|
||||
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`
|
||||
}
|
||||
|
||||
// DeploymentSpec defines micro deployment spec
|
||||
@ -220,3 +221,16 @@ type ServiceAccount struct {
|
||||
Metadata *Metadata `json:"metadata,omitempty"`
|
||||
ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets,omitempty"`
|
||||
}
|
||||
|
||||
// Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.
|
||||
type Probe struct {
|
||||
TCPSocket TCPSocketAction `json:"tcpSocket,omitempty"`
|
||||
PeriodSeconds int `json:"periodSeconds"`
|
||||
InitialDelaySeconds int `json:"initialDelaySeconds"`
|
||||
}
|
||||
|
||||
// TCPSocketAction describes an action based on opening a socket
|
||||
type TCPSocketAction struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Port int `json:"port,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user