-
Notifications
You must be signed in to change notification settings - Fork 2
remove nersc.org from tls request #15
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
edfa9d5
remove nersc.org from tls request
dingp fa97835
refactor ingress handling
dingp dddab51
fix placeholder for ingress name
dingp 9c7960f
replace prepare-values.sh with python script and config file
dingp 8f10c39
ensure nersc.org is in the host list
dingp 0b934fb
fix cluster name
dingp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Repository Guidelines | ||
|
|
||
| This guide explains how to contribute to the Spin Helm recipes with minimal friction. Keep changes small, tested, and documented so others can reproduce them. | ||
|
|
||
| ## Project Structure & Module Organization | ||
| - `nats/`: Helm values and kustomize post-renderer for the NATS chart; `values.yaml` for defaults and `tls-acme-values.yaml` for certificate setup. `kustomize/` patches StatefulSets/Deployments with `SPIN_UID`/`SPIN_GID`. | ||
| - `tls-acme/`: Standalone Helm chart (`Chart.yaml`, `templates/`, `values.yaml`) for ACME-driven TLS issuance and renewals on Spin. | ||
| - `scripts/`: Utility scripts (e.g., `scripts/mdl.sh` for markdownlint autofix). | ||
| - Repo configs: `.pre-commit-config.yaml`, `.yamllint.yml`, `.markdownlint.rb` define lint rules; align contributions to them. | ||
|
|
||
| ## Build, Test, and Development Commands | ||
| - `pre-commit run --all-files` to run markdownlint, yamllint, and trailing whitespace checks locally. | ||
| - `yamllint .` to validate YAML with the repo config (line length 120, strict indentation). | ||
| - `./scripts/mdl.sh` to autofix Markdown formatting before review. | ||
| - `helm lint tls-acme` to sanity-check the TLS chart; add `-f <values>` as needed. | ||
| - For NATS overlays, render and patch locally: `cd nats/kustomize && helm template nats/nats -f ../values.yaml --post-renderer ./kustomize.sh`. | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
| - YAML: 2-space indentation, descriptive keys, keep `*-values.yaml` file names and placeholder tokens (`RUN_AS_USER_PLACEHOLDER`, `FS_GROUP_PLACEHOLDER`) intact for scripted substitution. | ||
| - Markdown: respect `.markdownlint.rb` (ordered lists, generous line length). Prefer short headings and actionable steps. | ||
| - Shell: keep scripts POSIX/Bash compatible, check for required env vars (`SPIN_UID`, `SPIN_GID`) before use. | ||
|
|
||
| ## Testing Guidelines | ||
| - Chart changes: run `helm lint` and, when altering templates, `helm template ... | kubectl kustomize ./nats/kustomize` to verify patches apply cleanly. | ||
| - Functional checks occur on Spin: follow the per-directory READMEs to install/upgrade releases, then validate via `kubectl` execs (e.g., `nats rtt`) or ingress reachability. | ||
| - Add brief notes in PRs on what was verified (commands + namespace/cluster used), especially for TLS issuance runs. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| - Commits: imperative mood with scope when helpful (e.g., `nats: adjust websocket ingress whitelist`); group related changes. | ||
| - PRs: include a summary of changes, linked issues (if any), values files touched, commands run, and relevant logs or screenshots for install/upgrade attempts. | ||
| - Avoid committing secrets or cluster-specific kubeconfigs; keep sensitive values in local overrides and document placeholders instead. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/usr/bin/env python3 | ||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| from pathlib import Path | ||
| import sys | ||
|
|
||
| import yaml | ||
| from jinja2 import Environment, FileSystemLoader, StrictUndefined | ||
|
|
||
|
|
||
| def build_parser() -> argparse.ArgumentParser: | ||
| parser = argparse.ArgumentParser( | ||
| description='Render values.yaml from a YAML config file and Jinja template.' | ||
| ) | ||
| parser.add_argument( | ||
| 'config', | ||
| nargs='?', | ||
| default='prepare-values.yaml', | ||
| help='Path to the YAML config file. Default: prepare-values.yaml', | ||
| ) | ||
| parser.add_argument( | ||
| '--template', | ||
| default='values_template.yaml', | ||
| help='Path to the Jinja values template. Default: values_template.yaml', | ||
| ) | ||
| parser.add_argument( | ||
| '--output', | ||
| default='values.yaml', | ||
| help='Path to the rendered values file. Default: values.yaml', | ||
| ) | ||
| return parser | ||
|
|
||
|
|
||
| def load_yaml(path: Path) -> dict: | ||
| with path.open('r', encoding='utf-8') as fh: | ||
| data = yaml.safe_load(fh) or {} | ||
| if not isinstance(data, dict): | ||
| raise ValueError(f'{path} must contain a YAML mapping at the top level.') | ||
| return data | ||
|
|
||
|
|
||
| def derive_fields(config: dict) -> dict: | ||
| rendered = dict(config) | ||
|
|
||
| if 'webserver_existing' not in rendered: | ||
| use_case = rendered.get('use_case') | ||
| if use_case == 'case1': | ||
| rendered['webserver_existing'] = True | ||
| elif use_case == 'case2': | ||
| rendered['webserver_existing'] = False | ||
| else: | ||
| raise ValueError( | ||
| 'Set webserver_existing explicitly, or set use_case to case1 or case2.' | ||
| ) | ||
|
|
||
| user_domains = rendered.get('user_domains') | ||
| if not isinstance(user_domains, list) or not user_domains: | ||
| raise ValueError('user_domains must be a non-empty YAML list.') | ||
| if not all(isinstance(domain, str) and domain for domain in user_domains): | ||
| raise ValueError('Each entry in user_domains must be a non-empty string.') | ||
|
|
||
| return rendered | ||
|
|
||
|
|
||
| def render(template_path: Path, context: dict) -> str: | ||
| env = Environment( | ||
| loader=FileSystemLoader(str(template_path.parent)), | ||
| undefined=StrictUndefined, | ||
| trim_blocks=True, | ||
| lstrip_blocks=True, | ||
| ) | ||
| template = env.get_template(template_path.name) | ||
| return template.render(**context) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| parser = build_parser() | ||
| args = parser.parse_args() | ||
|
|
||
| config_path = Path(args.config).resolve() | ||
| template_path = Path(args.template).resolve() | ||
| output_path = Path(args.output).resolve() | ||
|
|
||
| if not config_path.exists(): | ||
| print( | ||
| f'Error: config file not found: {config_path}\n' | ||
| f'Hint: copy {config_path.parent / "prepare-values.yaml.example"} ' | ||
| f'to {config_path.parent / "prepare-values.yaml"} and edit it.', | ||
| file=sys.stderr, | ||
| ) | ||
| return 1 | ||
|
|
||
| try: | ||
| config = derive_fields(load_yaml(config_path)) | ||
| rendered = render(template_path, config) | ||
| except Exception as exc: | ||
| print(f'Error: {exc}', file=sys.stderr) | ||
| return 1 | ||
|
|
||
| output_path.write_text(rendered, encoding='utf-8') | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| raise SystemExit(main()) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copy this file to prepare-values.yaml and update the values for your deployment. | ||
| nersc_user_id: 12345 | ||
| nersc_user_group: 67890 | ||
| service_port: 8080 | ||
| ingress_name: my-ingress | ||
| email: user@email.com | ||
| cluster: production | ||
| use_case: case2 | ||
| # Optional override. If omitted, prepare-values.py derives it from use_case. | ||
| # webserver_existing: false | ||
| user_domains: | ||
| - app1.example1.com | ||
| - app1.example2.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.