Skip to content

Commit

Permalink
Made changes for configuring probes
Browse files Browse the repository at this point in the history
Signed-off-by: anishakj <[email protected]>
  • Loading branch information
anishakj committed Jan 11, 2021
1 parent ce7b41d commit 22a0b33
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 9 deletions.
10 changes: 10 additions & 0 deletions charts/zookeeper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ 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.successThreshold` | Minimum number of consecutive successes for the liveness probe to be considered successful after having failed | `1` |
| `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
tag: 0.2.9-162-9bdc9a2
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

0 comments on commit 22a0b33

Please sign in to comment.