Creating Deployments
Deployments are where your application is defined including scaling and resource limits.
You are browsing the latest version for the release v0.0.3.
Deployments are defined by using the class Larakube\Cluster\Deployment.
You define your deployments in the kube/services.php
file.
The below example creates a deployment for our Laravel application.
Container
Set Dockerfile
To tell your service that it needs to build from a Dockerfile you can use the method below:
This method takes one argument which is the relative path to the service directory of where the Dockerfile is located.
Example
If your Laravel application service is located at kube/services/laravel
and your Dockerfile is located at kube/services/laravel/docker/Dockerfile
then you only need to pass the value docker/Dockerfile
to the method.
Set Container Image
You can specify an image and tag for deployment pods to pull from.
Environment
Set Namespace
You may want to explicitly set the namespace for your service in Kubernetes, you can achieve this with the following method.
The default namespace is "default".
Environment Variables
You can easily set environment variables for your deployments, they can be hard coded values or come from the current environment, for example when you are deploying from a CI provider.
Take a look at the EnvironmentVariable
class for method reference.
Scaling
Set number of Replicas
You can set the number of replicas a deployment should have by using the method below.
The default number of replicas is 1.
Networking
Set Container Port
The container port should be the same port you expose in your Dockerfile and/or the port your application listens on for traffic.
If you wish to change the port you can use the method below.
The default container port is 80.
Last updated