Skip to content

delta10/access-operator

Repository files navigation

Access operator

This project uses Kubebuilder to implement a Kubernetes operator that manages access to databases for different applications.

Setup

First make sure you have Kubebuilder installed on your machine. Follow the instructions on the Kubebuilder website to set it up.

If you're running Windows use WSL.

Running the operator locally

First install the operator with the following command:

make install

Install from a release

Every tagged release publishes an install.yaml asset that references the prebuilt image on GHCR.

kubectl apply -f https://github.com/<org>/<repo>/releases/download/<tag>/install.yaml

If you wish to install the operator via its yaml you can find it in config/crd/bases/access.k8s.delta10.nl_postgresaccesses.yaml

Then run it:

make run

Cross-namespace existing secrets (optional)

By default, PostgresAccess.spec.connection.existingSecret is resolved in the same namespace as the PostgresAccess resource.

To allow cross-namespace references, create exactly one Controller resource and set:

  • spec.settings.existingSecretNamespace=true

If there are zero Controller resources, the safe default is false. If there are multiple Controller resources, cross-namespace lookups fail with MultipleControllersFound.

When using the docker compose you can use a simple sample config with:

kubectl apply -f config/samples/access_v1_postgresaccess.yaml

Running tests

Ofcourse you can also use act to run the whole pipeline locally in Docker but preformance isn't great.

Unit tests

make test

e2e tests

for e2e tests, you can use: Make sure you have kind installed and running, then you can run the e2e tests with:

make test-e2e

Though beware it'll consume quite a bit of memory, within WSL2 it consumed 9gb during the test run.

if you don't have a database running locally you can use docker compose to start a postgres database:

docker compose up -d

Linter

Install golangci-lint first, then you can run the linter with:

golangci-lint run

formatting issues can be fixed with:

golangci-lint fmt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages