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

Add external connection IPs to connection secret if service type is set to LoadBalancer for PostgreSQL Managed by VSHN #46

Merged
merged 19 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,22 @@ To add a new function to PostgreSQL by VSHN:
entrypoint to start working with gRPC server is to run:
```
go run main.go --log-level 1 start grpc --network tcp --socket ':9547' --devmode

```

This will start the GRPC server listening on a TCP port. Afterward you can configure the composition to use this connection:

```yaml
### Macos:
wejdross marked this conversation as resolved.
Show resolved Hide resolved
functions:
- container:
image: redis
imagePullPolicy: IfNotPresent
runner:
endpoint: host.docker.internal:9547 # HERE
endpoint: host.docker.internal:9547 # HERE in component-appcat or k edit compositions.apiextensions.crossplane.io vshnpostgres.vshn.appcat.vshn.io

### Linux:
### use default gateway for docker0 interface, `ip -4 addr show dev docker0 | grep inet`, the default should be 172.17.0.1
```

It's also possible to trigger fake request to gRPC server by client (to imitate Crossplane):
Expand Down
8 changes: 8 additions & 0 deletions apis/vshn/v1/dbaas_vshn_postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ type VSHNDBaaSNetworkSpec struct {
// If no IP Filter is set, you may not be able to reach the service.
// A value of `0.0.0.0/0` will open the service to all addresses on the public internet.
IPFilter []string `json:"ipFilter,omitempty"`

// ServiceType defines the type of the service.
// Possible enum values:
// - `"ClusterIP"` indicates that the service is only reachable from within the cluster.
// - `"LoadBalancer"` indicates that the service is reachable from the public internet via dedicated Ipv4 address.
// +kubebuilder:default="ClusterIP"
// +kubebuilder:validation:Enum="ClusterIP";"LoadBalancer"
ServiceType string `json:"serviceType,omitempty"`
}

type VSHNPostgreSQLBackup struct {
Expand Down
4 changes: 4 additions & 0 deletions cmd/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ var images = map[string][]runtime.Transform{
Name: "replication",
TransformFunc: vpf.ConfigureReplication,
},
{
Name: "loadBalancer",
TransformFunc: vpf.AddLoadBalancerIPToConnectionDetails,
},
},
"redis": {
{
Expand Down
7 changes: 7 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3498,6 +3498,13 @@ spec:
items:
type: string
type: array
serviceType:
default: ClusterIP
description: 'ServiceType defines the type of the service. Possible enum values: - `"ClusterIP"` indicates that the service is only reachable from within the cluster. - `"LoadBalancer"` indicates that the service is reachable from the public internet via dedicated Ipv4 address.'
enum:
- ClusterIP
- LoadBalancer
type: string
type: object
replication:
description: "This section allows to configure Postgres replication mode and HA roles groups. \n The main replication group is implicit and contains the total number of instances less the sum of all instances in other replication groups."
Expand Down
4 changes: 2 additions & 2 deletions docs/antora-build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ docs_out_dir := ./.public

docker_opts ?= --rm --tty --user "$$(id -u)"

antora_build_version ?= 3.0.1
antora_cmd ?= $(DOCKER_CMD) run $(docker_opts) --volume "$${PWD}":/antora docker.io/vshn/antora:$(antora_build_version)
antora_build_version ?= latest
antora_cmd ?= $(DOCKER_CMD) run $(docker_opts) --volume "$${PWD}":/antora ghcr.io/vshn/antora:$(antora_build_version)
antora_opts ?= --cache-dir=.cache/antora

.PHONY: docs
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
* xref:explanations/comp-functions/vshn-postgres.adoc[VSHN Postgres Functions]
* xref:explanations/slareports.adoc[]
* xref:explanations/dev-notes.adoc[]
* xref:explanations/debug.adoc[]
//* xref:explanations/debug.adoc[]
11 changes: 3 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ replace github.com/deepmap/oapi-codegen => github.com/sljeff/oapi-codegen v1.5.1

require (
github.com/appuio/appuio-cloud-reporting v0.15.0
github.com/blang/semver/v4 v4.0.0
github.com/crossplane-contrib/provider-helm v0.15.0
github.com/crossplane-contrib/provider-kubernetes v0.7.0
github.com/crossplane/crossplane v1.11.2
Expand All @@ -16,12 +17,12 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/google/go-containerregistry v0.9.0
github.com/hashicorp/go-version v1.6.0
github.com/jackc/pgx/v5 v5.3.1
github.com/k8up-io/k8up/v2 v2.7.1
github.com/minio/minio-go/v7 v7.0.56
github.com/ory/dockertest v3.3.5+incompatible
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.63.0
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.40.0
Expand All @@ -30,12 +31,10 @@ require (
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/thediveo/enumflag/v2 v2.0.2
github.com/urfave/cli/v2 v2.25.3
github.com/vektra/mockery/v2 v2.26.1
go.uber.org/zap v1.24.0
golang.org/x/text v0.9.0
google.golang.org/grpc v1.52.0
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.0.3
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
Expand All @@ -60,15 +59,13 @@ require (
github.com/alessio/shellescape v1.4.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chigopher/pathlib v0.13.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand Down Expand Up @@ -129,12 +126,10 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand All @@ -144,7 +139,6 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/v3 v3.5.6 // indirect
Expand Down Expand Up @@ -178,6 +172,7 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools v2.2.0+incompatible // indirect
helm.sh/helm/v3 v3.10.2 // indirect
k8s.io/apiextensions-apiserver v0.26.3 // indirect
Expand Down
Loading