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

inital pass at adding terraform for the k8s charms #194

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

asbalderson
Copy link

Applicable spec: https://docs.google.com/document/d/1EG71A2pJ244PQRaGVzGj7Mx2B_bzE4U_OSqx4eeVI1E/edit?tab=t.0

Overview

Adds basic terraform modules for the k8s charms

Rationale

Enable deploying canonical k8s with terraform

Juju Events Changes

N/A

Module Changes

N/A

Library Changes

N/A

Checklist

@asbalderson asbalderson marked this pull request as ready for review December 2, 2024 18:02
@asbalderson asbalderson requested a review from a team as a code owner December 2, 2024 18:02
Copy link
Contributor

github-actions bot commented Dec 2, 2024

Test coverage for 2a1d220

coverage-report: install_deps /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> python -I -m pip install 'coverage[toml]'
coverage-report: commands[0] /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> coverage report
Name                                    Stmts   Miss  Cover
-----------------------------------------------------------
lib/charms/k8s/v0/k8sd_api_manager.py     278     29    90%
src/charm.py                              473    233    51%
src/cloud_integration.py                   80      3    96%
src/config/extra_args.py                   27      1    96%
src/containerd.py                         140     16    89%
src/cos_integration.py                     33     12    64%
src/events/update_status.py                48     10    79%
src/inspector.py                           40      4    90%
src/kube_control.py                        39     31    21%
src/literals.py                             1      0   100%
src/protocols.py                           16      3    81%
src/reschedule.py                          77      4    95%
src/snap.py                               165     10    94%
src/token_distributor.py                  181    109    40%
src/upgrade.py                             31      1    97%
-----------------------------------------------------------
TOTAL                                    1629    466    71%
coverage-report: OK (1.23=setup[1.02]+cmd[0.20] seconds)
congratulations :) (1.28 seconds)

Static code analysis report

Run started:2024-12-02 21:08:59.067008

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 3534
  Total lines skipped (#nosec): 3
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Copy link
Contributor

@louiseschmidtgen louiseschmidtgen left a comment

Choose a reason for hiding this comment

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

Did a first pass on the templates, thank you so much for your work! I believe these should find a separate repo to live in.

| Name | Type | Description | Required |
| - | - | - | - |
| `app_name`| string | Application name | False |
| `channel`| string | Channel that the charm is deployed from | False |
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this tf deploy work for strict as well?

```

### Define a `data` source
Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything.
Define a `data` source and pass a reference to the `model_name` input to the `data.juju_model` resource's name. Terraform will look for a `juju_model` resource with a matching model name and only apply resources if the names match.

Comment on lines +46 to +55
variable "series" {
description = "Ubuntu series to deploy the charm onto"
type = string
default = "24.04"

validation {
condition = contains(["20.04", "22.04", "24.04"], var.series)
error_message = "Series must be one of 20.04, 22.04, 24.04"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
variable "series" {
description = "Ubuntu series to deploy the charm onto"
type = string
default = "24.04"
validation {
condition = contains(["20.04", "22.04", "24.04"], var.series)
error_message = "Series must be one of 20.04, 22.04, 24.04"
}
}
variable "base" {
description = "Ubuntu series to deploy the charm onto"
type = string
default = "ubuntu@24.04"
validation {
condition = contains(["ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04"], var.base)
error_message = "Series must be one of ubuntu@20.04, ubuntu@22.04, ubuntu@24.04"
}
}

Let's use base here since series attribute will be removed in the next major version of the provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants