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

Review Charm for Listing #24

Open
wants to merge 1 commit into
base: charm-review-base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Integration tests

on:
pull_request:

jobs:
integration-test-microk8s:
name: Integration tests (microk8s)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: 3.1/stable
provider: microk8s
channel: 1.25-strict/stable
- name: Run integration tests
# set a predictable model name so it can be consumed by charm-logdump-action
run: tox -e integration -- --model testing
- name: Dump logs
uses: canonical/charm-logdump-action@main
if: failure()
with:
app: trino-k8s
model: testing
26 changes: 26 additions & 0 deletions .github/workflows/promote_charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Promote charm

on:
workflow_dispatch:
inputs:
origin-channel:
type: choice
description: 'Origin Channel'
options:
- latest/edge
destination-channel:
type: choice
description: 'Destination Channel'
options:
- latest/stable
secrets:
CHARMHUB_TOKEN:
required: true

jobs:
promote-charm:
uses: canonical/operator-workflows/.github/workflows/promote_charm.yaml@8892eb826818585b397295e40276ddd0c5d3d459
with:
origin-channel: ${{ github.event.inputs.origin-channel }}
destination-channel: ${{ github.event.inputs.destination-channel }}
secrets: inherit
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Tests
on:
pull_request:
jobs:
unit-tests:
uses: canonical/operator-workflows/.github/workflows/test.yaml@8892eb826818585b397295e40276ddd0c5d3d459
secrets: inherit
16 changes: 16 additions & 0 deletions .github/workflows/test_and_publish_charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Publish to edge

on:
push:
branches:
- main

jobs:
publish-to-edge:
uses: canonical/operator-workflows/.github/workflows/test_and_publish_charm.yaml@8892eb826818585b397295e40276ddd0c5d3d459
secrets: inherit
with:
integration-test-provider: microk8s
integration-test-provider-channel: 1.25-strict/stable
integration-test-juju-channel: 3.1/stable
integration-test-modules: '["test_charm"]'
AmberCharitos marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
venv/
build/
*.charm
.tox/
.coverage
__pycache__/
*.py[cod]
.idea
.vscode/
2 changes: 2 additions & 0 deletions .jujuignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.charm
/venv
37 changes: 37 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
header:
license:
spdx-id: Apache-2.0
copyright-owner: Canonical Ltd.
content: |
Copyright [year] [owner]
See LICENSE file for licensing details.
paths:
- '**'
paths-ignore:
- '.github/**'
- '**/.gitkeep'
- '**/*.cfg'
- '**/*.conf'
- '**/*.j2'
- '**/*.json'
- '**/*.md'
- '**/*.rule'
- '**/*.tmpl'
- '**/*.txt'
- '**/*.jinja'
- '.codespellignore'
- '.dockerignore'
- '.flake8'
- '.jujuignore'
- '.gitignore'
- '.licenserc.yaml'
- '.trivyignore'
- '.woke.yaml'
- '.woke.yml'
- 'CODEOWNERS'
- 'icon.svg'
- 'LICENSE'
- 'trivy.yaml'
- 'lib/**'
- 'trino-tls.svg'
comment: on-failure
4 changes: 4 additions & 0 deletions .woke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignore_files:
# Ignore ingress charm library as it uses non compliant terminology:
# whitelist.
- lib/charms/nginx_ingress_integrator/v0/nginx_route.py
124 changes: 124 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Testing

This project uses `tox` for managing test environments (4.4.x). There are some pre-configured environments
that can be used for linting and formatting code when you're preparing contributions to the charm:

```shell
tox run -e format # update your code according to linting rules
tox run -e lint # code style
tox run -e unit # unit tests
tox run -e integration # integration tests
tox # runs 'format', 'lint', and 'unit' environments
```

# Deploy Trino

This charm is used to deploy Trino Server in a k8s cluster. For local deployment, follow the following steps:

## Set up your development environment
### Install Microk8s
```
# Install Microk8s from snap:
sudo snap install microk8s --classic --channel=1.25

# Add the 'ubuntu' user to the Microk8s group:
sudo usermod -a -G microk8s ubuntu

# Give the 'ubuntu' user permissions to read the ~/.kube directory:
sudo chown -f -R ubuntu ~/.kube

# Create the 'microk8s' group:
newgrp microk8s
AmberCharitos marked this conversation as resolved.
Show resolved Hide resolved

# Enable the necessary Microk8s addons:
microk8s enable hostpath-storage dns
```
### Install Charmcraft
```
# Install lxd from snap:
sudo snap install lxd --classic --channel=5.12/stable

# Install charmcraft from snap:
sudo snap install charmcraft --classic --channel=2.2/stable

# Charmcraft relies on LXD. Configure LXD:
lxd init --auto
```
### Set up the Juju OLM
```
# Install the Juju CLI client, juju:
sudo snap install juju --channel=3.1/stable

# Install a "juju" controller into your "microk8s" cloud:
juju bootstrap microk8s trino-controller

# Create a 'model' on this controller:
juju add-model trino-k8s

# Enable DEBUG logging:
juju model-config logging-config="<root>=INFO;unit=DEBUG"

# Check progress:
juju status
juju debug-log
```
### Deploy charm
```
# Pack the charm:
charmcraft pack

# Deploy the coordinator:
juju deploy ./trino-k8s_ubuntu-22.04-amd64.charm --resource trino-image=trinodb/trino:418

# Deploy the worker:
juju deploy ./trino-k8s_ubuntu-22.04-amd64.charm --resource trino-image=trinodb/trino:418 --config charm-function=worker trino-k8s-worker

# Check deployment was successful:
kubectl get pods -n trino-k8s
```

For development of the `policy` relation please use the `trino-image=ghcr.io/canonical/trino:418` instead.

Note: due to the requirements of the `discovery_uri`, when using a separate coordinator and worker, the default `discovery_uri` value of `http://trino-k8s:8080` will only work if the trino coordinator deployment is named `trino-k8s`. If using another alias please update the worker and coordinator charm configurations accordingly.

## Trino configuration
```
# Enable DEBUG logging
juju config trino-k8s log-level=debug

```

## Trino actions
```
# Add a database:
juju run trino-k8s/0 add-connector --params connector.yaml

# Remove a database:
juju run trino-k8s/0 remove-connector --params connector.yaml

# Restart Trino Server:
juju run trino-k8s/0 restart
```

Note: the example of actions above are for postgres connector, however any connector listed [here](https://trino.io/docs/current/connector.html) are permissible.

## Accessing Trino
```
# Port forward (http)
kubectl port-forward pod/trino-k8s-0 8080:8080

# Connect to Trino server (http):
./cli/trino --server http://localhost:8080 --user dev

# View databases
SHOW CATALOGS;
```

## Cleanup
```
# Remove TLS relation:
juju remove-relation tls-certificates-operator trino-k8s

# Remove the application before retrying
juju remove-application trino-k8s --force
```
Loading