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

Bootstrap Companions in Kubernetes Environments #156

Merged
merged 6 commits into from
Jan 25, 2024

Conversation

schrieveslaach
Copy link
Contributor

@schrieveslaach schrieveslaach commented Jan 11, 2024

This commit introduces the configuration bootstrapping.containers which provides a way to parse the configuration of application wide companions because the current available configuration of companions is quite limiting (Current backends, Docker and Kubernetes, offer way more options than the PREvant configuration object allows). For example, PREvant was limited to self-contained applications where each microservice only relies on interactions via network API calls (REST, database connections, messaging, etc.) With this commit PREvant is now able to deploy application companions that are more powerful than the PREvant configuration in Kubernetes backends.

If bootstrapping.containers is defined, PREvant will start one or more containers on the infrastructure backend that are expected to generate Kubernetes manifests as output on standard out (stdout) that will be parsed by PREvant and supported are:

  • roles and role bindings
  • config maps and secrets
  • service accounts
  • persistent volume claims
  • services
  • pods, deployments, stateful sets, and jobs

Then before deploying these manifests PREvant merges all objects with the objects generated from the HTTP request payload. Thus you can add or overwrite configurations. For example, you can change the image used or an environment variable. If you overwrite any configuration the companion will be turned into an instance (as PREvant did before).

Ingresses won't be deployed if the bootstrap container outputs one of these. Instead they will be parsed and if they use the ingress class nginx they will be transformed into Traefik ingresses and middlewares so that the microservices will be available via web interface.

This approach make #143 obsolete and fixes #123 and contributes to #146.

@schrieveslaach schrieveslaach marked this pull request as draft January 11, 2024 10:13
@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch 2 times, most recently from 9fb15a7 to c293e03 Compare January 11, 2024 13:14
@schrieveslaach schrieveslaach mentioned this pull request Jan 11, 2024
4 tasks
@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch 2 times, most recently from 5cf9924 to 2d11894 Compare January 16, 2024 07:51
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docs/companions.md Outdated Show resolved Hide resolved
docs/companions.md Outdated Show resolved Hide resolved
docs/companions.md Outdated Show resolved Hide resolved
docs/companions.md Outdated Show resolved Hide resolved
docs/companions.md Outdated Show resolved Hide resolved
@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch from 9e04a38 to 0925fc1 Compare January 23, 2024 07:26
@schrieveslaach schrieveslaach marked this pull request as ready for review January 23, 2024 13:58
@schrieveslaach
Copy link
Contributor Author

@aixigo-ohornischer, thanks for proofing this PR.

@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch 2 times, most recently from d7bdf91 to 3509e8a Compare January 23, 2024 15:04
This commit introduces the configuration `bootstrapping.containers`
which provides a way to parse the configuration of application wide
companions because the current available configuration of companions if
quite limiting (Current backends, Docker and Kubernetes, offer way more
options than the PREvant configuration object allows). For example,
PREvant was limited to self-contained applications where each
microservice only relies on interactions via network API calls (REST,
database connections, messaging, etc.) With this commit PREvant is now
able to deploy application companions that are more powerful than the
PREvant configuration in Kubernetes backends.

If `bootstrapping.containers` is defined, PREvant will start one or more
containers on the infrastructure backend that are expected to generate
Kubernetes manifests as output on standard out (stdout) that will be
parsed by PREvant and supported are:

 - roles and role bindings
 - config maps and secrets
 - service accounts
 - persistent volume claims
 - services
 - pods, deployments, stateful sets, and jobs

Then before deploying these manifests PREvant merges all objects with
the objects generated from the HTTP request payload. Thus you can add or
overwrite configurations. For example, you can change the image used or
an environment variable. If you overwrite any configuration the
companion will be turned into an instance (as PREvant did before).

Ingresses won't be deployed if the bootstrap container outputs one of
these. Instead they will be parsed and if they use the ingress class
`nginx` they will be transformed into Traefik ingresses and middlewares
so that the microservices will be available via web interface.

This approach make #143 obsolete and fixes #123 and contributes to #146.
This commit ensures that there are less requests to the Kubernetes API,
improving the performance. Additionally, it fixes some additional TODO
comments.
@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch from 3509e8a to 675f26e Compare January 24, 2024 08:29
Copy link
Contributor

@samuchila samuchila left a comment

Choose a reason for hiding this comment

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

Some minor typo's identified after reading the changes

docs/companions.md Outdated Show resolved Hide resolved
api/src/infrastructure/kubernetes/deployment_unit.rs Outdated Show resolved Hide resolved
api/src/infrastructure/kubernetes/infrastructure.rs Outdated Show resolved Hide resolved
api/src/infrastructure/kubernetes/payloads.rs Outdated Show resolved Hide resolved
@schrieveslaach schrieveslaach force-pushed the bootstrapping-k8s-companions branch from 675f26e to c2b240d Compare January 24, 2024 14:03
@schrieveslaach schrieveslaach merged commit a21eebb into master Jan 25, 2024
2 checks passed
@schrieveslaach schrieveslaach deleted the bootstrapping-k8s-companions branch January 25, 2024 12:12
`registry.example.com/user/bootstrap-helm-chart:lastet` is based on a [Helm
chart][helm-chart] that generates an OpenID provider for your application with
[Keycloak][keycloak]. Additionally, it is possible to pass additional arguments
to the container than can be templated with [Handlebars][handlebars].
Copy link
Contributor

Choose a reason for hiding this comment

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

to the container (than->that) can be templated with [Handlebars][handlebars]

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.

Persistent Data
4 participants