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 metacontroller for kubeflow 1.4 #1

Merged
merged 27 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af71a81
Initial commit
ca-scribner Sep 22, 2021
17010e7
feat: Add remove hook
ca-scribner Sep 22, 2021
db1856a
feat: encapsulate resource-check logic for reuse
ca-scribner Sep 22, 2021
5e7d673
feat: add reconcile loop on update-status hook
ca-scribner Sep 22, 2021
74fa19a
fix: tests
ca-scribner Sep 22, 2021
795323a
fix: tests
ca-scribner Sep 22, 2021
4887fb4
fix: add setuptools and pip to charmcraft parts for building
ca-scribner Oct 27, 2021
75c974e
fix: add missing yaml resources
ca-scribner Oct 28, 2021
b9694a9
feat: Add LICENSE, minor fixes
ca-scribner Nov 15, 2021
838d579
Misc updates from peer review
ca-scribner Nov 15, 2021
aa0dcc3
Misc updates from peer review
ca-scribner Nov 16, 2021
92045d0
Remove noop container
ca-scribner Nov 16, 2021
8f27442
feat: Use lightkube instead of kubectl for creating objects
ca-scribner Nov 16, 2021
03838fa
feat: unit tests for rendering yaml and creating k8s objects
ca-scribner Nov 17, 2021
da5abfb
feat: add unit tests for install and update_status events
ca-scribner Nov 17, 2021
af06c84
feat: refactor check_deployed_resources, add tests
ca-scribner Nov 18, 2021
4d1a478
fix: flake8 max-complexity, linting problems
ca-scribner Nov 18, 2021
74f44d2
feat: add StatefulSet validation and tests
ca-scribner Nov 18, 2021
6e38a7c
feat: add error message for when charm does not have trust
ca-scribner Nov 18, 2021
64bebb6
fix: typo in integrate.yaml
ca-scribner Nov 18, 2021
bfe2da4
fix: mock away lightkube client in unit tests
ca-scribner Nov 19, 2021
454e7a2
fix: update install process to handle resource conflicts
ca-scribner Nov 19, 2021
4200f8c
fix: formatting
ca-scribner Nov 19, 2021
85c3af5
fix: disable _no_trust integration test
ca-scribner Nov 19, 2021
24ef72b
Refactor to address review comments
ca-scribner Nov 19, 2021
198dd8c
Refactor to address review comments
ca-scribner Nov 23, 2021
29d8526
fix: test_check_deployed_resources
ca-scribner Nov 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 99
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
select: E,W,F,C,N
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
exclude:
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
venv
.git
build
dist
*.egg_info
75 changes: 75 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
sudo apt update
sudo apt install tox
- name: Lint code
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
run: tox -vve lint

unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: pip install tox
- name: Run unit tests
run: tox -vve unit

integration:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved

# TODO: Remove once the actions-operator does this automatically
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
- name: Configure kubectl
run: |
sg microk8s -c "microk8s config > ~/.kube/config"

- name: Test
run: |
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
sg microk8s -c "tox -vve integration -- --model testing"

# On failure, capture debugging resources
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we can probably skip the comment, seeing if: failure() is easy to spot for me, at least

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I actually like having. fwiw, I actually misread this the first time I saw it in charms. I see that comment as a header for the next 6 things, all of which happen in failures. Maybe it could be formatted differently instead?

- name: Get all
run: kubectl get all -A
if: failure()

- name: Describe deployments
run: kubectl describe deployments -A
if: failure()

- name: Describe replicasets
run: kubectl describe replicasets -A
if: failure()

- name: Get juju status
run: juju status
if: failure()

- name: Get application logs
run: kubectl logs -n testing --tail 1000 -ljuju-app=metacontroller-operator
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
if: failure()

- name: Get application operator logs
run: kubectl logs -n testing --tail 1000 -ljuju-operator=metacontroller-operator
if: failure()
45 changes: 45 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish

on:
push:
branches:
# TODO: Set this to 'main' when ready to publish
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
- master

jobs:
charm:
name: Charm
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Install dependencies
run: |
set -eux
sudo snap install charm --classic
sudo pip3 install charmcraft=
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
sudo snap install yq

- name: Publish charm
env:
CHARMSTORE_CREDENTIAL: ${{ secrets.CHARMSTORE_CREDENTIAL }}
run: |
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
set -eux
echo $CHARMSTORE_CREDENTIAL > ~/.go-cookies

CS_URL="cs:~kubeflow-charmers/metacontroller-operator"

# TODO: Make this loop over all resources
IMAGE=$(yq eval '.resources.noop.upstream-source' metadata.yaml)
charmcraft build
docker pull $IMAGE
charm push ./*.charm $CS_URL --resource oci-image=$IMAGE

REVISION=$(charm show $CS_URL --channel unpublished --format yaml | yq e .id-revision.Revision -)
OCI_VERSION=$(charm list-resources $CS_URL --format yaml --channel unpublished | yq e .0.revision -)
charm release \
--channel edge \
--resource oci-image-$OCI_VERSION \
$CS_URL-$REVISION
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
venv/
build/
.tox/
*.charm

.coverage
__pycache__/
*.py[cod]
3 changes: 3 additions & 0 deletions .jujuignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/venv
*.py[cod]
*.charm
25 changes: 25 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Learn more about charmcraft.yaml configuration at:
# https://juju.is/docs/sdk/charmcraft-config
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
type: "charm"
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
parts:
# TODO/DEBUG: Including the below kubectl and charm parts USUALLY causes an infinite loop during `charmcraft pack`.
# Omitting for now...
kubectl:
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
plugin: dump
source: .
override-pull: |
curl -sSLO https://dl.k8s.io/release/v1.22.1/bin/linux/amd64/kubectl
chmod +x kubectl
build-packages:
- curl
charm:
charm-python-packages: [setuptools, pip] # Fixes jinja install during pack
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
# prime:
# - ./files/manifests/*.yaml
22 changes: 22 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: metacontroller-operator
display-name: Metacontroller-operator
description: |
Metacontroller is an add-on for Kubernetes to make it easier to write and deploy custom controllers,
reducing the need for boilerplate code.

https://github.com/metacontroller/metacontroller
summary: An add-on for Kubernetes to write and deploy custom controllers from simple scripts

# Do I need this at all? This would be if I'm maintaining things via pebble?
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
containers:
noop:
resource: noop

resources:
noop:
type: oci-image
description: ''
upstream-source: alpine

# TODO: I don't really need this oci-image, everything gets downloaded by k8s. This is really a config arg. Will refactor
# TODO: Try with recent metacontroller. This is 3 years old... Kubeflow Pipelines has a merged change with update
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ops >= 1.2.0
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
jinja2 < 4
ca-scribner marked this conversation as resolved.
Show resolved Hide resolved
oci-image<1.1.0
kubernetes < 19.0.0
Loading