Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s resource limit patch lib #19

Merged
merged 40 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
09cad35
Add resource limit patch lib
sed-i Jun 21, 2022
53ed742
Use PatchType.APPLY
sed-i Jun 21, 2022
8a130f5
Only on config-changed
sed-i Jun 21, 2022
ac0db2a
Only on config-changed - fix utests
sed-i Jun 21, 2022
f08f4e6
Add 'is_ready' method
sed-i Jun 22, 2022
c056ad1
Add utest
sed-i Jun 22, 2022
dfae73d
Doc fix
sed-i Jun 22, 2022
3b8e668
Interconvert k8s quantities
sed-i Jun 23, 2022
788b1c3
type fixes
sed-i Jun 23, 2022
f3e9514
Emit custom event on failure
sed-i Jun 24, 2022
5555eb8
Privatize
sed-i Jun 24, 2022
af4fa77
Doc fix
sed-i Jun 24, 2022
45a8158
Convert StopIteration to ValueError
sed-i Jun 29, 2022
369be4b
Sanitize input
sed-i Jul 5, 2022
f44d3b9
Use custom exception
sed-i Jul 6, 2022
af253a3
Standardize tests structure
sed-i Jul 6, 2022
5fa5047
Add itests and use charm as tester charm
sed-i Jul 6, 2022
857e331
Add utest
sed-i Jul 6, 2022
4e6bf2a
Add a FIXME
sed-i Jul 7, 2022
97cf093
Use lightkube utils
sed-i Jul 14, 2022
40f5c37
Address review comments
sed-i Jul 19, 2022
6b52771
Lint
sed-i Jul 19, 2022
584e868
Add intermediate method as an observer for easy mocking
sed-i Jul 19, 2022
71e74ea
Fix mypy env for mypy 0.971
sed-i Jul 19, 2022
fdc6478
Use python 3.8 for CI
sed-i Jul 19, 2022
a5c4d2d
Fix paths
sed-i Jul 19, 2022
46a307b
Split validation and sanitation
sed-i Jul 19, 2022
06f13fd
Improve Object init via super
sed-i Jul 19, 2022
bbee960
Pass resource limits as callable instead of dict
sed-i Jul 20, 2022
7d20d91
Move the ray hopper from prom to here
sed-i Jul 22, 2022
77d0da0
Add 'adjust_limits_and_requests' func
sed-i Jul 25, 2022
619ed9d
Return ResourceRequirements instead of tuple
sed-i Jul 25, 2022
fff87d6
Remove ResourceSpecDict
sed-i Jul 25, 2022
eadef95
Cleanup
sed-i Jul 25, 2022
a85daa1
copy k-v pairs from "limits" to "requests" if missing
sed-i Jul 27, 2022
7739794
Address review comments
sed-i Jul 29, 2022
001b3aa
Lint
sed-i Jul 29, 2022
ff693c9
Simplify
sed-i Aug 2, 2022
286f147
Validate keys
sed-i Aug 2, 2022
bcb3eec
Pin flake8 < 5
sed-i Aug 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Observability Libs CI
on:
on:
pull_request:
branches:
- main
Expand All @@ -14,10 +14,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python3 -m pip install tox
- name: Run static analysis
run: tox -vve static
- name: Run static analysis (lib)
run: tox -vve static-lib
- name: Run static analysis (charm)
run: tox -vve static-charm
- name: Run static analysis (unit tests)
run: tox -vve static-unit
- name: Run static analysis (integration tests)
run: tox -vve static-integration
lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -38,3 +48,17 @@ jobs:
run: python -m pip install tox
- name: Run tests
run: tox -vve unit
integration-test:
name: Integration tests (microk8s)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: latest/stable
provider: microk8s
bootstrap-options: "--agent-version 2.9.29"
- name: Run integration tests
run: tox -vve integration
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,32 @@ are used for the development of charms deployed as part of the LMA Light [bundle

## Usage

While it is possible to deploy this charm, it is essentially a no-op, and not what this charm was
designed for. Instructions are omitted. This may change in the near future.
While it is possible to deploy this charm, it is only a tester charm and is
intended to be deployed only for testing purposes.

```shell
charmcraft pack
juju deploy ./observability-libs_ubuntu-20.04-amd64.charm \
--resource placeholder-image=busybox
```

Where this charm should be used, is to access one of the following libraries during development:

- [KubernetesServicePatch] - a small library used to patch the Juju auto-created Kubernetes Service
during the deployment of a sidecar charm to contain the correct ports for an application.

- [JujuTopology] - Used to create and output Juju topologies either from charms, relation data, or parts.
- [KubernetesComputeResourcesPatch] - a small library used to patch the Juju
auto-created statefulset with custom resource limits.

- [JujuTopology] - Used to create and output Juju topologies either from charms, relation data, or parts.

## Contributing

Please see the [Juju SDK docs](https://juju.is/docs/sdk) for guidelines on enhancements to this
charm following best practice guidelines, and `CONTRIBUTING.md` for developer guidance.

[kubernetesservicepatch]: https://charmhub.io/observability-libs/libraries/kubernetes_service_patch
[KubernetesServicePatch]: https://charmhub.io/observability-libs/libraries/kubernetes_service_patch
[KubernetesComputeResourcesPatch]: https://charmhub.io/observability-libs/libraries/kubernetes_compute_resources_patch
[bundle]: https://charmhub.io/lma-light
[charm libraries]: https://juju.is/docs/sdk/libraries
[JujuTopology]: https://charmhub.io/observability-libs/libraries/juju_topology
[JujuTopology]: https://charmhub.io/observability-libs/libraries/juju_topology
13 changes: 13 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
options:
cpu:
description: |
K8s cpu resource limit, e.g. "1" or "500m". Default is unset (no limit).
See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: string
memory:
description: |
K8s memory resource limit, e.g. "1Gi". Default is unset (no limit).
See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: string