Kubernetes Service¶
Bases: Deployment
🚀 Initialize the Service class for managing Kubernetes Services.
CLI Usage
genius service sub-command Examples:
genius service create --name example-service --image example-image --command "echo hello" --port 8080 --target_port 8080 --namespace geniusrise \
--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
genius service delete --name example-service --namespace geniusrise \
--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
YAML Configuration:
version: "1.0"
services:
- name: "example-service"
image: "example-image"
command: "example-command"
replicas: 3
port: 8080
target_port: 8080
env_vars:
KEY: "value"
cpu: "100m"
memory: "256Mi"
storage: "1Gi"
gpu: "1"
Extended CLI Examples
genius service deploy \
--k8s_kind service \
--k8s_namespace geniusrise \
--k8s_context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev \
--k8s_name webhook \
--k8s_image "genius-dev.dkr.ecr.ap-south-1.amazonaws.com/geniusrise" \
--k8s_env_vars '{"AWS_DEFAULT_REGION": "ap-south-1", "AWS_SECRET_ACCESS_KEY": "", "AWS_ACCESS_KEY_ID": ""}' \
--k8s_port 8080 \
--k8s_target_port 8080
__create_service_spec(node_port, port, target_port)
¶
📦 Create a Kubernetes Service specification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port |
int
|
Service port. |
required |
target_port |
int
|
Container target port. |
required |
Returns:
Type | Description |
---|---|
client.V1ServiceSpec
|
client.V1ServiceSpec: The Service specification. |
__init__()
¶
🚀 Initialize the Service class for managing Kubernetes Services.
create(name, image, command, registry_creds=None, replicas=1, node_port=80, port=80, target_port=8080, env_vars={}, cpu=None, memory=None, storage=None, gpu=None, **kwargs)
¶
🛠 Create a Kubernetes resource Service.
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
|
node_port |
int
|
Service port that is exposed. |
80
|
port |
int
|
Service port. |
80
|
target_port |
int
|
Container target port. |
8080
|
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 Service 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(service_name)
¶
🌐 Describe a Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
Name of the service. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
V1Service
|
Description of the service. |
run(args)
¶
🚀 Run the Service manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
The parsed command line arguments. |
required |
show()
¶
🌐 Show all services in the namespace.
Returns:
Name | Type | Description |
---|---|---|
list |
List[V1Service]
|
List of services. |
status(name)
¶
📊 Get the status of a Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the service. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
V1Deployment
|
Status of the service. |