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

Create IR structs, and merge functions for IRs. #188

Merged
merged 10 commits into from
Sep 10, 2024

Conversation

sawsa307
Copy link
Contributor

@sawsa307 sawsa307 commented Sep 5, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:
Add structures needed to support translation of extension features.

Which issue(s) this PR fixes:

Fixes #125

Does this PR introduce a user-facing change?:

None

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 5, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 5, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 5, 2024
@sawsa307
Copy link
Contributor Author

sawsa307 commented Sep 5, 2024

/assign @LiorLieberman

Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate you put the time to split this to two more concise commits. This is very useful, thanks @sawsa307 !

pkg/i2gw/provider.go Outdated Show resolved Hide resolved
pkg/i2gw/provider.go Outdated Show resolved Hide resolved
pkg/i2gw/ingress2gateway.go Outdated Show resolved Hide resolved
pkg/i2gw/ingress2gateway.go Outdated Show resolved Hide resolved
* Add BackendConfig to resource_reader.
* go.mod requires go 1.22.4, while golangci-lint 1.55.2 is built on go
  1.21. This would cause an issue to load go package.
  "go.mod requires go >= 1.22.1 (running go 1.22.0; GOTOOLCHAIN=local)"
* Thus, we need to update to the latest goclint-ci version.
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 6, 2024
Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Looks good to me, thank you so much for all your hard work @sawsa307 💪!

/approve
lets get final lgtm from @robscott for the specific logic

I also tested it locally with two files.
one is:
./ingress2gateway print --input-file tmp.yaml -A --providers gce

tmp.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sa-test
  annotations:
    kubernetes.io/ingress.class: "gce"
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: whereami
            port:
              number: 80
---
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: sa-test
spec:
  sessionAffinity:
    affinityType: "CLIENT_IP"
---
apiVersion: v1
kind: Service
metadata:
  name: whereami
  annotations:
    cloud.google.com/neg: '{"ingress": true}'
    cloud.google.com/backend-config: '{"default": "sa-test"}'
spec:
  selector:
    app: whereami
  ports:
    - port: 80
      protocol: TCP
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: whereami
spec:
  replicas: 3
  selector:
    matchLabels:
      app: whereami
  template:
    metadata:
      labels:
        app: whereami
    spec:
      containers:
      - name: whereami
        image: bla/whereami:v1.2.20
        ports:
          - name: http
            containerPort: 8080
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  selector:
    matchLabels:
      purpose: bsc-config-demo
  replicas: 2
  template:
    metadata:
      labels:
        purpose: bsc-config-demo
    spec:
      containers:
      - name: hello-app-container
        image: bla/hello-app:1.0

output:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  creationTimestamp: null
  name: gce
spec:
  gatewayClassName: gke-l7-global-external-managed
  listeners:
  - name: http
    port: 80
    protocol: HTTP
status: {}
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  creationTimestamp: null
  name: sa-test-all-hosts
spec:
  parentRefs:
  - name: gce
  rules:
  - backendRefs:
    - name: whereami
      port: 80
    matches:
    - path:
        type: PathPrefix
        value: /
status:
  parents: []
---
apiVersion: networking.gke.io/v1
kind: GCPBackendPolicy
metadata:
  creationTimestamp: null
  name: whereami-GCPBackendPolicy
spec:
  default:
    sessionAffinity:
      type: CLIENT_IP
  targetRef:
    group: ""
    kind: Service
    name: whereami
status: {}

Second test to previous capabilities not break:
./ingress2gateway print --input-file ingress.yaml -A --providers ingress-nginx

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - foo.example.com
    - bar.example.com
    secretName: example-com
  rules:
  - host: foo.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: foo-app
            port:
              number: 80
      - path: /orders
        pathType: Prefix
        backend:
          service:
            name: foo-orders-app
            port:
              number: 80
  - host: bar.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: bar-app
            port:
              number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-canary-ingress
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "50"
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - foo.example.com
    - bar.example.com
    secretName: example-com
  rules:
  - host: foo.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: bar-app
            port:
              number: 80

output:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  creationTimestamp: null
  name: nginx
spec:
  gatewayClassName: nginx
  listeners:
  - hostname: bar.example.com
    name: bar-example-com-http
    port: 80
    protocol: HTTP
  - hostname: bar.example.com
    name: bar-example-com-https
    port: 443
    protocol: HTTPS
    tls:
      certificateRefs:
      - group: null
        kind: null
        name: example-com
  - hostname: foo.example.com
    name: foo-example-com-http
    port: 80
    protocol: HTTP
  - hostname: foo.example.com
    name: foo-example-com-https
    port: 443
    protocol: HTTPS
    tls:
      certificateRefs:
      - group: null
        kind: null
        name: example-com
      - group: null
        kind: null
        name: example-com
status: {}
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  creationTimestamp: null
  name: example-ingress-bar-example-com
spec:
  hostnames:
  - bar.example.com
  parentRefs:
  - name: nginx
  rules:
  - backendRefs:
    - name: bar-app
      port: 80
    matches:
    - path:
        type: PathPrefix
        value: /
status:
  parents: []
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  creationTimestamp: null
  name: example-canary-ingress-foo-example-com
spec:
  hostnames:
  - foo.example.com
  parentRefs:
  - name: nginx
  rules:
  - backendRefs:
    - name: bar-app
      port: 80
      weight: 50
    - name: foo-app
      port: 80
      weight: 50
    matches:
    - path:
        type: PathPrefix
        value: /
  - backendRefs:
    - name: foo-orders-app
      port: 80
    matches:
    - path:
        type: PathPrefix
        value: /orders
status:
  parents: []

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2024
* Providers now should implement ResourcesToIRConverter interface and
  IRToGatewayAPIConverter interface.
@LiorLieberman
Copy link
Member

/label tide/merge-method-merge

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges. label Sep 10, 2024
@robscott
Copy link
Member

Thanks for all the work on this @sawsa307 and also to @LiorLieberman for the great reviews!

/lgtm
/approve

(For future readers, most of my review for this work was actually on #185.)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LiorLieberman, robscott, sawsa307

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [LiorLieberman,robscott]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit a7628a8 into kubernetes-sigs:main Sep 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Gateway API extensions (output providers)
4 participants