Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 275: Made changes for configuring probes #290

Merged
merged 4 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions charts/zookeeper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ The following table lists the configurable parameters of the zookeeper chart and
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `domainName` | External host name appended for dns annotation | |
| `kubernetesClusterDomain` | Domain of the kubernetes cluster | `cluster.local` |
| `probes.readiness.initialDelaySeconds` | Number of seconds after the container has started before readiness probe is initiated | `10` |
| `probes.readiness.periodSeconds` | Number of seconds in which readiness probe will be performed | `10` |
| `probes.readiness.failureThreshold` | Number of seconds after which the readiness probe times out | `3` |
| `probes.readiness.successThreshold` | Minimum number of consecutive successes for the readiness probe to be considered successful after having failed | `1` |
| `probes.readiness.timeoutSeconds` | Number of times Kubernetes will retry after a readiness probe failure before restarting the container | `10` |
| `probes.liveness.initialDelaySeconds` | Number of seconds after the container has started before liveness probe is initiated | `10` |
| `probes.liveness.periodSeconds` | Number of seconds in which liveness probe will be performed | `10` |
| `probes.liveness.failureThreshold` | Number of seconds after which the liveness probe times out | `3` |
| `probes.liveness.timeoutSeconds` | Number of times Kubernetes will retry after a liveness probe failure before restarting the container | `10` |
| `labels` | Specifies the labels to be attached | `{}` |
| `ports` | Groups the ports for a zookeeper cluster node for easy access | `[]` |
| `pod` | Defines the policy to create new pods for the zookeeper cluster | `{}` |
Expand Down
18 changes: 18 additions & 0 deletions charts/zookeeper/templates/zookeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ spec:
domainName: {{ .Values.domainName }}
{{- end }}
kubernetesClusterDomain: {{ default "cluster.local" .Values.kubernetesClusterDomain }}
{{- if .Values.probes }}
probes:
{{- if .Values.probes.readiness }}
readinessProbe:
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds | default 10 }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds | default 10 }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold | default 3}}
successThreshold: {{ .Values.probes.readiness.successThreshold | default 1 }}
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds | default 10}}
{{- end }}
{{- if .Values.probes.liveness }}
livenessProbe:
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds | default 10 }}
periodSeconds: {{ .Values.probes.liveness.periodSeconds | default 10 }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold | default 3 }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds | default 10 }}
{{- end }}
{{- end }}
{{- if .Values.containers }}
containers:
{{ toYaml .Values.containers | indent 4 }}
Expand Down
17 changes: 14 additions & 3 deletions charts/zookeeper/values.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
replicas: 3

image:
repository: pravega/zookeeper
tag: 0.2.9
repository: devops-repo.isus.emc.com:8116/nautilus/zookeeper
Prabhaker24 marked this conversation as resolved.
Show resolved Hide resolved
tag: 0.2.9-162-9bdc9a2
Prabhaker24 marked this conversation as resolved.
Show resolved Hide resolved
pullPolicy: IfNotPresent

domainName:
labels: {}
ports: []
kubernetesClusterDomain: "cluster.local"

probes:
readiness:
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
successThreshold: 1
timeoutSeconds: 10
liveness:
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 10
pod:
# labels: {}
# nodeSelector: {}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
dmitri.shuralyov.com/go/generated v0.0.0-20170818220700-b1254a446363 // indirect
github.com/alexkohler/nakedret v1.0.0 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logr/logr v0.1.0
github.com/gordonklaus/ineffassign v0.0.0-20201107091007-3b93a8888063 // indirect
Expand All @@ -16,10 +17,9 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/common v0.9.1
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 // indirect
github.com/sirupsen/logrus v1.5.0
github.com/stripe/safesql v0.2.0 // indirect
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/tools v0.0.0-20200331202046-9d5940d49312 // indirect
k8s.io/api v0.17.5
k8s.io/apimachinery v0.17.5
k8s.io/client-go v12.0.0+incompatible
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alexkohler/nakedret v1.0.0 h1:S/bzOFhZHYUJp6qPmdXdFHS5nlWGFmLmoc8QOydvotE=
github.com/alexkohler/nakedret v1.0.0/go.mod h1:tfDQbtPt67HhBK/6P0yNktIX7peCxfOp0jO9007DrLE=
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
Expand Down Expand Up @@ -492,13 +494,15 @@ github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kshvakov/clickhouse v1.3.5/go.mod h1:DMzX7FxRymoNkVgizH0DWAL8Cur7wHLgx3MUnGwJqpE=
github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/leanovate/gopter v0.2.4/go.mod h1:gNcbPWNEWRe4lm+bycKqxUYoH5uoVje5SkOJ3uoLer8=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.0/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
Expand Down Expand Up @@ -573,6 +577,7 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mozilla/tls-observatory v0.0.0-20200317151703-4fa42e1c2dee/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
github.com/mozillazg/go-cos v0.13.0/go.mod h1:Zp6DvvXn0RUOXGJ2chmWt2bLEqRAnJnS3DnAZsJsoaE=
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
Expand All @@ -581,6 +586,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v0.0.0-20170117200651-66bb6560562f/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
Expand Down Expand Up @@ -721,6 +728,8 @@ github.com/satori/go.uuid v0.0.0-20160603004225-b111a074d5ef/go.mod h1:dA0hQrYB0
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 h1:rq2/kILQnPtq5oL4+IAjgVOjh5e2yj2aaCYi7squEvI=
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989/go.mod h1:i9l/TNj+yDFh9SZXUTvspXTjbFXgZGP/UvhU1S65A4A=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
Expand Down
84 changes: 84 additions & 0 deletions pkg/apis/zookeeper/v1beta1/zookeepercluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,42 @@ const (
// DefaultZookeeperCacheVolumeSize is the default volume size for the
// Zookeeper cache volume
DefaultZookeeperCacheVolumeSize = "20Gi"

// DefaultReadinessProbeInitialDelaySeconds is the default initial delay (in seconds)
// for the readiness probe
DefaultReadinessProbeInitialDelaySeconds = 10

// DefaultReadinessProbePeriodSeconds is the default probe period (in seconds)
// for the readiness probe
DefaultReadinessProbePeriodSeconds = 10

// DefaultReadinessProbeFailureThreshold is the default probe failure threshold
// for the readiness probe
DefaultReadinessProbeFailureThreshold = 3

// DefaultReadinessProbeSuccessThreshold is the default probe success threshold
// for the readiness probe
DefaultReadinessProbeSuccessThreshold = 1

// DefaultReadinessProbeTimeoutSeconds is the default probe timeout (in seconds)
// for the readiness probe
DefaultReadinessProbeTimeoutSeconds = 10

// DefaultLivenessProbeInitialDelaySeconds is the default initial delay (in seconds)
// for the liveness probe
DefaultLivenessProbeInitialDelaySeconds = 10

// DefaultLivenessProbePeriodSeconds is the default probe period (in seconds)
// for the liveness probe
DefaultLivenessProbePeriodSeconds = 10

// DefaultLivenessProbeFailureThreshold is the default probe failure threshold
// for the liveness probe
DefaultLivenessProbeFailureThreshold = 3

// DefaultLivenessProbeTimeoutSeconds is the default probe timeout (in seconds)
// for the liveness probe
DefaultLivenessProbeTimeoutSeconds = 10
)

// ZookeeperClusterSpec defines the desired state of ZookeeperCluster
Expand Down Expand Up @@ -93,6 +129,15 @@ type ZookeeperClusterSpec struct {

// Volumes defines to support customized volumes
Volumes []v1.Volume `json:"volumes,omitempty"`

// Probes specifies the timeout values for the Readiness and Liveness Probes
// for the bookkeeper pods.
Probes *Probes `json:"probes"`
}

type Probes struct {
ReadinessProbe *Probe `json:"readinessProbe"`
LivenessProbe *Probe `json:"livenessProbe"`
}

