Skip to content

Commit

Permalink
Pass targetIPs to service-backend
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 3, 2024
1 parent 320c419 commit e5e1c7e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apis/installer/v1alpha1/ace_service_backend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type ServiceBackendSpec struct {
Ingress AppIngress `json:"ingress"`
Monitoring Monitoring `json:"monitoring"`
Server ServerConfig `json:"server"`
// +optional
DNS ServiceBackendDns `json:"dns"`
}

type ServerConfig struct {
Expand All @@ -99,6 +101,11 @@ type Cookie struct {
EncryptionKey string `json:"encryptionKey"`
}

type ServiceBackendDns struct {
// +optional
TargetIPs []string `json:"targetIPs"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ServiceBackendList is a list of ServiceBackends
Expand Down
21 changes: 21 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
{{ $_ := set $overrides.helm "repositories" $helmrepos }}
{{ $_ := set $overrides.helm "createNamespace" $.Values.helm.createNamespace }}

{{ $targetIPs := dig "releases" "ace" "values" "global" "infra" "dns" "targetIPs" list $.Values.helm }}
{{ if $targetIPs }}
{{ $hrs := printf `
service-backend:
values:
dns:
targetIPs: %v
`
($targetIPs | toJson)
| fromYaml }}
{{ $_ := set $overrides.helm "releases" $hrs }}
{{ end }}
{{ $vals := dig "values" dict . }}
{{ $vals = mergeOverwrite $vals $overrides }}
Expand Down
1 change: 1 addition & 0 deletions charts/service-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The following table lists the configurable parameters of the `service-backend` c
| server.consumerScope | How consumers access the service provider cluster. In Kubernetes, "namespaced" allows namespace isolation. In kcp, "cluster" allows workspace isolation, and with that allows cluster-scoped resources to bind, and it is generally more performant. | <code>"Namespaced"</code> |
| server.cookie.signingKey | The key which is used to sign cookies, base64 encoded. Valid lengths are 32 or 64 bytes. | <code>""</code> |
| server.cookie.encryptionKey | The key which is used to encrypt cookies, base64 encoded, optional. Valid lengths are 16, 24, or 32 bytes selecting AES-128, AES-192, or AES-256. | <code>""</code> |
| dns.targetIPs | | <code>[]</code> |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:
Expand Down
6 changes: 6 additions & 0 deletions charts/service-backend/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "service-backend.fullname" . -}}
{{- $svcPort := .Values.service.port -}}

{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}

{{- if and (not (hasKey .Values.ingress.annotations "external-dns.alpha.kubernetes.io/target")) .Values.dns.targetIPs }}
{{- $_ := set .Values.ingress.annotations "external-dns.alpha.kubernetes.io/target" (join "," .Values.dns.targetIPs)}}
{{- end }}

{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
Expand Down
7 changes: 7 additions & 0 deletions charts/service-backend/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ properties:
- maxReplicas
- minReplicas
type: object
dns:
properties:
targetIPs:
items:
type: string
type: array
type: object
fullnameOverride:
type: string
image:
Expand Down
3 changes: 3 additions & 0 deletions charts/service-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ server:
signingKey: ""
# The key which is used to encrypt cookies, base64 encoded, optional. Valid lengths are 16, 24, or 32 bytes selecting AES-128, AES-192, or AES-256.
encryptionKey: ""

dns:
targetIPs: []

0 comments on commit e5e1c7e

Please sign in to comment.