Skip to content

Commit 0e5923e

Browse files
authored
Merge branch 'main' into sah/container-log-opts
2 parents 7703c43 + d1191f5 commit 0e5923e

13 files changed

+487
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export VERSION
3939
SOURCES := $(shell find . -name "*.go" | grep -v test.go)
4040

4141
# Note: When bumping this version, update the version in pkg/validator/validator.go as well.
42-
export ENVOY_IMAGE ?= quay.io/solo-io/envoy-gloo:1.35.2-patch1
42+
export ENVOY_IMAGE ?= quay.io/solo-io/envoy-gloo:1.35.2-patch4
4343
export LDFLAGS := -X 'github.com/kgateway-dev/kgateway/v2/internal/version.Version=$(VERSION)'
4444
export GCFLAGS ?=
4545

internal/kgateway/helm/kgateway/templates/gateway/agent-gateway-deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ spec:
1818
template:
1919
metadata:
2020
annotations:
21+
prometheus.io/path: /metrics
22+
prometheus.io/port: "15020"
23+
prometheus.io/scrape: "true"
2124
{{- with $gateway.extraPodAnnotations }}
2225
{{- toYaml . | nindent 8 }}
2326
{{- end }}

pkg/deployer/gateway_parameters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ func GetInMemoryGatewayParameters(name string, imageInfo *ImageInfo, gatewayClas
133133
// set for the agentgateway deployment.
134134
func defaultAgentgatewayParameters(imageInfo *ImageInfo, omitDefaultSecurityContext bool) *v1alpha1.GatewayParameters {
135135
gwp := defaultGatewayParameters(imageInfo, omitDefaultSecurityContext)
136+
// Leave unset to allow HPA, etc
137+
gwp.Spec.Kube.Deployment.Replicas = nil
136138
gwp.Spec.Kube.Agentgateway.Enabled = ptr.To(true)
137139
gwp.Spec.Kube.PodTemplate.ReadinessProbe.HTTPGet.Path = "/healthz/ready"
138140
gwp.Spec.Kube.PodTemplate.ReadinessProbe.HTTPGet.Port = intstr.FromInt(15021)

pkg/deployer/merge.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ func deepMergeProbe(dst, src *corev1.Probe) *corev1.Probe {
330330
}
331331

332332
func deepMergeProbeHandler(dst, src corev1.ProbeHandler) corev1.ProbeHandler {
333+
srcHasExecAction := src.Exec != nil
334+
srcHasHTTPGetAction := src.HTTPGet != nil
335+
srcHasTCPSocketAction := src.TCPSocket != nil
336+
srcHasGRPCAction := src.GRPC != nil
337+
srcHasAction := srcHasExecAction || srcHasHTTPGetAction || srcHasTCPSocketAction || srcHasGRPCAction
338+
if srcHasAction {
339+
// Reset the dest so it does not conflict with the src Action as there should only be one Action defined per probe
340+
dst.Exec = nil
341+
dst.HTTPGet = nil
342+
dst.TCPSocket = nil
343+
dst.GRPC = nil
344+
}
345+
// kube-builder validation ensures that the src has only one action
333346
dst.Exec = deepMergeExecAction(dst.Exec, src.Exec)
334347
dst.HTTPGet = deepMergeHTTPGetAction(dst.HTTPGet, src.HTTPGet)
335348
dst.TCPSocket = deepMergeTCPSocketAction(dst.TCPSocket, src.TCPSocket)

pkg/deployer/merge_test.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/assert"
7+
corev1 "k8s.io/api/core/v1"
8+
"k8s.io/apimachinery/pkg/util/intstr"
79
"k8s.io/utils/ptr"
810

911
gw2_v1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1"
@@ -227,6 +229,92 @@ func TestDeepMergeGatewayParameters(t *testing.T) {
227229
assert.Equal(t, expectedMap, got.Spec.Kube.ServiceAccount.ExtraAnnotations)
228230
},
229231
},
232+
{
233+
name: "should have only one probeHandler action",
234+
dst: &gw2_v1alpha1.GatewayParameters{
235+
Spec: gw2_v1alpha1.GatewayParametersSpec{
236+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
237+
PodTemplate: &gw2_v1alpha1.Pod{
238+
StartupProbe: &corev1.Probe{
239+
ProbeHandler: corev1.ProbeHandler{
240+
Exec: &corev1.ExecAction{
241+
Command: []string{"exec", "command"},
242+
},
243+
},
244+
},
245+
},
246+
},
247+
},
248+
},
249+
src: &gw2_v1alpha1.GatewayParameters{
250+
Spec: gw2_v1alpha1.GatewayParametersSpec{
251+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
252+
PodTemplate: &gw2_v1alpha1.Pod{
253+
StartupProbe: &corev1.Probe{
254+
ProbeHandler: corev1.ProbeHandler{
255+
TCPSocket: &corev1.TCPSocketAction{
256+
Port: intstr.FromString("8080"),
257+
},
258+
},
259+
},
260+
},
261+
},
262+
},
263+
},
264+
want: &gw2_v1alpha1.GatewayParameters{
265+
Spec: gw2_v1alpha1.GatewayParametersSpec{
266+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
267+
PodTemplate: &gw2_v1alpha1.Pod{
268+
StartupProbe: &corev1.Probe{
269+
ProbeHandler: corev1.ProbeHandler{
270+
TCPSocket: &corev1.TCPSocketAction{
271+
Port: intstr.FromString("8080"),
272+
},
273+
},
274+
},
275+
},
276+
},
277+
},
278+
},
279+
},
280+
{
281+
name: "should merge the default probeHandler action if none specified",
282+
dst: &gw2_v1alpha1.GatewayParameters{
283+
Spec: gw2_v1alpha1.GatewayParametersSpec{
284+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
285+
PodTemplate: &gw2_v1alpha1.Pod{
286+
StartupProbe: &corev1.Probe{
287+
ProbeHandler: corev1.ProbeHandler{
288+
Exec: &corev1.ExecAction{
289+
Command: []string{"exec", "command"},
290+
},
291+
},
292+
},
293+
},
294+
},
295+
},
296+
},
297+
src: &gw2_v1alpha1.GatewayParameters{
298+
Spec: gw2_v1alpha1.GatewayParametersSpec{
299+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{},
300+
},
301+
},
302+
want: &gw2_v1alpha1.GatewayParameters{
303+
Spec: gw2_v1alpha1.GatewayParametersSpec{
304+
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
305+
PodTemplate: &gw2_v1alpha1.Pod{
306+
StartupProbe: &corev1.Probe{
307+
ProbeHandler: corev1.ProbeHandler{
308+
Exec: &corev1.ExecAction{
309+
Command: []string{"exec", "command"},
310+
},
311+
},
312+
},
313+
},
314+
},
315+
},
316+
},
317+
},
230318
}
231319

