-
Notifications
You must be signed in to change notification settings - Fork 67
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
Conversation
/assign @LiorLieberman |
6750d27
to
db03324
Compare
There was a problem hiding this 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 !
* ir can be a commonly used name for local variable and function parameters, which could potential shadow the package ir.
373e30e
to
538c925
Compare
* 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.
c6a8035
to
a2c881e
Compare
a2c881e
to
8aa6bfe
Compare
There was a problem hiding this 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: []
* Providers now should implement ResourcesToIRConverter interface and IRToGatewayAPIConverter interface.
8aa6bfe
to
859f2c9
Compare
/label tide/merge-method-merge |
Thanks for all the work on this @sawsa307 and also to @LiorLieberman for the great reviews! /lgtm (For future readers, most of my review for this work was actually on #185.) |
[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:
Approvers can indicate their approval by writing |
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?: