feat(k8s): enable relative volume paths for kind deployments
Some checks failed
Lint Checks / Run linter (push) Successful in 4m32s
Lint Checks / Run linter (pull_request) Successful in 8m0s
Deploy Test / Run deploy test suite (pull_request) Successful in 14m0s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Failing after 16m26s
Webapp Test / Run webapp test suite (pull_request) Successful in 25m29s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Failing after 26m43s
Smoke Test / Run basic test suite (pull_request) Successful in 26m2s

Makes kind deployments use the same volume pattern as Docker Compose:
./data/{volume-name} relative to deployment directory.

Changes:
- Allow relative paths for kind (single host, like Docker Compose)
- Default kind volumes to ./data/ instead of provisioner-managed PVCs
- Update Caddy manifest to use hostPath /mnt/caddy-data
- Add caddy-data infrastructure volume support in kind mounts

This enables Caddy certificate persistence across cluster recreation
without requiring system-level directories like /opt/caddy-data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
A. F. Dudley 2026-01-25 16:57:28 -05:00
parent d5e1a6652c
commit 79b7870a6a
3 changed files with 32 additions and 27 deletions

View File

@ -243,26 +243,12 @@ spec:
mountPath: /config
volumes:
- name: caddy-data
persistentVolumeClaim:
claimName: caddy-data-pvc
hostPath:
path: /mnt/caddy-data
type: DirectoryOrCreate
- name: caddy-config
emptyDir: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: caddy-data-pvc
namespace: caddy-system
labels:
app.kubernetes.io/name: caddy-ingress-controller
app.kubernetes.io/instance: caddy-ingress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:

View File

@ -452,17 +452,21 @@ def init_operation(
volume_descriptors = {}
configmap_descriptors = {}
for named_volume in named_volumes["rw"]:
if "k8s" in deployer_type:
if deployer_type == "k8s":
# Full k8s: use provisioner-managed volumes
volume_descriptors[named_volume] = None
else:
# Docker Compose and kind: use relative paths
volume_descriptors[named_volume] = f"./data/{named_volume}"
for named_volume in named_volumes["ro"]:
if "k8s" in deployer_type:
if deployer_type == "k8s":
# Full k8s: configmaps or provisioner-managed
if "config" in named_volume:
configmap_descriptors[named_volume] = f"./configmaps/{named_volume}"
else:
volume_descriptors[named_volume] = None
else:
# Docker Compose and kind: use relative paths
volume_descriptors[named_volume] = f"./data/{named_volume}"
if volume_descriptors:
spec_file_content["volumes"] = volume_descriptors
@ -509,14 +513,17 @@ def _create_deployment_file(deployment_dir: Path):
def _check_volume_definitions(spec):
if spec.is_kubernetes_deployment():
for volume_name, volume_path in spec.get_volumes().items():
if volume_path:
if not os.path.isabs(volume_path):
raise Exception(
f"Relative path {volume_path} for volume {volume_name} not "
f"supported for deployment type {spec.get_deployment_type()}"
)
# Kind allows relative paths (single host, like Docker Compose)
# Full k8s requires absolute paths (pods could run on any node)
if not spec.is_kubernetes_deployment() or spec.is_kind_deployment():
return
for volume_name, volume_path in spec.get_volumes().items():
if volume_path and not os.path.isabs(volume_path):
raise Exception(
f"Relative path {volume_path} for volume {volume_name} not "
f"supported for deployment type {spec.get_deployment_type()}"
)
@click.command()

View File

@ -238,6 +238,18 @@ def _make_absolute_host_path(data_mount_path: Path, deployment_dir: Path) -> Pat
def _generate_kind_mounts(parsed_pod_files, deployment_dir, deployment_context):
volume_definitions = []
volume_host_path_map = _get_host_paths_for_volumes(deployment_context)
# Add infrastructure volumes (not defined in compose files)
for infra_volume in ["caddy-data"]:
if infra_volume in volume_host_path_map and volume_host_path_map[infra_volume]:
host_path = _make_absolute_host_path(
volume_host_path_map[infra_volume], deployment_dir
)
container_path = get_kind_pv_bind_mount_path(infra_volume)
volume_definitions.append(
f" - hostPath: {host_path}\n" f" containerPath: {container_path}\n"
)
# Note these paths are relative to the location of the pod files (at present)
# So we need to fix up to make them correct and absolute because kind assumes
# relative to the cwd.