Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 28 | All time: 11,158 This week: 455 |
Version | License | PHP version | Categories | |||
kubernetes-resource- 1.0 | MIT/X Consortium ... | 8.1 | PHP 5, Tools, Systems administration, C... |
Description | Author | |||||||||||||||||||||||
This package can generate a configuration for a Kubernetes resource. Innovation Award |
|
a PHP package to generate yaml files of Kubernetes resources.
use Acamposm\K8sResourceGenerator\Reference\Annotations\PodAnnotations;
use Acamposm\K8sResourceGenerator\Reference\Labels\PodLabels;
use Acamposm\K8sResourceGenerator\Enums\ImagePullPolicy;
use Acamposm\K8sResourceGenerator\Enums\OperatingSystem;
use Acamposm\K8sResourceGenerator\Enums\RestartPolicy;
use Acamposm\K8sResourceGenerator\Resources\Container;
use Acamposm\K8sResourceGenerator\Resources\Pod;
// Set well known kubernetes annotations
$podAnnotations = array_merge(
PodAnnotations::deletionCost(500),
PodAnnotations::defaultContainer('my-app-container'),
);
// Set common used kubernetes labels
$podLabels = array_merge(
PodLabels::component('database'),
PodLabels::instance('my-awesome-application-xyz'),
PodLabels::managedBy('Kustomize'),
PodLabels::name('my-awesome-application'),
PodLabels::partOf('my-awesome-application'),
PodLabels::version('1.0.0'),
);
// Now set a container for the pod
$container = new Container();
$container->name('app-name')
->addEnvVariable('DEBUG', '*')
->addPorts([
[
'containerPort' => 4000,
'name' => 'http-alt',
'protocol' => 'TCP'
]
])
->image('alpine:latest')
->imagePullPolicy(ImagePullPolicy::ALWAYS)
->setCpuRequest('100m')
->setCpuLimit(1)
->setMemoryLimit('120Mi')
->setMemoryRequest('1Gi');
// Finally fill the Pod values
$pod = new Pod();
$pod->name('pod-name')
->namespace('my-awesome-project')
->addAnnotation('imageregistry', 'https://hub.docker.com/')
->addLabels($podLabels)
->addContainers([$container->toArray()])
->addImagePullSecret('registry-access-secret')
->addNodeSelectors([
'type' => 'compute',
'diskType' => 'ssd'
])
->osName(OperatingSystem::LINUX)
->restartPolicy(RestartPolicy::NEVER)
->serviceAccount('pod-service-account')
->toYaml();
Use toYaml() method to generate a YAML representation of the Kubernetes resource.
apiVersion: v1
kind: Pod
metadata:
name: pod-name
namespace: my-awesome-project
annotations:
controller.kubernetes.io/pod-deletion-cost: 500
imageregistry: 'https://hub.docker.com/'
kubectl.kubernetes.io/default-container: my-app-container
labels:
app.kubernetes.io/component: database
app.kubernetes.io/instance: my-awesome-application-xyz
app.kubernetes.io/managed-by: Kustomize
app.kubernetes.io/name: my-awesome-application
app.kubernetes.io/part-of: my-awesome-application
app.kubernetes.io/version: 1.0.0
spec:
os:
name: linux
containers:
- env:
- name: DEBUG
value: '*'
image: 'alpine:latest'
imagePullPolicy: Always
name: app-name
ports:
- containerPort: 4000
name: http-alt
protocol: TCP
resources:
limits:
cpu: '1'
memory: '120Mi'
requests:
cpu: '100m'
memory: '1Gi'
imagePullSecrets:
- name: registry-access-secret
nodeSelector:
type: compute
diskType: ssd
restartPolicy: Never
serviceAccount: pod-service-account
Files (50) |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
docs (1 file) | ||||
src (5 files, 7 directories) | ||||
tests (3 directories) | ||||
.editorconfig | Data | Auxiliary data | ||
CODE_OF_CONDUCT.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation | ||
sonar-project.properties | Data | Auxiliary data |
Files (50) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Contracts (1 file) | ||||
Enums (3 files) | ||||
Exceptions (1 file) | ||||
Helpers (3 files) | ||||
Reference (2 directories) | ||||
Resources (10 files) | ||||
Traits (2 files) | ||||
K8sConfigurationResource.php | Class | Class source | ||
K8sNetworkResource.php | Class | Class source | ||
K8sResource.php | Class | Class source | ||
K8sStorageResource.php | Class | Class source | ||
K8sWorkloadResource.php | Class | Class source |
Files (50) | / | src | / | Enums |
File | Role | Description |
---|---|---|
ImagePullPolicy.php | Aux. | Auxiliary script |
OperatingSystem.php | Aux. | Auxiliary script |
RestartPolicy.php | Aux. | Auxiliary script |
Files (50) | / | src | / | Exceptions |
File | Role | Description |
---|---|---|
UnexpectedUnitSuffixException.php | Class | Class source |
Files (50) | / | src | / | Helpers |
File | Role | Description |
---|---|---|
KubernetesRecommendedLabels.php | Class | Class source |
ResourceUnit.php | Class | Class source |
Yaml.php | Class | Class source |
Files (50) | / | src | / | Reference | / | Annotations |
File | Role | Description |
---|---|---|
AllObjectAnnotations.php | Class | Class source |
PodAnnotations.php | Class | Class source |
ServiceAccountAnnotations.php | Class | Class source |
Files (50) | / | src | / | Reference | / | Labels |
File | Role | Description |
---|---|---|
AllObjectLabels.php | Class | Class source |
NodeLabels.php | Class | Class source |
PodLabels.php | Class | Class source |
Files (50) | / | src | / | Resources |
File | Role | Description |
---|---|---|
ConfigMap.php | Class | Class source |
Container.php | Class | Class source |
DaemonSet.php | Class | Class source |
Deployment.php | Class | Class source |
Ingress.php | Class | Class source |
Pod.php | Class | Class source |
ReplicaSet.php | Class | Class source |
Secret.php | Class | Class source |
Service.php | Class | Class source |
StatefulSet.php | Class | Class source |
Files (50) | / | src | / | Traits |
File | Role | Description |
---|---|---|
CanCheckProperties.php | Class | Class source |
Exportable.php | Class | Class source |
Files (50) | / | tests | / | Integration |
File | Role | Description |
---|---|---|
addContainersToPodTest.php | Class | Class source |
Files (50) | / | tests | / | Unit |
File | Role | Description |
---|---|---|
ContainerTest.php | Class | Class source |
LabelsTest.php | Class | Class source |
NodeLabelsTest.php | Class | Class source |
PodAnnotationsTest.php | Class | Class source |
PodLabelsTest.php | Class | Class source |
PodTest.php | Class | Class source |
ServiceAccountAnnotationsTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
kubernetes-resource--2022-10-17.zip 39KB | |
kubernetes-resource--2022-10-17.tar.gz 25KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Comments (1) | |||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.