Skip to content

Latest commit

 

History

History
1549 lines (653 loc) · 48.9 KB

protocol.md

File metadata and controls

1549 lines (653 loc) · 48.9 KB

Protocol Documentation

Table of Contents

Top

backup.proto

BackupCapabilitiesRequest

Intentionally empty.

BackupCapabilitiesResult

Field Type Label Description
capabilities BackupCapability repeated All the capabilities that the controller service supports. This field is OPTIONAL.

BackupCapability

Field Type Label Description
rpc BackupCapability.RPC

BackupCapability.RPC

Field Type Label Description
type BackupCapability.RPC.Type

BackupRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster being backed up
backup_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Backup that is being taken
parameters BackupRequest.ParametersEntry repeated This field is OPTIONAL. Value of this field is the configuration of this backup as set in the Backup or in the ScheduledBackup object

BackupRequest.ParametersEntry

Field Type Label Description
key string
value string

BackupResult

Field Type Label Description
backup_id string This field is REQUIRED and contains a machine-readable ID of the backup that is being taken
backup_name string This field is OPTIONAL and contains a human-readable name of the backup that is being taken
started_at int64 This field is REQUIRED and contains the Unix timestamp of the start time of the backup
stopped_at int64 This field is REQUIRED and contains the Unix timestamp of the end time of the backup
begin_wal string This field is OPTIONAL and contains the current WAL when the backup was started
end_wal string This field is OPTIONAL and contains the current WAL at the end of the backup
begin_lsn string This field is OPTIONAL and contains the current LSN record when the backup was started
end_lsn string This field is OPTIONAL and contains the current LSN record when the backup has finished
backup_label_file bytes This field is OPTIONAL and contains the backup label of the backup that have been taken
tablespace_map_file bytes This field is OPTIONAL and contains the tablespace map of the backup that have been taken
instance_id string This field is OPTIONAL and contains the ID of the instance that have been backed up
online bool This field is REQUIRED and is set to true for online/hot backups and to false otherwise.
metadata BackupResult.MetadataEntry repeated This field is OPTIONAL and contains all the plugin specific information that needs to be stored

BackupResult.MetadataEntry

Field Type Label Description
key string
value string

BackupCapability.RPC.Type

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_BACKUP 1 TYPE_BACKUP indicates that the Plugin is able to take physical backups. This feature is required for every plugin exposing the Backup service

Backup

Method Name Request Type Response Type Description
GetCapabilities BackupCapabilitiesRequest BackupCapabilitiesResult GetCapabilities gets the capabilities of the Backup service
Backup BackupRequest BackupResult Backup takes a physical backup of PostgreSQL.

Top

identity.proto

GetPluginCapabilitiesRequest

Intentionally empty.

GetPluginCapabilitiesResponse

Field Type Label Description
capabilities PluginCapability repeated All the capabilities that the controller service supports. This field is OPTIONAL.

GetPluginMetadataRequest

Intentionally empty.

GetPluginMetadataResponse

