Skip to content

Commit c3e2234

Browse files
authored
Allow container resource limits to be configured in the Operator Helm chart (#536)
1 parent 0d70dc1 commit c3e2234

File tree

7 files changed

+171
-115
lines changed

7 files changed

+171
-115
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ kind-single-worker: ## Run a KinD cluster with a single worker node
14851485
.PHONY: kind-calico
14861486
kind-calico: export KIND_CONFIG=$(SCRIPTS_DIR)/kind-config-calico.yaml
14871487
kind-calico: ## Run a KinD cluster with Calico
1488-
kind create cluster --name $(KIND_CLUSTER) --wait 10m --config $(SCRIPTS_DIR)/kind-config-calico.yaml --image $(KIND_IMAGE)
1488+
kind create cluster --name $(KIND_CLUSTER) --config $(SCRIPTS_DIR)/kind-config-calico.yaml --image $(KIND_IMAGE)
14891489
$(SCRIPTS_DIR)/kind-label-node.sh
14901490
curl -sL https://docs.projectcalico.org/manifests/calico.yaml | kubectl apply -f -
14911491
kubectl -n kube-system set env daemonset/calico-node FELIX_IGNORELOOSERPF=true

config/manager/manager.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ spec:
3838
name: webhook-server
3939
protocol: TCP
4040
- containerPort: 8080
41-
name: metrics-server
41+
name: metrics
4242
protocol: TCP
4343
- containerPort: 8088
44-
name: health-server
44+
name: health
4545
protocol: TCP
4646
args:
4747
- --enable-leader-election
@@ -71,8 +71,16 @@ spec:
7171
name: cert
7272
readOnly: true
7373
readinessProbe:
74-
tcpSocket:
75-
port: metrics-server
74+
httpGet:
75+
port: health
76+
path: /readyz
77+
initialDelaySeconds: 10
78+
periodSeconds: 10
79+
failureThreshold: 3
80+
livenessProbe:
81+
httpGet:
82+
port: health
83+
path: /healthz
7684
initialDelaySeconds: 10
7785
periodSeconds: 10
7886
failureThreshold: 3

config/manager/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
ports:
3838
- name: http-rest
3939
port: 8000
40-
targetPort: 8000
40+
targetPort: operator
4141
selector:
4242
app.kubernetes.io/name: coherence-operator
4343
app.kubernetes.io/instance: coherence-operator-manager

helm-charts/coherence-operator/templates/deployment.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,33 @@ spec:
137137
containerPort: 9443
138138
protocol: TCP
139139
- containerPort: 8080
140-
name: metrics-server
140+
name: metrics
141141
protocol: TCP
142142
- containerPort: 8088
143-
name: health-server
143+
name: health
144144
protocol: TCP
145145
volumeMounts:
146146
- mountPath: /tmp/k8s-webhook-server/serving-certs
147147
name: cert
148148
readOnly: true
149149
readinessProbe:
150-
tcpSocket:
151-
port: metrics-server
150+
httpGet:
151+
port: health
152+
path: /readyz
152153
initialDelaySeconds: {{ default 10 .Values.readinessProbe.initialDelaySeconds }}
153154
periodSeconds: {{ default 10 .Values.readinessProbe.periodSeconds }}
154155
failureThreshold: {{ default 3 .Values.readinessProbe.failureThreshold }}
156+
livenessProbe:
157+
httpGet:
158+
port: health
159+
path: /healthz
160+
initialDelaySeconds: {{ default 10 .Values.livenessProbe.initialDelaySeconds }}
161+
periodSeconds: {{ default 10 .Values.livenessProbe.periodSeconds }}
162+
failureThreshold: {{ default 3 .Values.livenessProbe.failureThreshold }}
163+
{{- if .Values.resources }}
164+
resources:
165+
{{ toYaml .Values.resources | indent 10 }}
166+
{{- end }}
155167
{{- if .Values.imagePullSecrets }}
156168
imagePullSecrets:
157169
{{ toYaml .Values.imagePullSecrets | indent 8 }}

helm-charts/coherence-operator/values.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020, 2021 Oracle Corporation and/or its affiliates.
1+
# Copyright 2020, 2022, Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# http://oss.oracle.com/licenses/upl.
44

@@ -89,6 +89,18 @@ serviceAccountName: coherence-operator
8989

9090
# The optional settings to adjust the readiness probe timings for the Operator
9191
readinessProbe:
92+
# initialDelaySeconds is the number of seconds after the container has started before readiness probes are initiated.
93+
# More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
94+
initialDelaySeconds: 10
95+
# periodSeconds is how often (in seconds) to perform the probe.
96+
# Default to 10 seconds. Minimum value is 1.
97+
periodSeconds: 10
98+
# failureThreshold is the minimum consecutive failures for the probe to be considered failed after having succeeded.
99+
# Defaults to 3. Minimum value is 1.
100+
failureThreshold: 3
101+
102+
# The optional settings to adjust the liveness probe timings for the Operator
103+
livenessProbe:
92104
# initialDelaySeconds is the number of seconds after the container has started before liveness probes are initiated.
93105
# More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
94106
initialDelaySeconds: 10
@@ -99,6 +111,28 @@ readinessProbe:
99111
# Defaults to 3. Minimum value is 1.
100112
failureThreshold: 3
101113

114+
# resources will configure the Coherence Operator container's resource limits.
115+
# The resources can be specified in a values file, the same as they would be
116+
# for a container in a k8s Pod spec, for example:
117+
#
118+
# resources:
119+
# requests:
120+
# memory: "64Mi"
121+
# cpu: "250m"
122+
# limits:
123+
# memory: "128Mi"
124+
# cpu: "500m"
125+
#
126+
# Or, alternatively they can be specified individually using the Helm install --set option, for example
127+
#
128+
# helm install --set resources.requests.memory="64Mi" \
129+
# -- set resources.requests.cpu="250m"
130+
# -- set resources.limits.memory="128Mi"
131+
# -- set resources.limits.cpu="250m"
132+
#
133+
# ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
134+
resources:
135+
102136
# clusterRoles controls whether the Helm chart will create RBAC ClusterRole and bindings for the Operator
103137
# These are required if the Operator will watch multiple namespaces.
104138
# If set to false then the Operator will only watch the namespace it is deployed into.

main.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818
"github.com/spf13/pflag"
1919
"github.com/spf13/viper"
2020
"k8s.io/apimachinery/pkg/util/version"
21+
"net/http"
2122
"os"
2223
"runtime"
2324
"sigs.k8s.io/controller-runtime/pkg/cache"
2425
"sigs.k8s.io/controller-runtime/pkg/client"
26+
"sigs.k8s.io/controller-runtime/pkg/healthz"
2527
logf "sigs.k8s.io/controller-runtime/pkg/log"
2628
"strings"
2729

@@ -188,20 +190,25 @@ func execute() {
188190
}
189191

190192
// Create the REST server
191-
if err := rest.NewServer(cs).SetupWithManager(mgr); err != nil {
193+
restServer := rest.NewServer(cs)
194+
if err := restServer.SetupWithManager(mgr); err != nil {
192195
setupLog.Error(err, " unable to start REST server")
193196
os.Exit(1)
194197
}
195198

196-
//// ToDo: Make the ready check actually check stuff...
197-
//if err := mgr.AddHealthzCheck("health", healthz.Ping); err != nil {
198-
// setupLog.Error(err, "unable to set up health check")
199-
// os.Exit(1)
200-
//}
201-
//if err := mgr.AddReadyzCheck("check", healthz.Ping); err != nil {
202-
// setupLog.Error(err, "unable to set up ready check")
203-
// os.Exit(1)
204-
//}
199+
var health healthz.Checker = func(_ *http.Request) error {
200+
<-restServer.Running()
201+
return nil
202+
}
203+
204+
if err := mgr.AddHealthzCheck("health", health); err != nil {
205+
setupLog.Error(err, "unable to set up health check")
206+
os.Exit(1)
207+
}
208+
if err := mgr.AddReadyzCheck("ready", health); err != nil {
209+
setupLog.Error(err, "unable to set up ready check")
210+
os.Exit(1)
211+
}
205212

206213
// +kubebuilder:scaffold:builder
207214

0 commit comments

Comments
 (0)