Skip to content

Commit

Permalink
feat: add Kubernetes/helm release setup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
O1ahmad committed Jun 25, 2024
1 parent 830ffd1 commit 0aed475
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ Systemd, [Docker SDK](https://docker-py.readthedocs.io/en/stable/) for Python (f
| _ports_ | listening port information for a service | `{}` |
| _dataDir_ | directory to store service runtime/operational data | `/tmp` |
| _restart_policy_ | service restart policy | `unless-stopped` |
| _cpus_ | available CPU resources each deployed service can use | `1.0` |
| _memory_ | available memory resources each deployed service can use | `4g` |

### Container

| var | description | default |
| :-------------: | :--------------------------------------------------------: | :--------------: |
| _image_ | service container image to deploy | ` ` |
| _resources.cpuLimit_ | limit of CPU resources each deployed service can use | `1.0` |
| _resources.memLimit_ | limit of memory resources each deployed service can use | `1G` |
| _resources.memRequest_ | requested memory resources each deployed service can use | `1G` |

### Systemd

Expand All @@ -49,7 +50,16 @@ Systemd, [Docker SDK](https://docker-py.readthedocs.io/en/stable/) for Python (f
| _binary_file_name_override_ | Override the binary file name after moving it to the destination directory | ` ` |
| _destination_directory_ | directory where the binary file will be placed after downloading/extracting | `/usr/local/bin` |
| _systemd_ | Systemd deployment custom unit, service and install properties | `{}` |
| _cpus_ | percentage of CPU resources each deployed service can use | `100%` |
| _memory_ | available memory resources each deployed service can use | `1G` |

### Kubernetes (k8s)

| var | description | default |
| :-------------: | :--------------------------------------------------------: | :--------------: |
| _helm_chart_path_ | path to Helm chart to use for the service deployment/release | `../../helm` |
| _helm_namespace_ | Kubernetes namespace to deploy to | `default` |
| _helm_values_path_ | file to load Helm chart values (see [here](./helm/README.md) for available values) | `values.yml` |

## Containerized Apps
- [O1 Containers](https://github.com/0x0I/containers)
Expand Down
14 changes: 14 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,31 @@ port_list: []

### Container ###
image:
resources:

Check failure on line 61 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / lint

61:1 [key-duplicates] duplication of key "resources" in mapping
cpuLimit: 1
memRequest: 1G
memLimit: 1G

### Systemd ###
binary_url:
# (Optional) Override the binary file name after moving it to the destination directory
binary_file_name_override:

cpus: 100%
memory: 1G

systemd: {}
# unit_properties: {}
# service_properties: {}
# install_properties: {}

systemd_environment_directive: ""

### Kubernetes ###
helm_chart_path: ../../helm
helm_namespace: default
helm_values_path: values.yml

###

setup_iptables: false
19 changes: 19 additions & 0 deletions tasks/k8s/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Ensure Helm is installed
command: helm version

Check failure on line 3 in tasks/k8s/setup.yml

View workflow job for this annotation

GitHub Actions / lint

3:14 syntax error: mapping values are not allowed here (syntax)
register: helm_version
ignore_errors: true

- name: Install Helm if not installed
apt:
name: helm
state: present
when: helm_version.failed

- name: Deploy Helm chart
kubernetes.core.helm:
name: "{{ name }}"
chart_ref: "{{ helm_chart_path }}"
release_namespace: "{{ helm_namespace }}"
values_files:
- "{{ helm_values_path }}"

0 comments on commit 0aed475

Please sign in to comment.