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

feat(gateway): add initial Gateway API support to Kubernetes #3109

Merged
merged 5 commits into from
Dec 10, 2021

Conversation

michaelbeaumont
Copy link
Contributor

@michaelbeaumont michaelbeaumont commented Nov 9, 2021

Summary

Adds support for creating gatewayapi.Gateways and gatewayapi.HTTPRoutes in k8s. Upon creating a Gateway and GatewayClass, a kuma-dp deployment is created which uses a Dataplane with type: BUILTIN, created, like all dataplanes in k8s, by the Pod controller.

For example:

---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
  name: kuma
spec:
  controllerName: "gateways.kuma.io/controller"
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
  name: foo-gateway
  namespace: default
spec:
  gatewayClassName: 'kuma'
  listeners:
  - name: prod-web
    port: 80
    protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: foo-gateway
  namespace: default
spec:
  parentRefs:
  - name: foo-gateway
    sectionName: prod-web
  rules:
    - matches:
      - path:
          type: PathPrefix
          value: "/"
      backendRefs:
        - name: httpbin
          port: 8000
$ kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/httpbin/httpbin.yaml
$ IP=$(kubectl get gateways.gateway.networking.k8s.io foo-gateway -o json | jq -r '.status.addresses[0].value')
$ curl -i "$IP/get"
HTTP/1.1 200 OK
server: Kuma Gateway
date: Tue, 09 Nov 2021 12:36:49 GMT
content-type: application/json
content-length: 232
access-control-allow-origin: *
access-control-allow-credentials: true
x-envoy-upstream-service-time: 1

{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Host": "192.168.49.2",
    "User-Agent": "curl/7.79.1",
    "X-Envoy-Expected-Rq-Timeout-Ms": "15000"
  },
  "origin": "127.0.0.1",
  "url": "http://192.168.49.2/get"
}

TODO

  • annotation to Gateway resource to enable behavior check for GatewayClass
  • add gateway Service creation
  • gatewayapi object support
  • ExternalService backendRefs

Post merge TODO

  • separate packge for converting from k8s to kuma types with tests

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Kubernetes

@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 2 times, most recently from 85771df to 9b11bc8 Compare November 9, 2021 13:55
@codecov-commenter
Copy link

codecov-commenter commented Nov 9, 2021

Codecov Report

Merging #3109 (e4cfc43) into master (ff7a55f) will decrease coverage by 0.39%.
The diff coverage is 33.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3109      +/-   ##
==========================================
- Coverage   52.15%   51.76%   -0.40%     
==========================================
  Files         938      945       +7     
  Lines       54587    55001     +414     
==========================================
  Hits        28470    28470              
- Misses      23886    24306     +420     
+ Partials     2231     2225       -6     
Impacted Files Coverage Δ
api/mesh/v1alpha1/dataplane_helpers.go 81.74% <ø> (ø)
pkg/plugins/bootstrap/k8s/scheme.go 23.07% <0.00%> (-4.20%) ⬇️
...ns/runtime/k8s/controllers/gatewayapi/condition.go 0.00% <0.00%> (ø)
...ns/runtime/k8s/controllers/gatewayapi/converter.go 0.00% <0.00%> (ø)
...s/runtime/k8s/controllers/gatewayapi/deployment.go 0.00% <0.00%> (ø)
...e/k8s/controllers/gatewayapi/gateway_controller.go 0.00% <0.00%> (ø)
...8s/controllers/gatewayapi/http_route_controller.go 0.00% <0.00%> (ø)
pkg/plugins/runtime/k8s/plugin.go 1.11% <0.00%> (-0.02%) ⬇️
pkg/plugins/runtime/k8s/plugin_gateway.go 0.00% <0.00%> (ø)
pkg/plugins/runtime/k8s/containers/factory.go 96.57% <96.57%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff7a55f...e4cfc43. Read the comment docs.

@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 3 times, most recently from 9439536 to a4abed4 Compare November 10, 2021 10:35
@michaelbeaumont michaelbeaumont changed the base branch from master to feat/kuma_gateway_crds November 10, 2021 10:35
@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 4 times, most recently from e8e9792 to c132ffa Compare November 10, 2021 15:41
@michaelbeaumont michaelbeaumont marked this pull request as ready for review November 10, 2021 15:53
@michaelbeaumont michaelbeaumont requested a review from a team as a code owner November 10, 2021 15:53
@michaelbeaumont michaelbeaumont force-pushed the feat/kuma_gateway_crds branch 7 times, most recently from a5886b6 to 6ef7a42 Compare November 11, 2021 20:32
@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 3 times, most recently from eb0a075 to f9c8332 Compare November 15, 2021 16:16
Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

Part-way through :)

go.mod Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/controllers/pod_converter.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/metadata/annotations.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/plugin_gateway.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/plugin_gateway.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/controllers/gateway_converter.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/controllers/gateway_converter.go Outdated Show resolved Hide resolved
pkg/plugins/runtime/k8s/metadata/annotations.go Outdated Show resolved Hide resolved
@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 3 times, most recently from fc5231f to 955f3ff Compare December 1, 2021 17:58
@michaelbeaumont michaelbeaumont changed the title feat(gateway) add initial Gateway support to Kubernetes feat(gateway): add initial Gateway support to Kubernetes Dec 1, 2021
@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 2 times, most recently from 61a478f to 520b1b8 Compare December 1, 2021 23:55
@michaelbeaumont michaelbeaumont force-pushed the feat/gateway_k8s branch 5 times, most recently from ed2bd4a to 8237b3e Compare December 8, 2021 00:16
@michaelbeaumont michaelbeaumont changed the title feat(gateway): add initial Gateway support to Kubernetes feat(gateway): add initial Gateway API support to Kubernetes Dec 9, 2021
@michaelbeaumont michaelbeaumont linked an issue Dec 9, 2021 that may be closed by this pull request
1 task
Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

I'm happy to land this and deal with the install and deployment changes later, if that's your preference :)

@michaelbeaumont michaelbeaumont merged commit 7f31204 into master Dec 10, 2021
@michaelbeaumont michaelbeaumont deleted the feat/gateway_k8s branch December 10, 2021 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial support for Kubernetes Gateway API
3 participants