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

APIRule v1beta1 -> v2alpha1 conversion should add the domain to the host name (if it is not FQDN) #1166

Open
6 tasks
mluk-sap opened this issue Jul 16, 2024 · 1 comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@mluk-sap
Copy link
Contributor

Description

The host name in APIRule v2alpha1 is expected to be in FQDN format, while in v1beta1 it could be provided in a short name (only host without domain).
It would be nice to enhance a conversion webhook, so it adds the domain automatically during conversion from v1beta1 to v2alpha1.

Reasons

It is now still possible to still have a host without domain in v2alpha1 if it is converted from v1beta1.

How to reproduce it:

cat <<EOF | kubectl apply -f -
apiVersion: gateway.kyma-project.io/v1beta1
kind: APIRule
metadata:
  name: httpbin-rule
  namespace: default
spec:
  host: httpbin
  service:
    name: httpbin
    namespace: default
    port: 8000
  gateway: kyma-gateway
  rules:
    - path: /.*
      methods: ["GET"]
      accessStrategies:
        - handler: no_auth
    - path: /post
      methods: ["POST"]
      accessStrategies:
        - handler: no_auth
EOF

Get the apirule resource in v2alpha1:

kubectl get apirules.v2alpha1.gateway.kyma-project.io -A -o yaml >apirule_converted.yaml

It gives:

apiVersion: v1
items:
- apiVersion: gateway.kyma-project.io/v2alpha1
  kind: APIRule
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"gateway.kyma-project.io/v1beta1","kind":"APIRule","metadata":{"annotations":{},"name":"httpbin-rule","namespace":"default"},"spec":{"gateway":"kyma-gateway","host":"httpbin","rules":[{"accessStrategies":[{"handler":"no_auth"}],"methods":["GET"],"path":"/.*"},{"accessStrategies":[{"handler":"no_auth"}],"methods":["POST"],"path":"/post"}],"service":{"name":"httpbin","namespace":"default","port":8000}}}
    creationTimestamp: "2024-07-15T11:22:18Z"
    finalizers:
    - gateway.kyma-project.io/subresources
    generation: 1
    name: httpbin-rule
    namespace: default
    resourceVersion: "5134"
    uid: 10de779e-a02f-4bbe-a4ca-4c2c0a47fb58
  spec:
    gateway: kyma-gateway
    hosts:
    - httpbin
    rules:
    - methods:
      - GET
      noAuth: true
      path: /.*
    - methods:
      - POST
      noAuth: true
      path: /post
    service:
      name: httpbin
      namespace: default
      port: 8000
  status:
    lastProcessedTime: "2024-07-15T11:22:24Z"
    state: Ready
kind: List
metadata:
  resourceVersion: ""

Then let's try to recreate it from the above content:

kubectl delete apirule httpbin-rule
kubectl apply -f ./apirule_converted.yaml
kubectl describe apirule

It gives error:

Status:
  API Rule Status:
    Code:  ERROR
    Desc:  Validation error: Attribute ".spec.hosts[0]": Host is not fully qualified domain name

DoD:

  • Provide unit and integration tests.
  • Provide documentation.
  • Verify if the solution works for both open-source Kyma and SAP BTP, Kyma runtime.
  • If you changed the resource limits, explain why it was needed.
  • Verify that your contributions don't decrease code coverage. If they do, explain why this is the case.
  • Add release notes.

Attachments

@mluk-sap mluk-sap added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 16, 2024
@strekm
Copy link
Collaborator

strekm commented Sep 5, 2024

@mluk-sap i think it will be resolved with #1247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants