Kubernetes Deployment¶
Bases: K8sResourceManager
🚀 Initialize the Deployment class for managing Kubernetes Deployments.
CLI Usage
geniusrise deployment sub-command Examples:
genius deployment create --name example-deployment --image example-image --command "echo hello" --namespace geniusrise \
--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
genius deployment scale --name example-deployment --replicas 3 --namespace geniusrise \
--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
genius deployment describe --name example-deployment --namespace geniusrise \
--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
YAML Configuration:
version: "1.0"
deployments:
- name: "example-deployment"
image: "example-image"
command: "example-command"
replicas: 3
env_vars:
KEY: "value"
cpu: "100m"
memory: "256Mi"
storage: "1Gi"
gpu: "1"
__create_deployment_spec(image, command, replicas, image_pull_secret_name, env_vars, cpu=None, memory=None, storage=None, gpu=None)
¶
📦 Create a Kubernetes Deployment specification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
str
|
Docker image for the Deployment. |
required |
command |
str
|
Command to run in the container. |
required |
replicas |
int
|
Number of replicas. |
required |
image_pull_secret_name |
str
|
Name of the image pull secret. |
required |
env_vars |
dict
|
Environment variables for the Deployment. |
required |
cpu |
str
|
CPU requirements. |
None
|
memory |
str
|
Memory requirements. |
None
|
storage |
str
|
Storage requirements. |
None
|
gpu |
str
|
GPU requirements. |
None
|
Returns:
Type | Description |
---|---|
client.V1DeploymentSpec
|
client.V1DeploymentSpec: The Deployment specification. |
__init__()
¶
🚀 Initialize the Deployment class for managing Kubernetes Deployments.
create(name, image, command, registry_creds=None, replicas=1, env_vars={}, cpu=None, memory=None, storage=None, gpu=None, **kwargs)
¶
🛠Create a Kubernetes resource Deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the resource. |
required |
image |
str
|
Docker image for the resource. |
required |
command |
str
|
Command to run in the container. |
required |
registry_creds |
dict
|
Credentials for Docker registry. |
None
|
replicas |
int
|
Number of replicas for Deployment. |
1
|
env_vars |
dict
|
Environment variables for the resource. |
{}
|
cpu |
str
|
CPU requirements. |
None
|
memory |
str
|
Memory requirements. |
None
|
storage |
str
|
Storage requirements. |
None
|
gpu |
str
|
GPU requirements. |
None
|
create_parser(parser)
¶
🎛 Create a parser for CLI commands related to Deployment functionalities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
ArgumentParser
|
The main parser. |
required |
Returns:
Name | Type | Description |
---|---|---|
ArgumentParser |
ArgumentParser
|
The parser with subparsers for each command. |
delete(name)
¶
🗑 Delete a Kubernetes resource (Pod/Deployment/Service).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the resource to delete. |
required |
describe(deployment_name)
¶
🗂 Describe a Kubernetes deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name |
str
|
Name of the deployment. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
V1Deployment
|
Description of the deployment. |
run(args)
¶
🚀 Run the Deployment manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
The parsed command line arguments. |
required |
scale(name, replicas)
¶
📈 Scale a Kubernetes deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the deployment. |
required |
replicas |
int
|
Number of replicas. |
required |
show()
¶
🗂 List all deployments in the namespace.
Returns:
Name | Type | Description |
---|---|---|
list |
List[V1Deployment]
|
List of deployments. |
status(name)
¶
📊 Get the status of a Kubernetes deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the deployment. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
V1Deployment
|
Status of the deployment. |