Skip to content

Commit 904f47b

Browse files
authored
feat: add support for fetching subgraph schema via http (#41)
* feat: add support for fetching subgrapgh schema via http * fix: remove reconciling condition if requeue * fix: update rbac * chore: remove unnecessary watch
1 parent ad9ce3b commit 904f47b

17 files changed

Lines changed: 531 additions & 111 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ kind-test: ## Deploy including test
134134
CONTROLLER_GEN = $(GOBIN)/controller-gen
135135
.PHONY: controller-gen
136136
controller-gen: ## Download controller-gen locally if necessary.
137-
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.18.0)
137+
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.20.0)
138138
#cp config/base/crd/bases/* chart/apollo-controller/crds/
139139

140140
GOLANGCI_LINT = $(GOBIN)/golangci-lint

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ flowchart LR
117117
SchemaReconciler["SuperGraph Composer Pod"]
118118
119119
SuperGraphSchema --> SchemaReconciler
120-
SuperGraphSchema --> SuperGraph
120+
SuperGraph --> SuperGraphSchema
121121
Subgraph1 --> SuperGraphSchema
122122
Subgraph2 --> SuperGraphSchema
123123
Subgraph3 --> SuperGraphSchema
@@ -203,6 +203,21 @@ spec:
203203
runAsUser: 65532
204204
```
205205

206+
## Subgraph schema from other sources
207+
Besides inline schemas a subgraph schema can also be fetched via http:
208+
209+
```yaml
210+
apiVersion: apollo.infra.doodle.com/v1beta1
211+
kind: SubGraph
212+
metadata:
213+
name: users
214+
spec:
215+
endpoint: http://user-server/graphql
216+
schema:
217+
http:
218+
endpoint: http://user-server/graphql-schema
219+
```
220+
206221
## Suspend/Resume reconciliation
207222

208223
All resources support suspending reconciliation.
@@ -227,6 +242,8 @@ Alternatively you may get the bundled manifests in each release to deploy it usi
227242
The controller can be configured using cmd args:
228243
```
229244
--concurrent int The number of concurrent SuperGraph reconciles. (default 4)
245+
--default-httpd-image string The default image which provides an http server to serve the directory /output. By default httpd (busybox) is used. (default "busybox:1")
246+
--default-supergraph-image string The default rover cli image. (default "ghcr.io/doodlescheduling/supergraph:v0")
230247
--enable-leader-election Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.
231248
--graceful-shutdown-timeout duration The duration given to the reconciler to finish before forcibly stopping. (default 10m0s)
232249
--health-addr string The address the health endpoint binds to. (default ":9557")

