Replace DaemonSet with direct host API access in favor of a regular Deployment using Service trafficDistribution: PreferClose. This provides prefer-local routing to the nearest cozystack-api pod with fallback to remote pods when local one is unavailable. - Replace DaemonSet/Deployment toggle with always-Deployment - Replace internalTrafficPolicy: Local with trafficDistribution: PreferClose - Remove KUBERNETES_SERVICE_HOST/PORT override (use default kubernetes service) - Replace hard nodeSelector with soft nodeAffinity for control-plane nodes - Simplify migration hook to always clean up DaemonSet if present Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
76 lines
1.8 KiB
YAML
76 lines
1.8 KiB
YAML
{{- $previous := lookup "apps/v1" "DaemonSet" .Release.Namespace "cozystack-api" }}
|
|
{{- if $previous }}
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: "cozystack-api-hook"
|
|
annotations:
|
|
helm.sh/hook: post-upgrade
|
|
helm.sh/hook-weight: "1"
|
|
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
|
|
spec:
|
|
template:
|
|
metadata:
|
|
labels:
|
|
policy.cozystack.io/allow-to-apiserver: "true"
|
|
spec:
|
|
serviceAccountName: "cozystack-api-hook"
|
|
containers:
|
|
- name: kubectl
|
|
image: docker.io/alpine/k8s:1.33.4
|
|
command:
|
|
- sh
|
|
args:
|
|
- -exc
|
|
- |-
|
|
kubectl --namespace={{ .Release.Namespace }} delete --ignore-not-found \
|
|
daemonsets.apps cozystack-api
|
|
restartPolicy: Never
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: Role
|
|
metadata:
|
|
annotations:
|
|
helm.sh/hook: post-upgrade
|
|
helm.sh/hook-weight: "1"
|
|
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
|
|
name: "cozystack-api-hook"
|
|
rules:
|
|
- apiGroups:
|
|
- "apps"
|
|
resources:
|
|
- "daemonsets"
|
|
verbs:
|
|
- get
|
|
- delete
|
|
resourceNames:
|
|
- "cozystack-api"
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: RoleBinding
|
|
metadata:
|
|
name: "cozystack-api-hook"
|
|
annotations:
|
|
helm.sh/hook: post-upgrade
|
|
helm.sh/hook-weight: "1"
|
|
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
|
|
roleRef:
|
|
apiGroup: rbac.authorization.k8s.io
|
|
kind: Role
|
|
name: "cozystack-api-hook"
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: "cozystack-api-hook"
|
|
namespace: "{{ .Release.Namespace }}"
|
|
---
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: "cozystack-api-hook"
|
|
annotations:
|
|
helm.sh/hook: post-upgrade
|
|
helm.sh/hook-weight: "1"
|
|
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
|
|
{{- end }}
|
|
|