Field Type Label Description
name string The name MUST follow domain name notation format (https://tools.ietf.org/html/rfc1035#section-2.3.1). It SHOULD include the plugin's host company name and the plugin name, to minimize the possibility of collisions. It MUST be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between. This field is REQUIRED.
version string This field is REQUIRED. Value of this field is opaque.
display_name string A name to display for the plugin. This field is REQUIRED.
description string A description for the plugin. This field is REQUIRED.
project_url string URL of the home page of the plugin project.
repository_url string URL of the source code repository for the plugin project.
license string License of the plugin. This field is REQUIRED.
license_url string URL of the license of the plugin. This field is REQUIRED.
maturity string Maturity level (alpha, beta, stable)
vendor string Provider/vendor of the plugin, e.g. an organization
manifest GetPluginMetadataResponse.ManifestEntry repeated This field is OPTIONAL. Values are opaque.

GetPluginMetadataResponse.ManifestEntry

Field Type Label Description
key string
value string

PluginCapability

Field Type Label Description
service PluginCapability.Service

PluginCapability.Service

Field Type Label Description
type PluginCapability.Service.Type

ProbeRequest

Intentionally empty.

ProbeResponse

Field Type Label Description
ready bool This field is OPTIONAL. If not present, the caller SHALL assume that the plugin is in a ready state and is accepting calls to its Controller and/or Node services (according to the plugin's reported capabilities).

PluginCapability.Service.Type

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_OPERATOR_SERVICE 1 TYPE_OPERATOR_SERVICE indicated that the Plugin provider RPCs for the Operator service. The presence of this capability determines whether the CO will attempt to invoke the REQUIRED Operator RPCs, as well as specific RPCs as indicated by GetCapabilities.
TYPE_WAL_SERVICE 2 TYPE_WAL_SERVICE indicates that the Plugin provides RPCs for the WAL service. Plugins MAY provide this capability. The presence of this capability determines whether the CO will attempt to invoke the REQUIRED WALService RPCs, as well as specific RPCs as indicated by GetCapabilities.
TYPE_BACKUP_SERVICE 3 TYPE_BACKUP_SERVICE indicates that the Plugin provides RPCs for the Backup service. The presence of this capability determines whether the CO will attempt to invoke the REQUIRED Backup Service RPCs, as well as specific RPCs as indicated by GetCapabilities.
TYPE_LIFECYCLE_SERVICE 4 TYPE_LIFECYCLE_SERVICE indicates that the Plugin provides RPCs for the Lifecycle service.
TYPE_RECONCILER_HOOKS 5 TYPE_RECONCILER_HOOKS indicates that the Plugin provides RPCs to enhance the behavior of the reconcilers
TYPE_RESTORE_JOB 6 TYPE_RESTORE_JOB_HOOKS indicates that the Plugin provides RPCs to enhance the behavior of the restore jobs

Identity

Method Name Request Type Response Type Description
GetPluginMetadata GetPluginMetadataRequest GetPluginMetadataResponse GetPluginMetadata gets the plugin metadata
GetPluginCapabilities GetPluginCapabilitiesRequest GetPluginCapabilitiesResponse GetPluginCapabilities gets information about this plugin
Probe ProbeRequest ProbeResponse Probe is used to tell if the plugin is ready to receive requests

Top

operator.proto

DeregisterRequest

Field Type Label Description
definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster that should receive the default values

DeregisterResponse

OperatorCapabilitiesRequest

Intentionally empty.

OperatorCapabilitiesResult

Field Type Label Description
capabilities OperatorCapability repeated All the capabilities that the controller service supports. This field is OPTIONAL.

OperatorCapability

Field Type Label Description
rpc OperatorCapability.RPC

OperatorCapability.RPC

Field Type Label Description
type OperatorCapability.RPC.Type

OperatorMutateClusterRequest

Field Type Label Description
definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster that should receive the default values

OperatorMutateClusterResult

Field Type Label Description
json_patch bytes This field is OPTIONAL. Value of this field is a JSONPatch to be applied on the passed Cluster definition

OperatorValidateClusterChangeRequest

Field Type Label Description
old_cluster bytes This field is REQUIRED. Value of this field is the JSON serialization of the current Cluster definition
new_cluster bytes This field is REQUIRED. Value of this field is the JSON serialization of the updated Cluster definition

OperatorValidateClusterChangeResult

Field Type Label Description
validation_errors ValidationError repeated This field is OPTIONAL. Value of this field is a set of validation errors

OperatorValidateClusterCreateRequest

Field Type Label Description
definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster that is being created

OperatorValidateClusterCreateResult

Field Type Label Description
validation_errors ValidationError repeated This field is OPTIONAL. Value of this field is a set of validation errors

SetStatusInClusterRequest

Field Type Label Description
cluster bytes This field is REQUIRED. Value of this field is the JSON serialization of the current Cluster definition

SetStatusInClusterResponse

Field Type Label Description
json_status bytes This field is OPTIONAL. No value means no-op, otherwise the passed json is set inside the .status.plugins[pluginName] key

ValidationError

Field Type Label Description
path_components string repeated This field is REQUIRED. Value of this field is
value string This field is REQUIRED. Value of this field is the value that caused a validation error
message string This field is REQUIRED. Value of this field is a description of the validation error

OperatorCapability.RPC.Type

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_VALIDATE_CLUSTER_CREATE 1 TYPE_VALIDATE_CLUSTER_CREATE indicates that the Plugin is able to reply to the ValidateClusterCreate RPC request
TYPE_VALIDATE_CLUSTER_CHANGE 2 TYPE_VALIDATE_CLUSTER_CHANGE indicates that the Plugin is able to reply to the ValidateClusterChange RPC request
TYPE_MUTATE_CLUSTER 3 TYPE_MUTATE_CLUSTER indicates that the Plugin is able to reply to the MutateCluster RPC request
TYPE_SET_STATUS_IN_CLUSTER 5 TYPE_SET_STATUS_IN_CLUSTER indicates that the Plugin is able to reply to the SetStatusInCluster RPC request
TYPE_DEREGISTER 6 TYPE_DEREGISTER indicates that the Plugin is able to execute the cleanup logic once it is removed from the cluster definition

Operator

Method Name Request Type Response Type Description
GetCapabilities OperatorCapabilitiesRequest OperatorCapabilitiesResult GetCapabilities gets the capabilities of the WAL service
ValidateClusterCreate OperatorValidateClusterCreateRequest OperatorValidateClusterCreateResult ValidateCreate improves the behavior of the validating webhook that is called on creation of the Cluster resources
ValidateClusterChange OperatorValidateClusterChangeRequest OperatorValidateClusterChangeResult ValidateClusterChange improves the behavior of the validating webhook of is called on updates of the Cluster resources
MutateCluster OperatorMutateClusterRequest OperatorMutateClusterResult MutateCluster fills in the defaults inside a Cluster resource
SetStatusInCluster SetStatusInClusterRequest SetStatusInClusterResponse SetStatusInCluster is invoked at the end of the reconciliation loop and it is used to set the plugin status inside the .status.plugins[pluginName] map key
Deregister DeregisterRequest DeregisterResponse Deregister is invoked when the plugin is removed from the cluster definition. It is expected that the plugin executes its cleanup logic when this method is invoked.

Top

operator_lifecycle.proto

OperatorLifecycleCapabilities

Field Type Label Description
group string The Kubernetes resource group (such as "apps" or empty for core resources)
kind string The Kubernetes Kind name (such as "Cluster" or "Pod")
operation_types OperatorOperationType repeated The operation type

OperatorLifecycleCapabilitiesRequest

This message is intentionally empty

OperatorLifecycleCapabilitiesResponse

Field Type Label Description
lifecycle_capabilities OperatorLifecycleCapabilities repeated This message is OPTIONAL, containing the list of resources for which the lifecycle hook is called

OperatorLifecycleRequest

Field Type Label Description
operation_type OperatorOperationType This field is REQUIRED.
cluster_definition bytes This field is REQUIRED
object_definition bytes This field is REQUIRED.

OperatorLifecycleResponse

Field Type Label Description
json_patch bytes This field is OPTIONAL.

OperatorOperationType

Field Type Label Description
type OperatorOperationType.Type

OperatorOperationType.Type

The operator type corresponds to the Kubernetes API method

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_PATCH 1
TYPE_UPDATE 2
TYPE_CREATE 3
TYPE_DELETE 4
TYPE_DEREGISTER 5

OperatorLifecycle

Method Name Request Type Response Type Description
GetCapabilities OperatorLifecycleCapabilitiesRequest OperatorLifecycleCapabilitiesResponse GetCapabilities gets the capabilities of the Lifecycle service
LifecycleHook OperatorLifecycleRequest OperatorLifecycleResponse LifecycleHook allows the plugin to manipulate the Kubernetes resources before the CNPG operator applies them to the Kubernetes cluster.

Top

postgres.proto

EnrichConfigurationRequest

Field Type Label Description
configs EnrichConfigurationRequest.ConfigsEntry repeated This field is REQUIRED and represent the PostgreSQL configuration parameters as generated by the instance manager

EnrichConfigurationRequest.ConfigsEntry

Field Type Label Description
key string
value string

EnrichConfigurationResult

Field Type Label Description
configs EnrichConfigurationResult.ConfigsEntry repeated This field is OPTIONAL. It represent the configuration parameters that need to be changed before applying a new configuration

EnrichConfigurationResult.ConfigsEntry

Field Type Label Description
key string
value string

PostgresCapabilitiesRequest

Intentionally empty

PostgresCapabilitiesResult

Field Type Label Description
capabilities PostgresCapability repeated All the capabilities that the controller service supports. This field is OPTIONAL.

PostgresCapability

Field Type Label Description
rpc PostgresCapability.RPC

PostgresCapability.RPC

Field Type Label Description
type PostgresCapability.RPC.Type

PostgresCapability.RPC.Type

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_ENRICH_CONFIGURATION 1 TYPE_BACKUP indicates that the Plugin is able to enrich the PostgreSQL configuration via the EnrichConfiguration endpoint

Postgres

Method Name Request Type Response Type Description
GetCapabilities PostgresCapabilitiesRequest PostgresCapabilitiesResult GetCapabilities gets the capabilities of the Backup service
EnrichConfiguration EnrichConfigurationRequest EnrichConfigurationResult EnrichConfiguration is called before applying the configuration to PostgreSQL

Top

reconciler.proto

ReconcilerHooksCapabilitiesRequest

ReconcilerHooksCapabilitiesResult

Field Type Label Description
reconciler_capabilities ReconcilerHooksCapability repeated This message is OPTIONAL, containing the list of resources for which the lifecycle hook is called

ReconcilerHooksCapability

Field Type Label Description
kind ReconcilerHooksCapability.Kind kind is the controller Kind

ReconcilerHooksRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster tied to the Kind being reconciled
resource_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the resource being reconciled. Please note that in case of Cluster Reconciliation, the resource_definition will match the cluster_definition

ReconcilerHooksResult

ReconcilerHooksResult response is used to instruct then the CNPG controller on which action take after the plugin execution.

Field Type Label Description
behavior ReconcilerHooksResult.Behavior This field is REQUIRED, and indicates the behavior that should be used for the current reconciliation loop.
requeue_after int64 This field is OPTIONAL. If true, the current reconciliation loop will be stopped and the operator will ensure that another one will be run in the requested number of seconds. IMPORTANT: the new reconciliation loop may start even before the number of specified seconds.

ReconcilerHooksCapability.Kind

Name Number Description
KIND_UNSPECIFIED 0
KIND_CLUSTER 1 KIND_CLUSTER indicates that the plugin will plug the Cluster reconciler
KIND_BACKUP 2 KIND_BACKUP indicates that the plugin will plug the Backup reconciler

ReconcilerHooksResult.Behavior

Name Number Description
BEHAVIOR_UNSPECIFIED 0
BEHAVIOR_CONTINUE 1 BEHAVIOR_CONTINUE indicates that this reconciliation loop will proceed running. BEHAVIOR_CONTINUE is useful when the plugin executes changes on internal status or resources not directly managed by the main reconciliation loop
BEHAVIOR_REQUEUE 2 BEHAVIOR_REQUEUE indicates that this reconciliation loop will be stopped and a new one will be requested. BEHAVIOR_REQUEUE should always be set when the plugin applies changes on resources that are directly managed by the main reconciliation loop
BEHAVIOR_TERMINATE 3 BEHAVIOR_TERMINATE indicates that the main reconciliation loop needs to be marked as succeeded and no further operations needs to be taken. This should be used when the invoked Reconcile hook act as a substitute for the main CNPG reconciliation loop. An example would be a plugin that substitutes the Backup logic of CNPG.

ReconcilerHooks

ReconcilerHooks offers a way for the plugins to directly execute changes on the resources through the kube-api server.

Method Name Request Type Response Type Description
GetCapabilities ReconcilerHooksCapabilitiesRequest ReconcilerHooksCapabilitiesResult GetCapabilities gets the capabilities of the Backup service
Pre ReconcilerHooksRequest ReconcilerHooksResult Pre is executed before the operator executes the reconciliation loop It is a way for the plugins to directly execute changes on the resources through the kube-api server.
Post ReconcilerHooksRequest ReconcilerHooksResult Post is executed after the operator executes the reconciliation loop It is a way for the plugins to directly execute changes on the resources through the kube-api server.

Top

restore_job.proto

RestoreJobHooksCapabilitiesRequest

RestoreJobHooksCapabilitiesResult

Field Type Label Description
capabilities RestoreJobHooksCapability repeated This field is REQUIRED and contains the describe capability

RestoreJobHooksCapability

Field Type Label Description
kind RestoreJobHooksCapability.Kind

RestoreRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster.

RestoreResponse

Field Type Label Description
restore_config string This field is REQUIRED. Value of this field is the string representation of PostgreSQL configuration parameters to use for the restore.
envs string repeated This field if REQUIRED. Environment variables to be set in the restore job, expressed as NAME=VALUE.

RestoreJobHooksCapability.Kind

Name Number Description
KIND_UNSPECIFIED 0
KIND_RESTORE 1 KIND_RESTORE means that the plugin is able to handle Restore requests

RestoreJobHooks

RestoreJobHooks offers a way for the plugins to enhance the cluster recovery process

Method Name Request Type Response Type Description
GetCapabilities RestoreJobHooksCapabilitiesRequest RestoreJobHooksCapabilitiesResult GetCapabilities gets the capabilities of the Backup service
Restore RestoreRequest RestoreResponse Restore is called to restore a PGDATA

Top

wal.proto

SetFirstRequiredRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster corresponding to the Pod being applied
first_required_wal string This field is REQUIRED. Value of this field is the name of the first required WAL in the WAL archive for this cluster (normally based on the begin WAL of the first available base backup for the cluster)

SetFirstRequiredResult

Intentionally empty.

WALArchiveRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster corresponding to the Pod being applied
source_file_name string This field is REQUIRED. Value of this field is the full path of the WAL file that should be archived
parameters WALArchiveRequest.ParametersEntry repeated This field is OPTIONAL. Values are opaque.

WALArchiveRequest.ParametersEntry

Field Type Label Description
key string
value string

WALArchiveResult

Intentionally empty.

WALCapabilitiesRequest

Intentionally empty.

WALCapabilitiesResult

Field Type Label Description
capabilities WALCapability repeated All the capabilities that the controller service supports. This field is OPTIONAL.

WALCapability

Field Type Label Description
rpc WALCapability.RPC

WALCapability.RPC

Field Type Label Description
type WALCapability.RPC.Type

WALRestoreRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster corresponding to the Pod being applied
source_wal_name string This field is REQUIRED. Value of this field is the name of the WAL to be retrieved from the archive, such as: 000000010000000100000012
destination_file_name string This field is REQUIRED. Value of this field is the full path where the WAL file should be stored
parameters WALRestoreRequest.ParametersEntry repeated This field is OPTIONAL. Values are opaque.

WALRestoreRequest.ParametersEntry

Field Type Label Description
key string
value string

WALRestoreResult

Intentionally empty.

WALStatusRequest

Field Type Label Description
cluster_definition bytes This field is REQUIRED. Value of this field is the JSON serialization of the Cluster corresponding to the Pod being applied

WALStatusResult

Field Type Label Description
first_wal string This field is REQUIRED. Value of this field is the base name of the oldest archived WAL, such as: 000000010000000100000012
last_wal string This field is REQUIRED. Value of this field is the base name of the newest archived WAL, such as: 000000010000000100000014
additional_information WALStatusResult.AdditionalInformationEntry repeated This field is OPTIONAL. Value is opaque.

WALStatusResult.AdditionalInformationEntry

Field Type Label Description
key string
value string

WALCapability.RPC.Type

Name Number Description
TYPE_UNSPECIFIED 0
TYPE_ARCHIVE_WAL 1 TYPE_ARCHIVE_WAL indicates that the Plugin is able to reply to the Archive RPC request
TYPE_RESTORE_WAL 2 TYPE_RESTORE_WAL indicates that the Plugin is able to reply to the Restore RPC request
TYPE_STATUS 3 TYPE_STATUS indicates that the Plugin is able to reply to the Status RPC request
TYPE_SET_FIRST_REQUIRED 4 TYPE_SET_FIRST_REQUIRED indicates that the Plugin is able to reply to the SetFirstRequired RPC request

WAL

Method Name Request Type Response Type Description
GetCapabilities WALCapabilitiesRequest WALCapabilitiesResult GetCapabilities gets the capabilities of the WAL service
Archive WALArchiveRequest WALArchiveResult Archive copies one WAL file into the archive
Restore WALRestoreRequest WALRestoreResult Restores copies WAL file from the archive to the data directory
Status WALStatusRequest WALStatusResult Status gets the statistics of the WAL file archive
SetFirstRequired SetFirstRequiredRequest SetFirstRequiredResult SetFirstRequired sets the first required WAL for the cluster

Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)