Kubernetes Postgres Migration
Migrate from Bolt store to Postgres with Helm
As your BindPlane OP environment grows in size and importance, it can be desirable to migrate BindPlane's backend to Postgres. Using Postgres allows BindPlane to operate in High Availability.
Prerequisites
The following prerequisites must be met before performing the migration.
CLI
warning
Your CLI version should match your control plane version.
The migration requires the BindPlane CLI. Make sure you have a profile configured.
Example profile configuration:
Credentials
The migration process will involve exporting and importing resources using the BindPlane CLI. The export process will not return sensitive data, such as credentials. You must have access to all credentials used by your resources, such as usernames and passwords, API keys, etc.
Deprecated Resources
When resources are deprecated by BindPlane, they are removed unless they are in use. When migrating from Bolt store to Postgres, any deprecated resources will need to be replaced. Generally, a resource is deprecated and replaced by a newer version if a breaking change is made.
Using the BindPlane CLI and jq
, check to see if any of your resource types are deprecated.
Example output. The parse_severity
processor is deprecated. The delete_empty_values
processor is not deprecated.
If there are deprecated resource types, it indicates that you have a configuration or resource library component that is deprecated. Remove the component from your configurations and delete it from the resource library, if it is present there.
Secret Key
Note the secret key. You can find your secret key with the bindplane get account
command.
Example:
You will need your secret key during the migration process.
Postgres
Postgres should be pre-provisioned and include a database named bindplane
or something similar.
There should be a user with full access to the database named bindplane
. The BindPlane Helm chart
does not deploy or manage the Postgres instance.
Max Connections
Make a note of the maximum connections allowed to Postgres. When configuring BindPlane, you can set the maximum number of connections per BindPlane pod.
Prometheus
During the migration, a new Prometheus instance will be deployed by the Helm chart. This means you will lose existing Prometheus data. Prometheus is used by BindPlane to track agent throughput and data reduction metrics. It is not considered critical data when performing the migration.
If you manage your own Prometheus instance, outside of the Helm chart, you will not lose data.
Migration Steps
During the migration, users mustn't modify BindPlane resources. Doing so will cause the exported resources to become out of sync.
1. Export Resources
warning
Make sure there are no pending configuration changes. When exporting a configuration, the pending version will be exported if changes are present.
Export resources to a directory called resources
. Avoid modifying resources after exporting.
1.1 Sensitive Values
Using a text editor, find all instances of (sensitive)
in your resource files. Make a note of each
resource that contains a sensitive value. When the resources are imported, you will need to update
them with the correct value.
2. Deploy High Availability BindPlane
warning
Make sure the new BindPlane deployment uses the same image tag as your current deployment.
2.1 Helm Values
Copy your Helm values file to a new file, values-ha.yaml
or backup the existing values file.
Make the following changes to the HA values file.
- Add the
replica
top level key, and set it to3
- Set
backend.type
topostgres
- Configure
backend.postgres
with the values that are correct for your Postgres instance.
- Update the top-level
resources
section to reflect multiple pods. Follow the High Availability Sizing documentation for details.
- If using the Helm-managed Prometheus, ensure its resources and capacity are increased if you expect a high agent count.
- Enable the NATS Event Bus.
- Add the top-level
nats
configuration. This configuration is not nested undereventbus
.
- Update
config.server_url
andconfig.remote_url
to use a "staging" hostname. During the migration, BindPlane will need to be accessed over a temporary hostname to allow the existing deployment to continue functioning.
2.2 Helm Deployment
Deploy the new BindPlane HA environment using Helm. Make sure to use a new name.
warning
Chart version 1.12.0 or newer is required for NATS event bus.
Once deployed, the old and new HA deployments will be present side by side, if deployed to the same namespace. It is expected that some of the pods will have restarted during the initial deployment.
2.3 Ensure Access
Make sure you can access the new environment using your existing solution (NGINX, Istio Gateway, etc). This may require you to create an additional ingress configuration.
It is important to keep the current ingress solution routing to your old BindPlane deployment, to prevent downtime. Access to the new HA environment should be handled using a temporary solution, allowing you to import resources.
3. Configure Project
3.1 Initial Sign In
Sign into BindPlane for the first time, and follow the onboarding prompts.
3.2 Configure CLI
Create a new CLI profile for accessing the new environment.
Ensure the CLI profile is working by issuing a get agent
command. The command should not return
any agents. If it does, you might be using the profile for the old BindPlane instance.
3.3 Update Project Secret Key
Update the new project's secret key with the secret key used by the old BindPlane deployment. This will allow agents to connect to the new BindPlane instance and project.
It will look similar to this.
Update spec.secretKey
in ha-account.yaml
to match the secret key from the original environment.
Update the account using the apply
command.
Check if it worked: bindplane get account
. The output should show the original secret key. You can also check the UI.
4 Import Resources
4.1 Import
Import your resources using the apply
command.
4.2 Update Sensitive Values
Find all components that use sensitive values, and update them. The resources exported from the previous BindPlane instance will not contain sensitive values such as usernames and passwords or API keys.
4.3 Rollout Configurations
Trigger a rollout for all configurations to ensure they will be pushed to agents during the cut-over to the HA instance.
5 Cut Over Access
Now that the new BindPlane instance has had its secret key configured and resources imported, it is ready to accept connections from agents.
5.1 Helm Configuration
Update config.server_url
and config.remote_url
to your primary hostname, the hostname used by the
old BindPlane instance. Use Helm to deploy the change.
5.2
Update your ingress solution to point to the new BindPlane HA deployment.
Note that agents will likely remain connected to the old BindPlane instance until one of two things happens:
- The agent(s) are restarted
- The old BindPlane instance is restarted
Restart the old BindPlane StatefulSet pod to force agents to reconnect, allowing them to connect to new HA system.
6 Verify Functionality
- Ensure resource utilization is acceptable
- Ensure agents are connecting
- Ensure Recent Telemetry is working
- Ensure Live Preview is working
- Ensure configuration rollout can be triggered and finished
6.1 Abort
If the new system is not working correctly or appears unstable, revert your ingress change to point to the old BindPlane instance. Restart all BindPlane HA pods to force agents to reconnect to the old BindPlane system.
7 Finish and Cleanup
At this point, you have successfully migrated to BindPlane High Availability with NATS and Postgres.
You can safely and optionally remove the old BindPlane instance using helm uninstall
. The New BindPlane
deployment does not rely on any resources from the old BindPlane instance.