Skip to content

Commit

Permalink
add urlrewite for api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaliMatharaarachchi committed Sep 24, 2024
1 parent 5a3683c commit 20c3dc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ func (r *ResourceRender) Service() (*corev1.Service, error) {
}

for _, port := range config.ReadConfigs().Deployment.Gateway.EnforcerPorts {
p := corev1.ServicePort{
Name: ExpectedResourceHashedName(port.Name),
Protocol: corev1.ProtocolTCP,
Port: port.ContainerPort,
TargetPort: intstr.IntOrString{IntVal: port.ContainerPort},
if port.Expose {
p := corev1.ServicePort{
Name: ExpectedResourceHashedName(port.Name),
Protocol: corev1.ProtocolTCP,
Port: port.ContainerPort,
TargetPort: intstr.IntOrString{IntVal: port.ContainerPort},
}
ports = append(ports, p)
}
ports = append(ports, p)
}

// Set the labels based on the owning gatewayclass name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ func (r *gatewayReconcilerNew) processHTTPRoutes(ctx context.Context, gatewayNam
newMatches = append(newMatches, match)
}
rule.Matches = newMatches
rule.Filters = append(rule.Filters,
gwapiv1.HTTPRouteFilter{
Type: gwapiv1.HTTPRouteFilterURLRewrite,
URLRewrite: &gwapiv1.HTTPURLRewriteFilter{
Path: &gwapiv1.HTTPPathModifier{
Type: gwapiv1.PrefixMatchHTTPPathModifier,
ReplacePrefixMatch: &api.Spec.BasePath,
},
},
},
)
newRules = append(newRules, rule)
}
hr.Spec.Rules = newRules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ data:
javaOpts = "{{ .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.javaOpts }}"
{{- end }}
{{- range .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.ports}}
{{- if and .name .value }}
[[deployment.gateway.enforcerPorts]]
name = "{{ .name }}"
containerPort = {{ .value }}
expose = {{ .expose | default false }}
{{- end }}
{{- end }}
{{- end }}
[deployment.gateway.volumes]
ratelimiterTruststoreSecretVolume = "{{ template "apk-helm.resource.prefix" . }}-ratelimiter-server-cert"
Expand Down

0 comments on commit 20c3dc8

Please sign in to comment.