46 lines
1.5 KiB
Plaintext
46 lines
1.5 KiB
Plaintext
//! PostgreSQL Cluster Deployment Example (Rhai)
|
|
//!
|
|
//! This script shows how to deploy a PostgreSQL cluster using Rhai scripting
|
|
//! with the KubernetesManager convenience methods.
|
|
|
|
print("=== PostgreSQL Cluster Deployment ===");
|
|
|
|
// Create Kubernetes manager for the database namespace
|
|
print("Creating Kubernetes manager for 'database' namespace...");
|
|
let km = kubernetes_manager_new("database");
|
|
print("✓ Kubernetes manager created");
|
|
|
|
// Create PostgreSQL cluster using the convenience method
|
|
print("\nDeploying PostgreSQL cluster...");
|
|
|
|
try {
|
|
// Deploy PostgreSQL using the convenience method
|
|
let result = deploy_application(km, "postgres-cluster", "postgres:15", 2, 5432, #{
|
|
"app": "postgres-cluster",
|
|
"type": "database",
|
|
"engine": "postgresql"
|
|
});
|
|
print("✓ " + result);
|
|
|
|
print("\n✅ PostgreSQL cluster deployed successfully!");
|
|
|
|
print("\n📋 Connection Information:");
|
|
print(" Host: postgres-cluster.database.svc.cluster.local");
|
|
print(" Port: 5432");
|
|
print(" Database: postgres (default)");
|
|
print(" Username: postgres (default)");
|
|
|
|
print("\n🔧 To connect from another pod:");
|
|
print(" psql -h postgres-cluster.database.svc.cluster.local -U postgres");
|
|
|
|
print("\n💡 Next steps:");
|
|
print(" • Set POSTGRES_PASSWORD environment variable");
|
|
print(" • Configure persistent storage");
|
|
print(" • Set up backup and monitoring");
|
|
|
|
} catch(e) {
|
|
print("❌ Failed to deploy PostgreSQL cluster: " + e);
|
|
}
|
|
|
|
print("\n=== Deployment Complete ===");
|