- Reorganized examples into osiris/, sal/, and utils/ folders - Moved hardcoded scripts to separate .rhai files - Added signature() method to JobBuilder for job signing - Updated OSIRIS context to use block_in_place instead of runtime - Removed runtime field from OsirisContext - Added typed save() methods for Note and Event objects - Updated all examples to use new structure and APIs
		
			
				
	
	
		
			73 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
//! Basic Kubernetes operations example
 | 
						|
//!
 | 
						|
//! This script demonstrates basic Kubernetes operations using the SAL Kubernetes module.
 | 
						|
//! 
 | 
						|
//! Prerequisites:
 | 
						|
//! - A running Kubernetes cluster
 | 
						|
//! - Valid kubeconfig file or in-cluster configuration
 | 
						|
//! - Appropriate permissions for the operations
 | 
						|
//!
 | 
						|
//! Usage:
 | 
						|
//!   herodo examples/kubernetes/basic_operations.rhai
 | 
						|
 | 
						|
print("=== SAL Kubernetes Basic Operations Example ===");
 | 
						|
 | 
						|
// Create a KubernetesManager for the default namespace
 | 
						|
print("Creating KubernetesManager for 'default' namespace...");
 | 
						|
let km = kubernetes_manager_new("default");
 | 
						|
print("✓ KubernetesManager created for namespace: " + namespace(km));
 | 
						|
 | 
						|
// List all pods in the namespace
 | 
						|
print("\n--- Listing Pods ---");
 | 
						|
let pods = pods_list(km);
 | 
						|
print("Found " + pods.len() + " pods in the namespace:");
 | 
						|
for pod in pods {
 | 
						|
    print("  - " + pod);
 | 
						|
}
 | 
						|
 | 
						|
// List all services in the namespace
 | 
						|
print("\n--- Listing Services ---");
 | 
						|
let services = services_list(km);
 | 
						|
print("Found " + services.len() + " services in the namespace:");
 | 
						|
for service in services {
 | 
						|
    print("  - " + service);
 | 
						|
}
 | 
						|
 | 
						|
// List all deployments in the namespace
 | 
						|
print("\n--- Listing Deployments ---");
 | 
						|
let deployments = deployments_list(km);
 | 
						|
print("Found " + deployments.len() + " deployments in the namespace:");
 | 
						|
for deployment in deployments {
 | 
						|
    print("  - " + deployment);
 | 
						|
}
 | 
						|
 | 
						|
// Get resource counts
 | 
						|
print("\n--- Resource Counts ---");
 | 
						|
let counts = resource_counts(km);
 | 
						|
print("Resource counts in namespace '" + namespace(km) + "':");
 | 
						|
for resource_type in counts.keys() {
 | 
						|
    print("  " + resource_type + ": " + counts[resource_type]);
 | 
						|
}
 | 
						|
 | 
						|
// List all namespaces (cluster-wide operation)
 | 
						|
print("\n--- Listing All Namespaces ---");
 | 
						|
let namespaces = namespaces_list(km);
 | 
						|
print("Found " + namespaces.len() + " namespaces in the cluster:");
 | 
						|
for ns in namespaces {
 | 
						|
    print("  - " + ns);
 | 
						|
}
 | 
						|
 | 
						|
// Check if specific namespaces exist
 | 
						|
print("\n--- Checking Namespace Existence ---");
 | 
						|
let test_namespaces = ["default", "kube-system", "non-existent-namespace"];
 | 
						|
for ns in test_namespaces {
 | 
						|
    let exists = namespace_exists(km, ns);
 | 
						|
    if exists {
 | 
						|
        print("✓ Namespace '" + ns + "' exists");
 | 
						|
    } else {
 | 
						|
        print("✗ Namespace '" + ns + "' does not exist");
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
print("\n=== Example completed successfully! ===");
 |