api/v1beta1/subgraph_types.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ func init() {
2929
// SubGraphSpec
3030
// +k8s:openapi-gen=true
3131
type SubGraphSpec struct {
32-
Endpoint string `json:"endpoint,omitempty"`
33-
Suspend bool `json:"suspend,omitempty"`
34-
Schema *Schema `json:"schema,omitempty"`
32+
Endpoint string `json:"endpoint,omitempty"`
33+
Suspend bool `json:"suspend,omitempty"`
34+
Timeout *metav1.Duration `json:"timeout,omitempty"`
35+
Interval *metav1.Duration `json:"interval,omitempty"`
36+
Schema Schema `json:"schema,omitempty"`
3537
}
3638

39+
// +kubebuilder:validation:ExactlyOneOf=sdl;http
3740
type Schema struct {
38-
SDL string `json:"sdl,omitempty"`
41+
SDL *string `json:"sdl,omitempty"`
42+
HTTP *SchemaHTTP `json:"http,omitempty"`
43+
}
44+
45+
type SchemaHTTP struct {
46+
Endpoint string `json:"endpoint,omitempty"`
3947
}
4048

4149
type SubGraphStatus struct {
4250
SHA256Checksum string `json:"sha256Checksum,omitempty"`
4351

52+
// Schema
53+
Schema string `json:"schema,omitempty"`
54+
4455
// ObservedGeneration is the last generation reconciled by the controller
4556
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
4657

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 34 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/apollo-controller/crds/apollo.infra.doodle.com_subgraphs.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.18.0
6+
controller-gen.kubebuilder.io/version: v0.20.0
77
name: subgraphs.apollo.infra.doodle.com
88
spec:
99
group: apollo.infra.doodle.com
@@ -40,13 +40,26 @@ spec:
4040
properties:
4141
endpoint:
4242
type: string
43+
interval:
44+
type: string
4345
schema:
4446
properties:
47+
http:
48+
properties:
49+
endpoint:
50+
type: string
51+
type: object
4552
sdl:
4653
type: string
4754
type: object
55+
x-kubernetes-validations:
56+
- message: exactly one of the fields in [sdl http] must be set
57+
rule: '[has(self.sdl),has(self.http)].filter(x,x==true).size() ==
58+
1'
4859
suspend:
4960
type: boolean
61+
timeout:
62+
type: string
5063
type: object
5164
status:
5265
properties:
@@ -112,6 +125,9 @@ spec:
112125
by the controller
113126
format: int64
114127
type: integer
128+
schema:
129+
description: Schema
130+
type: string
115131
sha256Checksum:
116132
type: string
117133
type: object

chart/apollo-controller/crds/apollo.infra.doodle.com_supergraphs.yaml

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.18.0
6+
controller-gen.kubebuilder.io/version: v0.20.0
77
name: supergraphs.apollo.infra.doodle.com
88
spec:
99
group: apollo.infra.doodle.com
@@ -2032,8 +2032,9 @@ spec:
20322032
type: integer
20332033
type: object
20342034
resizePolicy:
2035-
description: Resources resize policy for the
2036-
container.
2035+
description: |-
2036+
Resources resize policy for the container.
2037+
This field cannot be set on ephemeral containers.
20372038
items:
20382039
description: ContainerResizePolicy represents
20392040
resource resize policy for the container.
@@ -5321,8 +5322,9 @@ spec:
53215322
type: integer
53225323
type: object
53235324
resizePolicy:
5324-
description: Resources resize policy for the
5325-
container.
5325+
description: |-
5326+
Resources resize policy for the container.
5327+
This field cannot be set on ephemeral containers.
53265328
items:
53275329
description: ContainerResizePolicy represents
53285330
resource resize policy for the container.
@@ -6117,8 +6119,8 @@ spec:
61176119
will be made available to those containers which consume them
61186120
by name.
61196121

6120-
This is an alpha field and requires enabling the
6121-
DynamicResourceAllocation feature gate.
6122+
This is a stable field but requires that the
6123+
DynamicResourceAllocation feature gate is enabled.
61226124

61236125
This field is immutable.
61246126
items:
@@ -6578,9 +6580,10 @@ spec:
65786580
operator:
65796581
description: |-
65806582
Operator represents a key's relationship to the value.
6581-
Valid operators are Exists and Equal. Defaults to Equal.
6583+
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
65826584
Exists is equivalent to wildcard for value, so that a pod can
65836585
tolerate all taints of a particular category.
6586+
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
65846587
type: string
65856588
tolerationSeconds:
65866589
description: |-
@@ -7385,7 +7388,7 @@ spec:
73857388
resources:
73867389
description: |-
73877390
resources represents the minimum resources the volume should have.
7388-
If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements
7391+
Users are allowed to specify resource requirements
73897392
that are lower than previous value but must still be higher than capacity recorded in the
73907393
status field of the claim.
73917394
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources
@@ -8295,6 +8298,24 @@ spec:
82958298
CSRs will be addressed to this
82968299
signer.
82978300
type: string
8301+
userAnnotations:
8302+
additionalProperties:
8303+
type: string
8304+
description: |-
8305+
userAnnotations allow pod authors to pass additional information to
8306+
the signer implementation. Kubernetes does not restrict or validate this
8307+
metadata in any way.
8308+
8309+
These values are copied verbatim into the `spec.unverifiedUserAnnotations` field of
8310+
the PodCertificateRequest objects that Kubelet creates.
8311+
8312+
Entries are subject to the same validation as object metadata annotations,
8313+
with the addition that all keys must be domain-prefixed. No restrictions
8314+
are placed on values, except an overall size limitation on the entire field.
8315+
8316+
Signers should document the keys and values they support. Signers should
8317+
deny requests that contain keys they do not recognize.
8318+
type: object
82988319
required:
82998320
- keyType
83008321
- signerName
@@ -8727,6 +8748,42 @@ spec:
87278748
x-kubernetes-list-map-keys:
87288749
- name
87298750
x-kubernetes-list-type: map
8751+
workloadRef:
8752+
description: |-
8753+
WorkloadRef provides a reference to the Workload object that this Pod belongs to.
8754+
This field is used by the scheduler to identify the PodGroup and apply the
8755+
correct group scheduling policies. The Workload object referenced
8756+
by this field may not exist at the time the Pod is created.
8757+
This field is immutable, but a Workload object with the same name
8758+
may be recreated with different policies. Doing this during pod scheduling
8759+
may result in the placement not conforming to the expected policies.
8760+
properties:
8761+
name:
8762+
description: |-
8763+
Name defines the name of the Workload object this Pod belongs to.
8764+
Workload must be in the same namespace as the Pod.
8765+
If it doesn't match any existing Workload, the Pod will remain unschedulable
8766+
until a Workload object is created and observed by the kube-scheduler.
8767+
It must be a DNS subdomain.
8768+
type: string
8769+
podGroup:
8770+
description: |-
8771+
PodGroup is the name of the PodGroup within the Workload that this Pod
8772+
belongs to. If it doesn't match any existing PodGroup within the Workload,
8773+
the Pod will remain unschedulable until the Workload object is recreated
8774+
and observed by the kube-scheduler. It must be a DNS label.
8775+
type: string
8776+
podGroupReplicaKey:
8777+
description: |-
8778+
PodGroupReplicaKey specifies the replica key of the PodGroup to which this
8779+
Pod belongs. It is used to distinguish pods belonging to different replicas
8780+
of the same pod group. The pod group policy is applied separately to each replica.
8781+
When set, it must be a DNS label.
8782+
type: string
8783+
required:
8784+
- name
8785+
- podGroup
8786+
type: object
87308787
required:
87318788
- containers
87328789
type: object

0 commit comments

Comments
 (0)