Skip to content

Commit f2aa2d4

Browse files
committed
Revert "Remove Bridge API"
This reverts commit 3fab022.
1 parent b75a330 commit f2aa2d4

32 files changed

+6553
-57
lines changed

cmd/postgres-operator/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"crypto/tls"
1010
"errors"
1111
"fmt"
12+
"net/http"
1213
"os"
1314
"os/signal"
1415
"strconv"
@@ -23,6 +24,8 @@ import (
2324
"sigs.k8s.io/controller-runtime/pkg/healthz"
2425
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
2526

27+
"github.com/crunchydata/postgres-operator/internal/bridge"
28+
"github.com/crunchydata/postgres-operator/internal/bridge/crunchybridgecluster"
2629
"github.com/crunchydata/postgres-operator/internal/controller/pgupgrade"
2730
"github.com/crunchydata/postgres-operator/internal/controller/postgrescluster"
2831
"github.com/crunchydata/postgres-operator/internal/controller/runtime"
@@ -238,10 +241,24 @@ func main() {
238241
manager := need(runtime.NewManager(config, options))
239242
must(manager.Add(k8s))
240243

244+
bridgeURL := os.Getenv("PGO_BRIDGE_URL")
245+
bridgeClient := func() *bridge.Client {
246+
client := bridge.NewClient(bridgeURL, versionString)
247+
client.Transport = otelTransportWrapper()(http.DefaultTransport)
248+
return client
249+
}
250+
241251
// add all PostgreSQL Operator controllers to the runtime manager
242252
must(pgupgrade.ManagedReconciler(manager))
243253
must(postgrescluster.ManagedReconciler(manager))
244254
must(standalone_pgadmin.ManagedReconciler(manager))
255+
must(crunchybridgecluster.ManagedReconciler(manager, func() bridge.ClientInterface {
256+
return bridgeClient()
257+
}))
258+
259+
if features.Enabled(feature.BridgeIdentifiers) {
260+
must(bridge.ManagedInstallationReconciler(manager, bridgeClient))
261+
}
245262

246263
// Enable health probes
247264
must(manager.AddHealthzCheck("health", healthz.Ping))
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
---
2+
# controller-gen.kubebuilder.io/version: v0.18.0
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
name: crunchybridgeclusters.postgres-operator.crunchydata.com
7+
spec:
8+
group: postgres-operator.crunchydata.com
9+
names:
10+
kind: CrunchyBridgeCluster
11+
listKind: CrunchyBridgeClusterList
12+
plural: crunchybridgeclusters
13+
singular: crunchybridgecluster
14+
scope: Namespaced
15+
versions:
16+
- name: v1beta1
17+
schema:
18+
openAPIV3Schema:
19+
description: CrunchyBridgeCluster is the Schema for the crunchybridgeclusters
20+
API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: |-
41+
CrunchyBridgeClusterSpec defines the desired state of CrunchyBridgeCluster
42+
to be managed by Crunchy Data Bridge
43+
properties:
44+
clusterName:
45+
description: The name of the cluster
46+
maxLength: 50
47+
minLength: 5
48+
pattern: ^[A-Za-z][A-Za-z0-9\-_ ]*[A-Za-z0-9]$
49+
type: string
50+
isHa:
51+
description: |-
52+
Whether the cluster is high availability,
53+
meaning that it has a secondary it can fail over to quickly
54+
in case the primary becomes unavailable.
55+
type: boolean
56+
isProtected:
57+
description: |-
58+
Whether the cluster is protected. Protected clusters can't be destroyed until
59+
their protected flag is removed
60+
type: boolean
61+
majorVersion:
62+
description: |-
63+
The ID of the cluster's major Postgres version.
64+
Currently Bridge offers 13-17
65+
maximum: 17
66+
minimum: 13
67+
type: integer
68+
metadata:
69+
description: Metadata contains metadata for custom resources
70+
properties:
71+
annotations:
72+
additionalProperties:
73+
type: string
74+
type: object
75+
labels:
76+
additionalProperties:
77+
type: string
78+
type: object
79+
type: object
80+
plan:
81+
description: The ID of the cluster's plan. Determines instance, CPU,
82+
and memory.
83+
type: string
84+
provider:
85+
description: |-
86+
The cloud provider where the cluster is located.
87+
Currently Bridge offers aws, azure, and gcp only
88+
enum:
89+
- aws
90+
- azure
91+
- gcp
92+
maxLength: 5
93+
type: string
94+
x-kubernetes-validations:
95+
- message: immutable
96+
rule: self == oldSelf
97+
region:
98+
description: The provider region where the cluster is located.
99+
type: string
100+
x-kubernetes-validations:
101+
- message: immutable
102+
rule: self == oldSelf
103+
roles:
104+
description: |-
105+
Roles for which to create Secrets that contain their credentials which
106+
are retrieved from the Bridge API. An empty list creates no role secrets.
107+
Removing a role from this list does NOT drop the role nor revoke their
108+
access, but it will delete that role's secret from the kube cluster.
109+
items:
110+
properties:
111+
name:
112+
description: |-
113+
Name of the role within Crunchy Bridge.
114+
More info: https://docs.crunchybridge.com/concepts/users
115+
type: string
116+
secretName:
117+
description: The name of the Secret that will hold the role
118+
credentials.
119+
maxLength: 253
120+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
121+
type: string
122+
required:
123+
- name
124+
- secretName
125+
type: object
126+
type: array
127+
x-kubernetes-list-map-keys:
128+
- name
129+
x-kubernetes-list-type: map
130+
secret:
131+
description: The name of the secret containing the API key and team
132+
id
133+
type: string
134+
storage:
135+
description: |-
136+
The amount of storage available to the cluster in gigabytes.
137+
The amount must be an integer, followed by Gi (gibibytes) or G (gigabytes) to match Kubernetes conventions.
138+
If the amount is given in Gi, we round to the nearest G value.
139+
The minimum value allowed by Bridge is 10 GB.
140+
The maximum value allowed by Bridge is 65535 GB.
141+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
142+
x-kubernetes-int-or-string: true
143+
required:
144+
- clusterName
145+
- isHa
146+
- majorVersion
147+
- plan
148+
- provider
149+
- region
150+
- secret
151+
- storage
152+
type: object
153+
status:
154+
description: CrunchyBridgeClusterStatus defines the observed state of
155+
CrunchyBridgeCluster
156+
properties:
157+
conditions:
158+
description: conditions represent the observations of postgres cluster's
159+
current state.
160+
items:
161+
description: Condition contains details for one aspect of the current
162+
state of this API Resource.
163+
properties:
164+
lastTransitionTime:
165+
description: |-
166+
lastTransitionTime is the last time the condition transitioned from one status to another.
167+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
168+
format: date-time
169+
type: string
170+
message:
171+
description: |-
172+
message is a human readable message indicating details about the transition.
173+
This may be an empty string.
174+
maxLength: 32768
175+
type: string
176+
observedGeneration:
177+
description: |-
178+
observedGeneration represents the .metadata.generation that the condition was set based upon.
179+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
180+
with respect to the current state of the instance.
181+
format: int64
182+
minimum: 0
183+
type: integer
184+
reason:
185+
description: |-
186+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
187+
Producers of specific condition types may define expected values and meanings for this field,
188+
and whether the values are considered a guaranteed API.
189+
The value should be a CamelCase string.
190+
This field may not be empty.
191+
maxLength: 1024
192+
minLength: 1
193+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
194+
type: string
195+
status:
196+
description: status of the condition, one of True, False, Unknown.
197+
enum:
198+
- "True"
199+
- "False"
200+
- Unknown
201+
maxLength: 7
202+
type: string
203+
type:
204+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
205+
maxLength: 316
206+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
207+
type: string
208+
required:
209+
- lastTransitionTime
210+
- message
211+
- reason
212+
- status
213+
- type
214+
type: object
215+
type: array
216+
x-kubernetes-list-map-keys:
217+
- type
218+
x-kubernetes-list-type: map
219+
host:
220+
description: The Hostname of the postgres cluster in Bridge, provided
221+
by Bridge API and null until then.
222+
type: string
223+
id:
224+
description: The ID of the postgres cluster in Bridge, provided by
225+
Bridge API and null until then.
226+
type: string
227+
isHa:
228+
description: |-
229+
Whether the cluster is high availability, meaning that it has a secondary it can fail
230+
over to quickly in case the primary becomes unavailable.
231+
type: boolean
232+
isProtected:
233+
description: |-
234+
Whether the cluster is protected. Protected clusters can't be destroyed until
235+
their protected flag is removed
236+
type: boolean
237+
majorVersion:
238+
description: The cluster's major Postgres version.
239+
type: integer
240+
name:
241+
description: The name of the cluster in Bridge.
242+
type: string
243+
observedGeneration:
244+
description: observedGeneration represents the .metadata.generation
245+
on which the status was based.
246+
format: int64
247+
minimum: 0
248+
type: integer
249+
ongoingUpgrade:
250+
description: The cluster upgrade as represented by Bridge
251+
items:
252+
properties:
253+
flavor:
254+
type: string
255+
starting_from:
256+
type: string
257+
state:
258+
type: string
259+
required:
260+
- flavor
261+
- starting_from
262+
- state
263+
type: object
264+
type: array
265+
plan:
266+
description: The ID of the cluster's plan. Determines instance, CPU,
267+
and memory.
268+
type: string
269+
responses:
270+
description: Most recent, raw responses from Bridge API
271+
type: object
272+
x-kubernetes-preserve-unknown-fields: true
273+
state:
274+
description: State of cluster in Bridge.
275+
type: string
276+
storage:
277+
description: The amount of storage available to the cluster.
278+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
279+
x-kubernetes-int-or-string: true
280+
type: object
281+
type: object
282+
served: true
283+
storage: true
284+
subresources:
285+
status: {}

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
kind: Kustomization
22

33
resources:
4+
- bases/postgres-operator.crunchydata.com_crunchybridgeclusters.yaml
45
- bases/postgres-operator.crunchydata.com_postgresclusters.yaml
56
- bases/postgres-operator.crunchydata.com_pgupgrades.yaml
67
- bases/postgres-operator.crunchydata.com_pgadmins.yaml

config/rbac/role.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ rules:
111111
- list
112112
- patch
113113
- watch
114+
- apiGroups:
115+
- postgres-operator.crunchydata.com
116+
resources:
117+
- crunchybridgeclusters
118+
verbs:
119+
- get
120+
- list
121+
- patch
122+
- update
123+
- watch
124+
- apiGroups:
125+
- postgres-operator.crunchydata.com
126+
resources:
127+
- crunchybridgeclusters/finalizers
128+
- crunchybridgeclusters/status
129+
verbs:
130+
- patch
131+
- update
114132
- apiGroups:
115133
- postgres-operator.crunchydata.com
116134
resources:

0 commit comments

Comments
 (0)