[platform] fix deleting bundles (#809)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced the container image with an additional YAML processing tool
for improved configuration management.
- Introduced new workflow commands that streamline deployment operations
by reconciling resource changes and automating cleanup.
- Enabled management of disabled components by automatically suspending
and flagging inactive deployments for optimized system performance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
klinch0
2025-04-14 14:28:08 +03:00
committed by GitHub
4 changed files with 33 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ FROM alpine:3.21
RUN apk add --no-cache make
RUN apk add helm kubectl --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
RUN apk add yq
COPY scripts /cozystack/scripts
COPY --from=builder /src/packages/core /cozystack/packages/core

View File

@@ -7,7 +7,18 @@ show:
helm template -n $(NAMESPACE) $(NAME) . --dry-run=server $(API_VERSIONS_FLAGS)
apply:
helm template -n $(NAMESPACE) $(NAME) . --dry-run=server $(API_VERSIONS_FLAGS) | kubectl apply -f-
@echo "Applying active HelmReleases..."
helm template -n $(NAMESPACE) $(NAME) . --dry-run=server \
| yq 'select(.metadata.annotations."cozystack.io/marked-for-deletion" != "true")' - \
| kubectl apply -f-
delete:
@echo "Deleting marked-for-deletion HelmReleases..."
helm template -n $(NAMESPACE) $(NAME) . --dry-run=server \
| yq 'select(.metadata.annotations."cozystack.io/marked-for-deletion" == "true")' - \
| kubectl delete -f - --ignore-not-found=true
reconcile: apply delete
namespaces-show:
helm template -n $(NAMESPACE) $(NAME) . --dry-run=server $(API_VERSIONS_FLAGS) -s templates/namespaces.yaml

View File

@@ -80,3 +80,21 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- range $name := $disabledComponents }}
{{- if ne $name "" }}
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: {{ $name }}
namespace: {{ index $dependencyNamespaces $name | default "cozy-system" }}
annotations:
cozystack.io/marked-for-deletion: "true"
labels:
cozystack.io/repository: system
cozystack.io/system-app: "true"
spec:
suspend: true
{{- end }}
{{- end }}

View File

@@ -70,7 +70,7 @@ make -C packages/core/platform namespaces-apply
ensure_fluxcd
# Install platform chart
make -C packages/core/platform apply
make -C packages/core/platform reconcile
# Install basic charts
if ! flux_is_ok; then
@@ -93,5 +93,5 @@ done
trap 'exit' INT TERM
while true; do
sleep 60 & wait
make -C packages/core/platform apply
make -C packages/core/platform reconcile
done