Terraform (validated with the real terraform CLI - was never actually
run against this cluster, no state file existed):
- Delete main.tf: it declared a duplicate kubernetes_namespace.core
(also in namespaces.tf) and a duplicate provider "kubernetes" block
(also in providers.tf), both hard errors that would fail
`terraform plan` immediately.
- Fix workloads.tf references to 6 files deleted in the manifest
cleanup (jupiter-sts/svc, atlantis-sts/svc, fiesta-sts/svc) - now
points at the canonical nearle-jupiter/atlantis/fiesta.yaml.
- Fix every kubernetes_manifest resource: they fed multi-document
YAML (multiple '---'-separated docs per file) straight into
yamldecode(), which only parses a single document. Rewrote using a
split-on-'---' + for_each pattern, confirmed safe first by checking
separator counts exactly match document counts for every affected
file (no embedded '---' inside any script/config content).
- Add the doormile namespace; rename kubernetes_namespace to
kubernetes_namespace_v1 (fixes a deprecation warning).
- `terraform validate` now passes clean.
Shell scripts:
- deploy-nearle-stack.sh only applied 4 of the ~13 files in
manifests/nearle/ - missing the ConfigMap/Secrets fiesta/jupiter/
titan/ariane need via envFrom, the fiesta gateway script ConfigMap,
atlantis entirely, and the Gateway/ReferenceGrant/jupiter-cors-proxy
resources. Now applies every file (verified by diffing the
directory listing against the script).
- Added deploy-doormile.sh and deploy-ingress.sh - nothing previously
applied ingress-unified.yaml or traefik-middlewares.yaml at all.
- Rewrote deploy.sh as an orchestrator calling all of the above in
order (previously referenced a manifests/namespace.yaml layout that
hasn't existed since before this repo's initial commit).
- Rewrote check-k8s-status.sh to check the real namespaces
(core/nearle/alaska/doormile/kubernetes-dashboard) instead of a
'nats-backend' namespace that never existed in this repo.
- Fixed a `cd` bug in setup-jetstream.sh that made it change into
shfiles/ and then look for scripts/setup_jetstream.py there (a
child directory that doesn't exist) - it could never have found its
own target file. Now pulls NATS credentials from the live
nats-credentials Secret instead of a third hardcoded copy.
Python scripts:
- sync_manifests.py had hardcoded Windows paths (e:\nats\kubernetes\...)
- replaced with paths relative to the script's own location so it
actually runs here (or anywhere). Verified by running it.
- setup_jetstream.py created durable consumers under different names
than worker.py computes at runtime ({NATS_CONSUMER}_{subject}), so
its max_deliver/ack_wait settings never actually reached the
consumers workers bind to. Naming now derived with the same logic
worker.py uses - verified all 10 derived names match workers.yaml
exactly.
- purge-old-messages.py had hardcoded NATS credentials with no env
var override at all - fixed to match the pattern used everywhere
else.
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
import os
|
|
|
|
def update_yaml_with_script(yaml_path, script_path, key_line_start):
|
|
with open(script_path, 'r', encoding='utf-8') as f:
|
|
script_content = f.read()
|
|
|
|
# Indent script content by 4 spaces
|
|
indented_script = '\n'.join(' ' + line if line.strip() else line for line in script_content.splitlines())
|
|
|
|
with open(yaml_path, 'r', encoding='utf-8') as f:
|
|
yaml_lines = f.readlines()
|
|
|
|
# Find the key line (e.g., " app.py: |")
|
|
start_index = -1
|
|
for i, line in enumerate(yaml_lines):
|
|
if key_line_start in line:
|
|
start_index = i + 1
|
|
break
|
|
|
|
if start_index == -1:
|
|
print(f"Error: Could not find '{key_line_start}' in {yaml_path}")
|
|
return
|
|
|
|
# Find where the script block ends (next line that is NOT indented by at least 4 spaces, or EOF)
|
|
# Actually, the Data block might be the last thing.
|
|
# We assume the script goes until the end of the file or next unindented key.
|
|
# In these files, the script is usually the main data.
|
|
# Let's just truncate and append if it looks like the script is the last/main thing.
|
|
# But usually, it's safer to just replace the lines that look like script.
|
|
|
|
# Simple heuristic: The script block ends when indentation drops to 2 spaces or 0?
|
|
# In worker-script.yaml:
|
|
# 6: data:
|
|
# 7: worker.py: |
|
|
# 8: ...script...
|
|
# The script is indented by 4 spaces.
|
|
|
|
pre_script = yaml_lines[:start_index]
|
|
|
|
# We will just write the pre_script + indented_script
|
|
# WARNING: If there are other keys after worker.py, this deletes them.
|
|
# Let's check the files.
|
|
# worker-script.yaml: 378 lines. Script ends at 378. Nothing follows.
|
|
# fiesta-gateway.yaml: 407 lines. Script ends at 407. Nothing follows.
|
|
# So appending is SAFE.
|
|
|
|
with open(yaml_path, 'w', encoding='utf-8') as f:
|
|
f.writelines(pre_script)
|
|
f.write(indented_script)
|
|
f.write('\n') # Ensure newline at EOF
|
|
|
|
print(f"Successfully updated {yaml_path}")
|
|
|
|
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Update Fiesta Gateway
|
|
update_yaml_with_script(
|
|
os.path.join(REPO_ROOT, 'manifests', 'nearle', 'fiesta-gateway.yaml'),
|
|
os.path.join(REPO_ROOT, 'conf', 'app.py'),
|
|
' app.py: |'
|
|
)
|
|
|
|
# Update Worker Script
|
|
update_yaml_with_script(
|
|
os.path.join(REPO_ROOT, 'manifests', 'core', 'worker-script.yaml'),
|
|
os.path.join(REPO_ROOT, 'conf', 'worker.py'),
|
|
' worker.py: |'
|
|
)
|