Package Data | |
---|---|
Maintainer Username: | rennokki |
Package Create Date: | 2020-04-29 |
Package Last Update: | 2024-06-10 |
Home Page: | |
Language: | PHP |
License: | Apache-2.0 |
Last Refreshed: | 2024-10-31 15:12:43 |
Package Statistics | |
---|---|
Total Downloads: | 427,715 |
Monthly Downloads: | 12,615 |
Daily Downloads: | 677 |
Total Stars: | 310 |
Total Watchers: | 8 |
Total Forks: | 59 |
Total Open Issues: | 20 |
Control your Kubernetes clusters with this PHP-based Kubernetes client. It supports any form of authentication, the exec API, and it has an easy implementation for CRDs.
For Laravel projects, you might want to use renoki-co/laravel-php-k8s which eases the access for this particular case.
Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.
If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.
You can install the package via composer:
composer require renoki-co/php-k8s
Having the following YAML configuration for a Service:
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: frontend
spec:
selector:
app: frontend
ports:
- protocol: TCP
port: 80
targetPort: 80
Can be written like this:
use RenokiCo\PhpK8s\KubernetesCluster;
// Create a new instance of KubernetesCluster.
$cluster = new KubernetesCluster('http://127.0.0.1:8080');
// Create a new NGINX service.
$svc = $cluster->service()
->setName('nginx')
->setNamespace('frontend')
->setSelectors(['app' => 'frontend'])
->setPorts([
['protocol' => 'TCP', 'port' => 80, 'targetPort' => 80],
])
->create();
To easily get started about how the resources are being handled, take a look at the Resources: Getting Started and Cluster Authentication guides, which provides a lot of examples on how to interact with the resources within the cluster.
Once you got started with how PHPK8s works, you can get specific methods, examples and tips for each resource that's implemented.
PHP K8s comes out-of-the-box with the following listed resources. For missing core Kubernetes CRDs, refer to the Planned Resources section and if you have custom resources (CRDs), you can implement them yourself.
| Resource | Default Version
| - | -
| ClusterRole | rbac.authorization.k8s.io/v1
| ClusterRoleBinding | rbac.authorization.k8s.io/v1
| ConfigMap | v1
| CronJob | batch/v1beta1
| DaemonSet | apps/v1
| Deployment | apps/v1
| Event | v1
| HorizontalPodAutoscaler | autoscaling/v2beta2
| Ingress | networking.k8s.io/v1
|
| Job | batch/v1
| Namespace | v1
| Node | v1
| PersistenVolume | v1
| PersistenVolumeClaim | v1
| Pod | v1
| PodDisruptionBudget | policy/v1beta1
| Role | rbac.authorization.k8s.io/v1
| RoleBinding | rbac.authorization.k8s.io/v1
| Secret | v1
| Service | v1
| ServiceAccount | v1
| StatefulSet | apps/v1
| StorageClass | storage.k8s.io/v1
PHP K8s supports any kind of HTTP cluster authentication, from Bearer Tokens to In-Cluster configuration for Pods. The extensive documentation on authentication & security can be found here.
Since the package supports multiple K8s Cluster versions, some versions do promote certain resources to GA. Since each resource needs a default version, the package will set the default versions for the oldest Kubernetes version supported.
For example, if the package supports v1.18+
, then the package will make sure the versions are defaults for v1.18
. In some cases, like Ingress in v1.19
that switched from Beta to GA, the v1beta1
is no longer a default and instead, the v1
is now a default. If v1.17
is the oldest supported version, then it will stay to v1beta
.
The minimum Kubernetes version that is supported by a given package version can be found at the top of this file. Maintainers try as hard as possible to update the Kubernetes versions that are put into test to the latest patch as often as possible.
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.