Files
mx-ops d4b84bb886 fix(network-agent): daemonset 补渲染 imagePullSecrets
ACR 私仓交付后 DaemonSet 无拉取凭据,匿名拉取报 insufficient_scope。
对齐其余 10 个 chart 的标准写法,消费 _common/registry.yaml 提供的 imagePullSecrets。
2026-09-10 08:43:57 +00:00

96 lines
3.5 KiB
YAML

apiVersion: apps/v1
kind: DaemonSet
metadata:
name: network-agent
labels:
app.kubernetes.io/name: mixingx
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: network-agent
spec:
selector:
matchLabels:
app.kubernetes.io/component: network-agent
template:
metadata:
labels:
app.kubernetes.io/component: network-agent
annotations:
# 容器内 nmcli 通过 D-Bus 操作主机 NetworkManager,
# 需要 unconfined 才能通过 dbus-daemon 的 AppArmor 仲裁
container.apparmor.security.beta.kubernetes.io/network-agent: unconfined
spec:
# hostNetwork: IP 变更后 agent 在新 IP 上继续存活,负责回滚与 k3s 自愈;
# 前端弹窗直连 http://<节点IP>:9750 即命中该节点的 agent
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- if .Values.nodeName }}
nodeName: {{ .Values.nodeName }}
{{- else if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: network-agent
image: {{ .Values.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: {{ .Values.ports.http }}
protocol: TCP
env:
- name: TZ
value: {{ .Values.timezone | default "Asia/Shanghai" | quote }}
- name: ASPNETCORE_URLS
value: "http://0.0.0.0:{{ .Values.ports.http }}"
- name: AUTH_TOKEN
value: {{ .Values.authToken | quote }}
- name: CORS_ORIGINS
value: {{ .Values.corsOrigins | quote }}
- name: ROLLBACK_TIMEOUT_SECONDS
value: {{ .Values.rollbackTimeoutSeconds | quote }}
- name: K3S_RESTART_ON_IP_CHANGE
value: {{ .Values.k3sRestartOnIpChange | quote }}
securityContext:
# 只需 root + D-Bus socket,无需 privileged 与额外 capability:
# nmcli 经 D-Bus 操作主机 NM,特权动作(改 IP/路由)全部由 NM 进程执行
runAsUser: 0
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /api/network/health
port: {{ .Values.ports.http }}
initialDelaySeconds: 15
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 6
readinessProbe:
httpGet:
path: /api/network/health
port: {{ .Values.ports.http }}
initialDelaySeconds: 5
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 6
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeMounts:
# 主机 system bus: nmcli 与 systemd 重启都走它
- name: dbus
mountPath: /run/dbus/system_bus_socket
# 网卡别名持久化: aliases.json 落宿主机,重启/重建 Pod 均保留
- name: alias-store
mountPath: /var/lib/mixingx/network-agent
volumes:
- name: dbus
hostPath:
path: /run/dbus/system_bus_socket
type: Socket
- name: alias-store
hostPath:
path: /var/lib/mixingx/network-agent
type: DirectoryOrCreate