func (s *ZookeeperClusterSpec) withDefaults(z *ZookeeperCluster) (changed bool) {
Expand All @@ -104,6 +149,14 @@ func (s *ZookeeperClusterSpec) withDefaults(z *ZookeeperCluster) (changed bool)
s.Replicas = 3
changed = true
}
if s.Probes == nil {
changed = true
s.Probes = &Probes{}
}
if s.Probes.withDefaults() {
changed = true
}

if s.Ports == nil {
s.Ports = []v1.ContainerPort{
{
Expand Down Expand Up @@ -196,6 +249,14 @@ func (s *ZookeeperClusterSpec) withDefaults(z *ZookeeperCluster) (changed bool)
return changed
}

type Probe struct {
InitialDelaySeconds int32 `json:"initialDelaySeconds"`
PeriodSeconds int32 `json:"periodSeconds"`
FailureThreshold int32 `json:"failureThreshold"`
SuccessThreshold int32 `json:"successThreshold"`
TimeoutSeconds int32 `json:"timeoutSeconds"`
}

// Generate CRD using kubebuilder
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down Expand Up @@ -395,6 +456,29 @@ func (p *PodPolicy) withDefaults(z *ZookeeperCluster) (changed bool) {
return changed
}

func (s *Probes) withDefaults() (changed bool) {
if s.ReadinessProbe == nil {
changed = true
s.ReadinessProbe = &Probe{}
s.ReadinessProbe.InitialDelaySeconds = DefaultReadinessProbeInitialDelaySeconds
s.ReadinessProbe.PeriodSeconds = DefaultReadinessProbePeriodSeconds
s.ReadinessProbe.FailureThreshold = DefaultReadinessProbeFailureThreshold
s.ReadinessProbe.SuccessThreshold = DefaultReadinessProbeSuccessThreshold
s.ReadinessProbe.TimeoutSeconds = DefaultReadinessProbeTimeoutSeconds
}

if s.LivenessProbe == nil {
changed = true
s.LivenessProbe = &Probe{}
s.LivenessProbe.InitialDelaySeconds = DefaultLivenessProbeInitialDelaySeconds
s.LivenessProbe.PeriodSeconds = DefaultLivenessProbePeriodSeconds
s.LivenessProbe.FailureThreshold = DefaultLivenessProbeFailureThreshold
s.LivenessProbe.TimeoutSeconds = DefaultLivenessProbeTimeoutSeconds
}

return changed
}

// ZookeeperConfig is the current configuration of each Zookeeper node, which
// sets these values in the config-map
type ZookeeperConfig struct {
Expand Down
15 changes: 11 additions & 4 deletions pkg/zk/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,22 @@ func makeZkPodSpec(z *v1beta1.ZookeeperCluster, volumes []v1.Volume) v1.PodSpec
},
ImagePullPolicy: z.Spec.Image.PullPolicy,
ReadinessProbe: &v1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 10,
InitialDelaySeconds: z.Spec.Probes.ReadinessProbe.InitialDelaySeconds,
PeriodSeconds: z.Spec.Probes.ReadinessProbe.PeriodSeconds,
TimeoutSeconds: z.Spec.Probes.ReadinessProbe.TimeoutSeconds,
FailureThreshold: z.Spec.Probes.ReadinessProbe.FailureThreshold,
SuccessThreshold: z.Spec.Probes.ReadinessProbe.SuccessThreshold,

Handler: v1.Handler{
Exec: &v1.ExecAction{Command: []string{"zookeeperReady.sh"}},
},
},
LivenessProbe: &v1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 10,
InitialDelaySeconds: z.Spec.Probes.LivenessProbe.InitialDelaySeconds,
PeriodSeconds: z.Spec.Probes.LivenessProbe.PeriodSeconds,
TimeoutSeconds: z.Spec.Probes.LivenessProbe.TimeoutSeconds,
FailureThreshold: z.Spec.Probes.LivenessProbe.FailureThreshold,

Handler: v1.Handler{
Exec: &v1.ExecAction{Command: []string{"zookeeperLive.sh"}},
},
Expand Down