ProxShift

OpenShift clusters on Proxmox made simple


Project maintained by randyoyarzabal Hosted on GitHub Pages — Theme by mattgraham

ProxShift Certificate Backup & Restore Guide

Overview

ProxShift provides automated certificate backup and restore functionality for OpenShift clusters, specifically designed for the ocp-sno1 ACM hub cluster which hosts critical certificate secrets.

Key Architecture

Backup Operations (Standalone)

Restore Operations (Post-Install)

πŸ” Certificate Backup & Restore Features

Reusable Authentication

Configurable Operations

Quick Usage

Backup Certificate Secrets (From Existing Cluster)

# Load ProxShift functions
source proxshift.sh

# Backup certificates from EXISTING ocp-sno1 (dry-run)
ps.backup_certs --dry-run

# Backup certificates from EXISTING ocp-sno1 (actual operation)  
ps.backup_certs

⚠ Important: The cluster ocp-sno1 must be running and accessible!

Restore Certificate Secrets (To Rebuilt Cluster)

# Restore certificates to REBUILT ocp-sno1 (dry-run)
ps.restore_certs --dry-run

# Restore certificates to REBUILT ocp-sno1 (actual operation)
ps.restore_certs

⚠ Important: Use this ONLY when rebuilding the ACM hub cluster!

Configuration

Default Certificate Secrets (defined in config/site-config.yaml)

backup_secrets:
  - name: secret-homelab-ca-tls
    namespace: cert-manager
  - name: secret-homelab-io-tls
    namespace: homelab

backup_dir: "/backups"

Feature Flags (in site.yaml)

backup_operation: false      # Set to true to backup certificate secrets
restore_operation: false     # Set to true to restore certificate secrets
backup_verbose: false        # Enable verbose output for backup/restore operations
enable_backup_restore: true  # Enable certificate backup/restore functionality

Manual Ansible Usage

Backup Only (Standalone Operation)

ansible-playbook site.yaml \
  -e cluster_name=ocp-sno1 \
  -e backup_operation=true \
  --tags=cert_backup

Note: Uses cert_backup tag - does NOT run any post-install tasks!

Restore Only (During Cluster Rebuild)

ansible-playbook site.yaml \
  -e cluster_name=ocp-sno1 \
  -e restore_operation=true \
  --tags=cert_restore

Note: Uses cert_restore tag - runs as part of post-install workflow!

Verbose Backup

ansible-playbook site.yaml \
  -e cluster_name=ocp-sno1 \
  -e backup_operation=true \
  -e backup_verbose=true \
  --tags=cert_backup

Advanced Configuration

Custom Backup Directory

ansible-playbook site.yaml \
  -e cluster_name=ocp-sno1 \
  -e backup_operation=true \
  -e backup_dir="/custom/backup/path" \
  --tags=backup

Custom Certificate Secrets

# Override in your inventory or command line
backup_secrets:
  - name: my-custom-cert
    namespace: my-namespace
  - name: another-cert
    namespace: cert-manager

πŸ“ Backup Structure

The backup directory structure follows this pattern:

/
β”œβ”€β”€ ocp-sno1/
β”‚   β”œβ”€β”€ cert-manager/
β”‚   β”‚   └── secret-homelab-ca-tls.yaml
β”‚   └── homelab/
β”‚       └── secret-homelab-io-tls.yaml
└── metadata/
    β”œβ”€β”€ backup-timestamp.txt
    └── cluster-info.yaml

Workflow Details

Backup Operation

  1. Authentication: Login to ocp-sno1 using cluster_login.yml
  2. Validation: Verify cluster connectivity and secret existence
  3. Export: Extract certificate secrets to YAML files
  4. Storage: Save to designated backup directory with timestamps
  5. Verification: Confirm backup files were created successfully

Restore Operation

  1. Authentication: Login to ocp-sno1 using cluster_login.yml
  2. Validation: Verify backup files exist and are readable
  3. Import: Apply certificate secrets from backup files
  4. Verification: Confirm secrets were restored successfully
  5. Status: Report restoration results

Integration with ProxShift

Role Integration

Authentication Integration

Tagging System

Target Clusters

Currently configured for:

Troubleshooting

Missing Required Arguments Error

missing required arguments: secret_management_backup_dir, secret_management_cluster, secret_management_secrets

Solution: This was fixed by updating variable names in site.yaml to match the role’s argument specifications.

Authentication Failed

βœ— Login failed for cluster: ocp-sno1

Solutions:

  1. Verify cluster is running and accessible
  2. Check vault credentials are correct
  3. Ensure cluster API URL is reachable

Backup Directory Not Found

Backup directory does not exist: /path/to/backup

Solutions:

  1. Verify backup_dir path exists and is writable
  2. Check gitops_root variable is correctly set
  3. Create backup directory manually if needed

Secret Not Found

Secret 'secret-name' not found in namespace 'namespace'

Solutions:

  1. Verify secret exists: oc get secrets -n namespace
  2. Check secret name spelling in configuration
  3. Ensure correct namespace is specified

πŸ“ˆ Best Practices

Regular Backups

Security Considerations

Monitoring

Future Enhancements

Multi-Cluster Support

Automated Scheduling

Enhanced Validation

This guide provides comprehensive coverage of ProxShift’s certificate backup and restore capabilities, ensuring reliable certificate management for your OpenShift infrastructure.