diff --git a/.github/workflows/clean.yaml b/.github/workflows/clean.yaml index 259e5fe0..5f97d9a0 100644 --- a/.github/workflows/clean.yaml +++ b/.github/workflows/clean.yaml @@ -36,7 +36,7 @@ jobs: context: "" - name: pgskipper-docker-pgbackrest-sidecar context: "" - - name: pgskipper-docker-query-exporter + - name: qubership-docker-query-exporter context: "" - name: pgskipper-docker-replication-controller context: "" diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..3428bd6d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,229 @@ +# AGENTS.md + +This file provides guidance to AI coding assistants when working with code in this repository. + +## Project Overview + +pgskipper-operator is a Kubernetes operator that provides PostgreSQL as a service on Kubernetes and OpenShift. The operator manages PostgreSQL clusters using Patroni for high availability and includes various supporting services. + +## Repository Architecture + +This is a **monorepo** with multiple Go modules: + +- **`/operator`** - Main operator implementation that manages two Custom Resource Definitions: + - `PatroniCore` (api/patroni/v1) - Core PostgreSQL cluster management with Patroni + - `PatroniServices` (api/apps/v1) - Additional PostgreSQL services layer + +- **`/services`** - Supporting microservices that run alongside PostgreSQL: + - `backup-daemon` - Handles PostgreSQL backups + - `dbaas-adapter` - Database-as-a-Service adapter + - `monitoring-agent` - Collects PostgreSQL metrics + - `patroni` - Patroni service implementation + - `pgbackrest-sidecar` - pgBackRest backup sidecar + - `query-exporter` - Prometheus query exporter + - `replication-controller` - Manages PostgreSQL replication + - `upgrade` - Handles PostgreSQL version upgrades + +- **`operator/charts`** - Helm charts + - `patroni-core` - Helm chart for Patroni Core operator + - `patroni-services` - Helm chart for PostgreSQL Services operator + +- **`/tests`** - Robot Framework tests + +## Operator Dual-Mode Operation + +The operator runs in one of two modes controlled by the `OPERATOR_ROLE` environment variable: + +1. **`OPERATOR_ROLE=patroni`** - Runs PatroniCoreReconciler (manages PatroniCore CRD) +2. **Default (or any other value)** - Runs PostgresServiceReconciler (manages PatroniServices CRD) + +Entry point: `operator/cmd/pgskipper-operator/main.go` + +## Building and Development + +### Operator + +Work from `/operator` directory: + +```bash +cd operator + +# Format code +make fmt + +# Vet code +make vet + +# Update dependencies +make deps + +# Compile binary +make compile + +# Build Docker image (requires TAG_ENV and DOCKER_NAMES env vars) +make docker-build + +# Full local build +make local # fmt + gzip-charts + deps + vet + compile + docker-build + docker-push + +# Generate CRDs from API types +make generate +``` + +### Services + +Each service in `/services` has its own Makefile with similar targets: + +```bash +cd services/ + +# Build Docker image +make docker-build + +# Run tests (where available) +make test + +# Format code +make fmt +``` + +### Default Docker Image Naming + +Without environment variables, images default to: +- Operator: `ghcr.io/netcracker/pgskipper-operator:local` +- Services: `ghcr.io/netcracker/pgskipper-docker-:local` + +Override with: +```bash +TAG_ENV=v1.2.3 DOCKER_NAMES="custom-registry/image:tag" make docker-build +``` + +## Key Package Structure + +In `operator/pkg`: + +- `reconciler/` - Core reconciliation logic +- `deployment/` - Kubernetes deployment management +- `storage/` - Storage provisioning and PV management +- `credentials/` - Secret and credential management +- `disasterrecovery/` - DR manager initialization +- `consul/` - Consul integration +- `pooler/` - Connection pooler management +- `postgresexporter/`, `pgbackrestexporter/`, `queryexporter/` - Metrics exporters +- `util/` - Utility functions +- `client/` - Kubernetes client wrappers + +## Testing + +Robot Framework tests are in `/tests/robot`: + +```bash +# Tests include: +# - check_installation +# - check_crud_user +# - check_manual_switchover +# - patroni_rest_api_auth +``` + +Service-specific Go tests: +```bash +cd services/ +make test +``` + +## CRD Generation + +CRDs are generated from Go types using controller-gen: + +```bash +cd operator +make generate +``` + +This generates: +- CRDs in `operator/charts/patroni-core/crds/` and `operator/charts/patroni-services/crds/` +- DeepCopy methods in `api/*/zz_generated.deepcopy.go` +- OpenAPI specs in `api/*/zz_generated.openapi.go` + +API type definitions: +- `operator/api/common/v1` - Common types +- `operator/api/apps/v1/postgresservice_types.go` - PatroniServices CRD +- `operator/api/patroni/v1/patronicore_types.go` - PatroniCore CRD + +## Helm Chart Preparation + +The operator embeds Helm charts into its deployment: + +```bash +cd operator +make gzip-charts # Compresses Grafana dashboards +make move-charts # Copies charts to operator/deployments/charts/patroni-services +``` + +## Installation (From Quickstart) + +1. Install CRDs: +```bash +kubectl create -f ./operator/charts/patroni-core/crds/netcracker.com_patronicores.yaml +kubectl create -f ./operator/charts/patroni-services/crds/netcracker.com_patroniservices.yaml +``` + +2. Install Patroni Core: +```bash +helm install --namespace=postgres --create-namespace \ + -f ./operator/charts/patroni-core/patroni-core-quickstart-sample.yaml \ + patroni-core ./operator/charts/patroni-core +``` + +3. Wait for leader promotion: +```bash +kubectl -n postgres get pods --selector=pgtype=master --field-selector=status.phase=Running +``` + +4. Install Patroni Services: +```bash +helm install --namespace=postgres \ + -f ./operator/charts/patroni-services/patroni-services-quickstart-sample.yaml \ + patroni-services ./operator/charts/patroni-services +``` + +## Dependencies + +- Go 1.26.2 +- Kubernetes 0.35.x (client-go, api, apimachinery) +- controller-runtime 0.23.3 +- Patroni (for PostgreSQL HA) +- pgBackRest (for backups) +- Uses Consul for distributed configuration +- Google Cloud APIs for cloud provider integration +- operator-framework/operator-lib for leader election + +## Common Gotchas + +- The operator uses **leader election** via operator-lib (lock name depends on OPERATOR_ROLE) +- Grafana dashboards must be gzipped before deployment +- PatroniCore must be fully running (leader elected) before installing PatroniServices +- Storage configuration is critical - supports both PV provisioners and manual PV assignment +- TLS can be enabled on operator server (port 8443 vs 8080) + +## Commit Message Pattern + +All commits in this project MUST follow this format: + +``` +: [] +``` + +Where: +- `` = fix, chore, feat, chore(deps), etc. +- `` = REQUIRED - Always ask the user for the ticket number before creating any commit +- `` = Clear, concise description of the change + +**Example:** +``` +feat: [CPCAP-1234] add backup retention policy configuration +fix: [CPCAP-5678] resolve memory leak in monitoring agent +chore(deps): [CPCAP-9012] bump kubernetes dependencies to v0.35.1 +``` + +**Important:** Never create a commit without first asking the user for the ticket number. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..f5d76674 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,3 @@ +# CLAUDE.md + +@AGENTS.md \ No newline at end of file diff --git a/README.md b/README.md index f23b9a3c..d74c319a 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,439 @@ # pgskipper-operator -Postgres-Operator provides PostgreSQL as a service on Kubernetes and OpenShift. +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) +[![Go Version](https://img.shields.io/badge/Go-1.26.2-00ADD8?logo=go)](https://go.dev/) +[![Kubernetes](https://img.shields.io/badge/Kubernetes-0.35.x-326CE5?logo=kubernetes)](https://kubernetes.io/) -## Repository structure +A Kubernetes operator that provides **PostgreSQL as a service** on Kubernetes and OpenShift platforms, featuring high availability through Patroni, automated backups with pgBackRest, and comprehensive monitoring capabilities. -* `./charts` - directory with HELM chart for Postgres components. -* * `./charts/patroni-core` - directory with HELM chart for Patroni Core. -* * `./charts/patroni-services` - directory with HELM chart for Postgres Services. -* `./pkg` - directory with operator source code, which is used for running Postgres Operator. -* `./tests` - directory with robot test source code, `Dockerfile`. +## Table of Contents -## How to start +- [Overview](#overview) +- [Features](#features) +- [Architecture](#architecture) +- [Prerequisites](#prerequisites) +- [Installation](#installation) +- [Configuration](#configuration) +- [Usage](#usage) +- [Documentation](#documentation) +- [Development](#development) +- [Testing](#testing) +- [Contributing](#contributing) +- [License](#license) +- [Support](#support) -Please refer to the [Quick Start Guide](/docs/public/quickstart.md) +## Overview -### Smoke tests +pgskipper-operator manages PostgreSQL clusters on Kubernetes with production-grade features including: -There is no smoke tests. +- **High Availability**: Automated failover and leader election using Patroni +- **Automated Backups**: pgBackRest integration for reliable backup and restore +- **Disaster Recovery**: Multi-site DR capabilities with active-standby clusters +- **Monitoring & Observability**: Built-in Prometheus exporters and Grafana dashboards +- **Connection Pooling**: Integrated PGBouncer for efficient connection management +- **Security**: TLS/SSL support, LDAP integration, and CIS hardening +- **Version Management**: Automated major version upgrades -### How to troubleshoot +## Features -There are no well-defined rules for troubleshooting, as each task is unique, but most frequent issues related to the wrong configuration, so please check: +### Core Capabilities -* Deploy parameters. -* Logs from all Postgres Service pods: operator, postgres db and others. +- **Patroni-based HA Cluster**: Automatic failover and leader election +- **pgBackRest Backups**: Full, incremental, and differential backups with S3/Azure/GCS support +- **Connection Pooler**: PGBouncer integration for connection management +- **Query Exporter**: Custom Prometheus metrics from SQL queries +- **TLS Configuration**: Secure connections with certificate management via cert-manager +- **Major Version Upgrades**: Automated PostgreSQL major version upgrades +- **Logical Replication**: Built-in logical replication controller +- **Disaster Recovery**: Active-standby cluster configuration across multiple sites +- **LDAP Integration**: Enterprise authentication support +- **Toleration Policies**: Advanced pod scheduling controls +- **CIS Hardening**: Security baseline compliance -## Useful links +See the [features documentation](docs/public/features/) for detailed information on each capability. -* [Installation Guide](/docs/public/installation.md) -* [Features](/docs/public/features) +## Architecture + +The operator consists of two main components: + +### 1. Patroni Core Operator +Manages the `PatroniCore` custom resource, responsible for: +- PostgreSQL cluster deployment with Patroni +- High availability and failover management +- Storage provisioning and management + +### 2. Patroni Services Operator +Manages the `PatroniServices` custom resource, providing: +- Backup daemon (pgBackRest integration) +- Monitoring agent and metrics exporters +- DBaaS adapter +- Replication controller +- Connection pooler (PGBouncer) +- Query exporter + +Both operators are packaged as separate Helm charts and can be deployed independently, with PatroniCore required before PatroniServices. + +## Prerequisites + +### Required Tools +- [kubectl](https://kubernetes.io/docs/tasks/tools/) - Kubernetes CLI +- [helm](https://helm.sh/docs/intro/install/) - Helm 3.x or later +- [git](https://git-scm.com/downloads) - For cloning the repository + +### Kubernetes Requirements +- Kubernetes 1.25+ or OpenShift 4.x+ +- Cluster admin rights for CRD installation +- Storage provisioner (or manually created PersistentVolumes) +- Minimum resources: 4 CPU cores, 8GB RAM + +### Optional Requirements +- **cert-manager**: For automatic TLS certificate management +- **Prometheus Operator**: For monitoring stack integration +- **Cloud Provider**: For cloud-native storage (AWS EBS, Azure Disk, GCP PD) + +See the [installation guide](docs/public/installation.md) for platform-specific requirements (AWS, Azure, GCP). + +## Installation + +### Step 1: Clone the Repository + +```bash +git clone https://github.com/Netcracker/pgskipper-operator.git +cd pgskipper-operator +``` + +### Step 2: Configure Storage + +Before installation, configure storage in your Helm values files (`operator/charts/patroni-core/patroni-core-quickstart-sample.yaml` and `operator/charts/patroni-services/patroni-services-quickstart-sample.yaml`). + +**Option A: With a storage provisioner (recommended)** +```yaml +patroni: + storage: + type: provisioned # Options: provisioned, pv + size: 20Gi + storageClass: fast-ssd + +backupDaemon: + storage: + type: provisioned # Options: provisioned, pv, ephemeral + size: 50Gi + storageClass: fast-ssd +``` + +**Storage Types:** +- `provisioned`: Uses dynamic volume provisioning with specified storageClass +- `pv`: Uses manually created PersistentVolumes +- `ephemeral`: Uses ephemeral storage (backupDaemon only, not recommended for production) + +**Option B: Without a provisioner (manual PVs)** +```yaml +patroni: + storage: + type: pv + size: 20Gi + volumes: + - postgres-pv-0 + - postgres-pv-1 + nodes: + - worker-node-1 + - worker-node-2 + +backupDaemon: + storage: + type: pv + size: 50Gi + volumes: + - backup-pv-0 + nodes: + - worker-node-1 +``` + +### Step 3: Install Custom Resource Definitions + +```bash +kubectl create -f ./operator/charts/patroni-core/crds/netcracker.com_patronicores.yaml +kubectl create -f ./operator/charts/patroni-services/crds/netcracker.com_patroniservices.yaml +``` + +### Step 4: Install Patroni Core Operator + +```bash +helm install --namespace=postgres --create-namespace \ + -f ./operator/charts/patroni-core/patroni-core-quickstart-sample.yaml \ + patroni-core ./operator/charts/patroni-core +``` + +**Verify installation:** +```bash +# Check operator pod +kubectl logs -n postgres "$(kubectl get pod -n postgres -l name=patroni-core-operator --output='name')" + +# Check Patroni pods are running +kubectl -n postgres get pods --selector=app=patroni --field-selector=status.phase=Running +``` + +### Step 5: Wait for Leader Election + +Before installing Patroni Services, ensure a PostgreSQL leader has been elected: + +```bash +# Wait for master pod to be ready +kubectl -n postgres get pods --selector=pgtype=master --field-selector=status.phase=Running + +# Verify cluster status +kubectl -n postgres get patronicore patroni-core -o jsonpath='{.status.conditions[?(@.type=="Successful")]}' +``` + +### Step 6: Install Patroni Services Operator + +Once the leader is elected, install the services operator: + +```bash +helm install --namespace=postgres \ + -f ./operator/charts/patroni-services/patroni-services-quickstart-sample.yaml \ + patroni-services ./operator/charts/patroni-services +``` + +**Verify installation:** +```bash +# Check operator pod +kubectl logs -n postgres "$(kubectl get pod -n postgres -l name=postgres-operator --output='name')" + +# Check all services are running +kubectl -n postgres get pods + +# Verify services status +kubectl -n postgres get patroniservices patroni-services -o jsonpath='{.status.conditions[?(@.type=="Successful")]}' +``` + +### Installation Complete + +Your PostgreSQL cluster is now ready! See the [Usage](#usage) section for connecting to the database. + +For advanced installation scenarios (AWS, Azure, GCP, disaster recovery), see the [full installation guide](docs/public/installation.md). + +## Configuration + +### Common Configuration Parameters + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `patroni.replicas` | Number of PostgreSQL replicas | `2` | +| `patroni.storage.size` | PV size per replica | `5Gi` | +| `backupDaemon.install` | Enable backup daemon | `true` | +| `backupDaemon.schedule` | Backup schedule (cron) | `0 0/7 * * *` | +| `metricCollector.install` | Enable monitoring stack | `true` | +| `tls.enabled` | Enable TLS/SSL | `false` | + +See Helm chart values files for comprehensive configuration options: +- [patroni-core values](operator/charts/patroni-core/values.yaml) +- [patroni-services values](operator/charts/patroni-services/values.yaml) + +## Usage + +### Connecting to PostgreSQL + +```bash +# Port forward to the master pod +PG_MASTER_POD=$(kubectl get pod -n postgres -o name -l app=patroni,pgtype=master) +kubectl -n postgres port-forward "${PG_MASTER_POD}" 5432:5432 + +# Get credentials +PGUSER=$(kubectl get secrets -n postgres postgres-credentials -o go-template='{{.data.username | base64decode}}') +PGPASSWORD=$(kubectl get secrets -n postgres postgres-credentials -o go-template='{{.data.password | base64decode}}') + +# Connect with psql +psql -h localhost -U $PGUSER +``` + +### Monitoring Cluster Status + +```bash +# Check cluster health +kubectl -n postgres get patronicore patroni-core -o jsonpath='{.status.conditions[?(@.type=="Successful")]}' + +kubectl -n postgres get patroniservices patroni-services -o jsonpath='{.status.conditions[?(@.type=="Successful")]}' + +# View all pods +kubectl -n postgres get pods -l app=patroni + +# Check master/replica status +kubectl -n postgres get pods -l pgtype=master +kubectl -n postgres get pods -l pgtype=replica +``` + +### Backup and Restore + +Backups are automated via the backup daemon on a schedule. For manual operations, use the backup daemon REST API: + +```bash +# Get backup daemon credentials +BACKUP_USER=$(kubectl get secret -n postgres postgres-credentials -o go-template='{{.data.username | base64decode}}') +BACKUP_PASS=$(kubectl get secret -n postgres postgres-credentials -o go-template='{{.data.password | base64decode}}') + +# Port forward to backup daemon +kubectl -n postgres port-forward svc/backup-daemon 8080:8080 & + +# Trigger manual backup +curl -X POST http://localhost:8080/backup -u "$BACKUP_USER:$BACKUP_PASS" +# or +curl -X POST http://localhost:8080/backups/request -u "$BACKUP_USER:$BACKUP_PASS" + +# Check backup status +curl -X GET http://localhost:8080/status -u "$BACKUP_USER:$BACKUP_PASS" + +# Check health and backup progress +curl -X GET http://localhost:8080/health -u "$BACKUP_USER:$BACKUP_PASS" + +# Restore from external backup (for disaster recovery) +curl -X POST http://localhost:8080/external/restore -u "$BACKUP_USER:$BACKUP_PASS" \ + -H "Content-Type: application/json" \ + -d '{"backupId": "backup-timestamp", "dbType": "AZURE"}' +``` + +For detailed backup configuration and pgBackRest features, see the [pgBackRest documentation](docs/public/features/pgBackRest.md). + +## Documentation + +- [Quick Start Guide](docs/public/quickstart.md) - Get started in minutes +- [Installation Guide](docs/public/installation.md) - Comprehensive installation instructions +- [Features Documentation](docs/public/features/) - Detailed feature guides + - [Active-Standby Clusters](docs/public/features/active-standby-cluster.md) + - [Disaster Recovery](docs/public/features/disaster-recovery.md) + - [Major Version Upgrades](docs/public/features/major-upgrade.md) + - [pgBackRest Configuration](docs/public/features/pgBackRest.md) + - [Connection Pooler](docs/public/features/connection-pooler.md) + - [TLS Configuration](docs/public/features/tls-configuration.md) + - [Query Exporter](docs/public/features/query-exporter.md) + - [LDAP Integration](docs/public/features/ldap_integration.md) + - [Logical Replication](docs/public/features/logical-replication-controller.md) + - [CIS Hardening](docs/public/features/cis-hardening.md) + - [Toleration Policies](docs/public/features/toleration-policies.md) + +## Development + +### Prerequisites + +- Go 1.26.2 or later +- Docker or Podman +- Access to a Kubernetes cluster (for testing) + +### Building the Operator + +```bash +cd operator + +# Quick build (recommended for development) +# Handles deps, gzip-charts, move-charts, compile, and docker-build +make sandbox-build + +# Local development with formatting, linting, and push +TAG_ENV=dev DOCKER_NAMES="your-registry/pgskipper-operator:dev" make local +``` + +**Individual commands** (if needed): +```bash +# Format code +make fmt + +# Run linters +make vet + +# Update dependencies +make deps + +# Compile binary only +make compile +``` + +### Building Services + +Each service has its own build process: + +```bash +cd services/ +make docker-build +``` + +### Generating CRDs + +After modifying API types: + +```bash +cd operator +make generate +``` + +This regenerates CRDs and DeepCopy methods from Go type definitions. + +### Project Structure + +``` +. +├── operator/ # Main operator code +│ ├── api/ # CRD API definitions +│ ├── cmd/ # Operator entry point +│ ├── controllers/ # Reconciliation controllers +│ ├── pkg/ # Core business logic +│ └── charts/ # Helm charts +├── services/ # Supporting microservices +│ ├── backup-daemon/ +│ ├── monitoring-agent/ +│ ├── query-exporter/ +│ └── ... +├── tests/ # Robot Framework tests +└── docs/ # Documentation + +``` + +## Testing + +### Robot Framework Tests + +```bash +cd tests +# Run specific test suite +robot robot//.robot +``` + +### Unit Tests (Services) + +```bash +cd services/ +make test +``` + +## Contributing + +We welcome contributions! Please follow these steps: + +1. Read the [Code of Conduct](CODE-OF-CONDUCT.md) +2. Sign the [Contributor License Agreement](https://pages.netcracker.com/cla-main.html) +3. Fork the repository +4. Create a feature branch (`git checkout -b feature/amazing-feature`) +5. Commit your changes (`git commit -m 'Add amazing feature'`) +6. Push to the branch (`git push origin feature/amazing-feature`) +7. Open a Pull Request + +See [CONTRIBUTING.md](CONTRIBUTING.md) for more details. + +## License + +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. + +## Support + +### Reporting Issues + +If you encounter a bug or have a feature request: +1. Check [existing issues](https://github.com/Netcracker/pgskipper-operator/issues) +2. Create a new issue with detailed information + +### Security Vulnerabilities + +For security concerns, please review our [Security Policy](SECURITY.md) and report vulnerabilities responsibly. + +### Community + +- **Issues**: [GitHub Issues](https://github.com/Netcracker/pgskipper-operator/issues) diff --git a/docs/public/quickstart.md b/docs/public/quickstart.md index 8564ff11..280914cc 100644 --- a/docs/public/quickstart.md +++ b/docs/public/quickstart.md @@ -24,13 +24,13 @@ Clone the repository and change to the directory git clone git@github.com:Netcracker/pgskipper-operator.git cd postgres-operator ``` -Note that in `charts` folder you can fide two separate `Helm Charts` named `patroni-core` and `patroni-services` +Note that in `operator/charts` folder you can fide two separate `Helm Charts` named `patroni-core` and `patroni-services` So for each of `Helm Chart` you can find the sample.yaml Information of the services separation you can find in [Architecture Guide](/docs/public/architecture.md#postgres-operator) ## Storage configuration -Before install, configure `patroni.storage` in charts/patroni-core/patroni-core-quickstart-sample.yaml and `backupDaemon.storage` properties in charts/patroni-services/patroni-services-quickstart-sample.yaml +Before install, configure `patroni.storage` in ./operator/charts/patroni-core/patroni-core-quickstart-sample.yaml and `backupDaemon.storage` properties in ./operator/charts/patroni-services/patroni-services-quickstart-sample.yaml according to your PV configuration. 1. If you have a PV provisioner, set up your storage sections as follows: @@ -64,16 +64,16 @@ When setup is complete, we can proceed to install the postgres operator. Manually install CRD for Patroni-Core: ``` -kubectl create -f ./charts/patroni-core/crds/netcracker.com_patronicores.yaml +kubectl create -f ./operator/charts/patroni-core/crds/netcracker.com_patronicores.yaml ``` Manually install CRD for Postgres-Services ``` -kubectl create -f ./charts/patroni-services/crds/netcracker.com_patroniservices.yaml +kubectl create -f ./operator/charts/patroni-services/crds/netcracker.com_patroniservices.yaml ``` Install Patroni-Core Operator via Helm by following command: ``` -helm install --namespace=postgres --create-namespace -f ./charts/patroni-core/patroni-core-quickstart-sample.yaml patroni-core ./charts/patroni-core +helm install --namespace=postgres --create-namespace -f ./operator/charts/patroni-core/patroni-core-quickstart-sample.yaml patroni-core ./operator/charts/patroni-core ``` This will create all necessary resources and run the Patroni-Core Operator Pod. @@ -99,7 +99,7 @@ kubectl logs -n postgres "$(kubectl get pod -n postgres -l name=patroni-core-ope After leader has been promoted, you may install Patroni-Services Operator via Helm by following command: ``` -helm install --namespace=postgres -f ./charts/patroni-services/patroni-services-quickstart-sample.yaml patroni-services ./charts/patroni-services +helm install --namespace=postgres -f ./operator/charts/patroni-services/patroni-services-quickstart-sample.yaml patroni-services ./operator/charts/patroni-services ``` This will create all necessary resources and run the Postgres-Operator Pod. diff --git a/services/backup-daemon/Makefile b/services/backup-daemon/Makefile new file mode 100644 index 00000000..b18f76ad --- /dev/null +++ b/services/backup-daemon/Makefile @@ -0,0 +1,40 @@ +DOCKER_FILE := Dockerfile + +ifndef TAG_ENV +override TAG_ENV = local +endif + +ifndef DOCKER_NAMES +override DOCKER_NAMES = ghcr.io/netcracker/pgskipper-docker-backup-daemon:${TAG_ENV} +endif + +sandbox-build: docker-build + +all: sandbox-build docker-push + +local: docker-build docker-push + +docker-build: + $(foreach docker_tag,$(DOCKER_NAMES),docker build --file="${DOCKER_FILE}" --pull -t $(docker_tag) ./;) + +docker-push: + $(foreach docker_tag,$(DOCKER_NAMES),docker push $(docker_tag);) + +clean: + rm -rf go/build/_output + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true + find . -type f -name "*.pyc" -delete 2>/dev/null || true + +# Go module in go/ subdirectory +go-deps: + cd go && go mod tidy && GO111MODULE=on + +go-fmt: + cd go && gofmt -l -s -w . + +go-compile: + cd go && CGO_ENABLED=0 go build -o ./build/_output/bin/pgskipper-backup-daemon-azure \ + -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} ./cmd/pgskipper-backup-daemon-azure + +go-test: + cd go && go test -v ./... diff --git a/services/monitoring-agent/Makefile b/services/monitoring-agent/Makefile new file mode 100644 index 00000000..54354176 --- /dev/null +++ b/services/monitoring-agent/Makefile @@ -0,0 +1,38 @@ +DOCKER_FILE := Dockerfile + +ifndef TAG_ENV +override TAG_ENV = local +endif + +ifndef DOCKER_NAMES +override DOCKER_NAMES = ghcr.io/netcracker/pgskipper-docker-monitoring-agent:${TAG_ENV} +endif + +sandbox-build: deps compile docker-build + +all: sandbox-build docker-push + +local: fmt deps compile docker-build docker-push + +deps: + go mod tidy + GO111MODULE=on + +fmt: + gofmt -l -s -w . + +compile: + cd collector && CGO_ENABLED=0 go build -o ../build/_output/bin/pgskipper-monitoring-agent \ + -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} . + +docker-build: + $(foreach docker_tag,$(DOCKER_NAMES),docker build --file="${DOCKER_FILE}" --pull -t $(docker_tag) ./;) + +docker-push: + $(foreach docker_tag,$(DOCKER_NAMES),docker push $(docker_tag);) + +clean: + rm -rf build/_output + +test: + go test -v ./... diff --git a/services/patroni/Makefile b/services/patroni/Makefile new file mode 100644 index 00000000..3f551613 --- /dev/null +++ b/services/patroni/Makefile @@ -0,0 +1,26 @@ +DOCKER_FILE := Dockerfile + +ifndef TAG_ENV +override TAG_ENV = local +endif + +ifndef DOCKER_NAMES +override DOCKER_NAMES = ghcr.io/netcracker/pgskipper-docker-patroni:${TAG_ENV} +endif + +sandbox-build: docker-build + +all: sandbox-build docker-push + +local: docker-build docker-push + +docker-build: + $(foreach docker_tag,$(DOCKER_NAMES),docker build --file="${DOCKER_FILE}" --pull -t $(docker_tag) ./;) + +docker-push: + $(foreach docker_tag,$(DOCKER_NAMES),docker push $(docker_tag);) + +clean: + rm -rf build/_output + find . -type f -name "*.pyc" -delete 2>/dev/null || true + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true diff --git a/services/query-exporter/Makefile b/services/query-exporter/Makefile index c36794de..51dcd553 100644 --- a/services/query-exporter/Makefile +++ b/services/query-exporter/Makefile @@ -5,7 +5,7 @@ override TAG_ENV = local endif ifndef DOCKER_NAMES -override DOCKER_NAMES = "ghcr.io/netcracker/qubership-query-exporter:${TAG_ENV}" +override DOCKER_NAMES = "ghcr.io/netcracker/qubership-docker-query-exporter:${TAG_ENV}" endif sandbox-build: deps docker-build diff --git a/services/upgrade/Makefile b/services/upgrade/Makefile new file mode 100644 index 00000000..71255de3 --- /dev/null +++ b/services/upgrade/Makefile @@ -0,0 +1,26 @@ +DOCKER_FILE := Dockerfile + +ifndef TAG_ENV +override TAG_ENV = local +endif + +ifndef DOCKER_NAMES +override DOCKER_NAMES = ghcr.io/netcracker/pgskipper-docker-upgrade:${TAG_ENV} +endif + +sandbox-build: docker-build + +all: sandbox-build docker-push + +local: docker-build docker-push + +docker-build: + $(foreach docker_tag,$(DOCKER_NAMES),docker build --file="${DOCKER_FILE}" --pull -t $(docker_tag) ./;) + +docker-push: + $(foreach docker_tag,$(DOCKER_NAMES),docker push $(docker_tag);) + +clean: + rm -rf build/_output + find . -type f -name "*.pyc" -delete 2>/dev/null || true + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true