Skip to content

Installation

Prerequisites

Dealroadshow K8S Framework requires PHP version 8.1 or higher.

Although Dealroadshow K8S Framework is released as a standalone package and can be used with a PHP framework of your preference or without any of them, it is highly recommended to use it with Symfony Framework by installing Dealroadshow K8S Bundle, since it allows you to write your Kubernetes manifests using Dependency Injection and all the cool Symfony features, such as autowiring and autoconfiguration. In fact, integration with Symfony is one of killer-features of this project and one of the reasons it was created.

Further documentation assumes you use Dealroadshow K8S Framework as a Symfony bundle.

Install Kubernetes API classes

First, you should look, what Kubernetes version your cluster has. This is needed so that K8S Framework can generate Kubernetes manifests in format, compatible with your Kubernetes cluster. Suppose you're using Kubernetes v1.22. You should install Kubernetes API classes for PHP by installing dealroadshow/k8s-resources package:

composer require dealroadshow/k8s-resources "~1.22.0"

Versions of dealroadshow/k8s-resources package follow Kubernetes versions in terms of it's minor versions, so just use the version of your cluster for this package.

Attention

Do not use caret operator ^ in version number for dealroadshow/k8s-resources package, because Composer will install latest minor version of this package. Suppose you're using Kubernetes v1.21 and you're trying to install corresponding version of API classes using version constraint ^1.21. This will end up by latest API classes version being installed (for example, v1.23). This is totally not what you want, so use tilde operator ~ instead and specify patch part of version (~1.22.0, not ~1.22).

Will I always have needed version of this package?

Don't worry that some day there will be no classes for your Kubernetes version or they will not match needed format - this PHP classes are autogenerated from Kubernetes API specs using a tool that was created specifically for that - Dealroadshow Kodegen. This ensures you'll always have your API classes up to date and compatible with your cluster.

Install K8S bundle for Symfony

It's your choice whether to create a separate Symfony project for your Kubernetes manifests generation or to install this bundle into you existing Symfony project (if you do have one). But separate project would probably ease managing and updates to Symfony Framework itself and any other packages. After you installed Kubernetes API classes by installing dealroadshow/k8s-resources, just install the latest version of Dealroadshow K8S Bundle via Composer:

composer require dealroadshow/k8s-bundle

That's pretty it! Now you can dive into writing your own manifests.