- How do I install and use this package in a Laravel project?
- Run `composer require dealroadshow/k8s-resources` to install. Define resources as PHP classes (e.g., `Deployment`, `Service`) extending the package’s base classes, then use `symfony/yaml` to serialize them to YAML. Example: `$yaml = Yaml::dump($deployment->toArray());`
- Does this package support Kubernetes CRDs (Custom Resource Definitions)?
- No, this package focuses on standard Kubernetes resources (Deployments, Services, Ingress, etc.). For CRDs, you’d need to extend the base classes manually or pair it with a tool like `kubectl` or `kubernetes-client-php` for dynamic CRD handling.
- Can I use this to dynamically generate Helm-like templates in PHP?
- Yes, the package lets you define reusable resource classes with configurable parameters (e.g., replicas, labels). Combine it with Laravel’s Blade or Twig for templating to create Helm-like workflows without Go templates.
- What Laravel versions are supported, and is PHP 8.1+ required?
- The package requires PHP 8.1+ and works with Laravel 9/10. It doesn’t enforce Laravel-specific dependencies, so it’s compatible with any PHP 8.1+ project, including non-Laravel PHP apps needing Kubernetes resource definitions.
- How do I validate Kubernetes resources before deploying them?
- Use the package’s built-in validation methods (e.g., `isValid()`) or extend the resource classes with custom logic. For stricter checks, integrate with tools like `kubeval` via CLI or write PHPUnit tests to mock and validate resources.
- Is there a way to apply these resources directly to a Kubernetes cluster?
- No, this package generates YAML manifests only. To apply them, use `kubectl apply -f manifest.yaml` or integrate with `kubernetes-client-php` for direct API calls. For Laravel, you could wrap these in an Artisan command or service.
- How does this compare to `kubernetes-client-php` for managing Kubernetes?
- `kubernetes-client-php` is a full SDK for interacting with the Kubernetes API (e.g., listing pods, applying resources). This package is lighter—it defines resources in PHP and generates YAML, leaving API calls to you. Use both for a hybrid approach: define resources here, apply them via the client.
- Can I use this package in CI/CD pipelines to generate Kubernetes manifests?
- Absolutely. Define resources in PHP, generate YAML in your pipeline, and use the output with `kubectl` or Helm. For example, trigger manifest generation via a Laravel command or CLI script in GitHub Actions/GitLab CI.
- Are there performance concerns with generating large Kubernetes manifests?
- For small-to-medium manifests, performance is negligible. For large clusters, optimize by generating resources incrementally or caching YAML output. Avoid loading entire clusters into memory—stream YAML generation or use batch processing.
- How do I handle secrets or sensitive data in resource definitions?
- Store sensitive data (e.g., passwords, tokens) in Laravel’s `.env` or a secrets manager, then inject them into resource classes via dependency injection. Never hardcode secrets in YAML or PHP files—use environment variables or encrypted storage.