232320
for _, tt := range tests {

pkg/validator/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
var (
1414
defaultEnvoyPath = "/usr/local/bin/envoy"
1515
// TODO(tim): avoid hardcoding the envoy image version in multiple places.
16-
defaultEnvoyImage = "quay.io/solo-io/envoy-gloo:1.35.2-patch1"
16+
defaultEnvoyImage = "quay.io/solo-io/envoy-gloo:1.35.2-patch4"
1717
)
1818

1919
// ErrInvalidXDS is returned when Envoy rejects the supplied YAML.

pkg/validator/validator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func TestExtractEnvoyError(t *testing.T) {
238238
},
239239
{
240240
name: "docker pull logs present",
241-
input: `Unable to find image 'quay.io/solo-io/envoy-gloo:1.35.2-patch1' locally
241+
input: `Unable to find image 'quay.io/solo-io/envoy-gloo:1.35.2-patch4' locally
242242
1.35.2-patch1: Pulling from solo-io/envoy-gloo
243243
f90c8eb4724c: Pulling fs layer
244244
9f37c34398c2: Pulling fs layer
@@ -257,16 +257,16 @@ f90c8eb4724c: Pull complete
257257
1cc4dfe322cb: Pull complete
258258
e800bbdc2f77: Pull complete
259259
Digest: sha256:98c645568997299a1c4301e6077a1d2f566bb20828c0739e6c4177a821524dad
260-
Status: Downloaded newer image for quay.io/solo-io/envoy-gloo:1.35.2-patch1
260+
Status: Downloaded newer image for quay.io/solo-io/envoy-gloo:1.35.2-patch4
261261
error initializing configuration '': invalid named capture group: (?<=foo)bar`,
262262
expected: "error initializing configuration '': invalid named capture group: (?<=foo)bar",
263263
},
264264
{
265265
name: "docker pull logs with multi-line error",
266-
input: `Unable to find image 'quay.io/solo-io/envoy-gloo:1.35.2-patch1' locally
266+
input: `Unable to find image 'quay.io/solo-io/envoy-gloo:1.35.2-patch4' locally
267267
1.35.2-patch1: Pulling from solo-io/envoy-gloo
268268
f90c8eb4724c: Pull complete
269-
Status: Downloaded newer image for quay.io/solo-io/envoy-gloo:1.35.2-patch1
269+
Status: Downloaded newer image for quay.io/solo-io/envoy-gloo:1.35.2-patch4
270270
error initializing configuration '': missing ]:
271271
at line 42 in filter configuration
272272
regex validation failed`,

test/deployer/internal_helm_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ func TestRenderHelmChart(t *testing.T) {
1515
InputFile: "base-gateway",
1616
},
1717
{
18-
Name: "gwparams with omitDefaultSecurityContext",
18+
Name: "gwparams with omitDefaultSecurityContext via GWC",
1919
InputFile: "omit-default-security-context",
2020
},
21+
{
22+
Name: "gwparams with omitDefaultSecurityContext via GW",
23+
InputFile: "omit-default-security-context-via-gw",
24+
},
2125
{
2226
Name: "agentgateway",
2327
InputFile: "agentgateway",

test/deployer/testdata/agentgateway-omitdefaultsecuritycontext-out.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ metadata:
7474
gateway.networking.k8s.io/gateway-class-name: agentgateway
7575
app.kubernetes.io/managed-by: Helm
7676
spec:
77-
replicas: 1
7877
selector:
7978
matchLabels:
8079
app.kubernetes.io/name: gw
@@ -83,6 +82,9 @@ spec:
8382
template:
8483
metadata:
8584
annotations:
85+
prometheus.io/path: /metrics
86+
prometheus.io/port: "15020"
87+
prometheus.io/scrape: "true"
8688
labels:
8789
app.kubernetes.io/name: gw
8890
app.kubernetes.io/instance: gw

test/deployer/testdata/agentgateway-omitdefaultsecuritycontext-ref-gwp-on-gw-out.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ metadata:
7474
gateway.networking.k8s.io/gateway-class-name: agentgateway
7575
app.kubernetes.io/managed-by: Helm
7676
spec:
77-
replicas: 1
7877
selector:
7978
matchLabels:
8079
app.kubernetes.io/name: gw
@@ -83,6 +82,9 @@ spec:
8382
template:
8483
metadata:
8584
annotations:
85+
prometheus.io/path: /metrics
86+
prometheus.io/port: "15020"
87+
prometheus.io/scrape: "true"
8688
labels:
8789
app.kubernetes.io/name: gw
8890
app.kubernetes.io/instance: gw

0 commit comments

Comments
 (0)