Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRY Gateway with domain transformation #138

Open
sebiklamar opened this issue Dec 28, 2024 · 1 comment
Open

DRY Gateway with domain transformation #138

sebiklamar opened this issue Dec 28, 2024 · 1 comment

Comments

@sebiklamar
Copy link
Collaborator

No description provided.

@sebiklamar
Copy link
Collaborator Author

sebiklamar commented Jan 1, 2025

Issue

Kustomize's transformers do not work with Gateway and Certificate because transformer code cannot cope with *.FQDN naming and with short domain (example.com instead of foo.example.comwith 1 domain component instead of 2 in addition to TLD). For the *.FQDN one could change the indices. For the latter (short FQDN) maybe do an additional split iteration.
Needless to say: no domain prefix transformation.

Source...

# base/gw-external.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: external
  namespace: gateway
spec:
  listeners:
    - hostname: "*.example.com"
...
    - hostname: example.com
...

... becomes in the overlay:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: dev-external
  namespace: gateway
spec:
  listeners:
  - hostname: '*.dev.iseja.net'
...   
  - hostname: example.dev.iseja.net

Transformer Code

Using the f. transformer code:

gateway-replace-hostname.yaml

# k8s/_transformers/replace-domain/repl/gateway-replace-hostname.yaml
- source:
    kind: ConfigMap
    name: cluster-param
    fieldPath: data.DOMAIN_TLD
  targets:
    - select:
        kind: Gateway
      fieldPaths:
        - spec.listeners.*.hostname
      options:
        delimiter: "."
        index: 2
- source:
    kind: ConfigMap
    name: cluster-param
    fieldPath: data.DOMAIN_BASE
  targets:
    - select:
        kind: Gateway
      fieldPaths:
        - spec.listeners.*.hostname
      options:
        delimiter: "."
        index: 1

certificate-replace-dnsNames.yaml

# k8s/_transformers/replace-domain/repl/certificate-replace-dnsNames.yaml
- source:
    kind: ConfigMap
    name: cluster-param
    fieldPath: data.DOMAIN_TLD
  targets:
    - select:
        kind: Certificate
      fieldPaths:
        - spec.dnsNames.*
      options:
        delimiter: "."
        index: 2
- source:
    kind: ConfigMap
    name: cluster-param
    fieldPath: data.DOMAIN_BASE
  targets:
    - select:
        kind: Certificate
      fieldPaths:
        - spec.dnsNames.*
      options:
        delimiter: "."
        index: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant