feat(network-agent): 新增 mixingx-network-agent chart——DaemonSet(hostNetwork:9750,root 仅挂载 dbus socket,非 privileged)+ Headless 诊断 Service
This commit is contained in:
1 parent
61edf87116
commit
da7762b0cf
4 files changed
+145
No files matched your search
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: mixingx-network-agent
|
||||
description: "MixingX network console agent: 每节点常驻,提供主机网口(IP/掩码/网关/DNS)与 WiFi 的可视化配置 API。"
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "1.0.1"
|
||||
@@ -0,0 +1,87 @@
|
||||
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
|
||||
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 }}
|
||||
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
|
||||
runAsUser: 0
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: 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
|
||||
- name: nm-run
|
||||
mountPath: /run/NetworkManager
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: dbus
|
||||
hostPath:
|
||||
path: /run/dbus/system_bus_socket
|
||||
type: Socket
|
||||
- name: nm-run
|
||||
hostPath:
|
||||
path: /run/NetworkManager
|
||||
type: DirectoryOrCreate
|
||||
@@ -0,0 +1,18 @@
|
||||
# Headless 诊断服务: DNS network-agent 返回各节点 agent 的全部地址。
|
||||
# 注意: 每个 agent 只管理自己所在节点,不要用普通 ClusterIP Service 访问
|
||||
# (会在节点间随机负载均衡导致操作到错误的主机)。前端弹窗始终直连节点 IP。
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: network-agent
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: network-agent
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app.kubernetes.io/component: network-agent
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.ports.http }}
|
||||
targetPort: http
|
||||
@@ -0,0 +1,34 @@
|
||||
registry: 192.168.1.105:8888/mixingx
|
||||
timezone: Asia/Shanghai
|
||||
|
||||
image:
|
||||
repository: network-agent
|
||||
tag: latest
|
||||
|
||||
ports:
|
||||
http: 9750
|
||||
|
||||
# 鉴权令牌:为空则不启用(仅限内网联调);生产环境必须配置,
|
||||
# 前端弹窗请求头 Authorization: Bearer <token>
|
||||
authToken: ""
|
||||
|
||||
# 前端弹窗的跨域来源,逗号分隔;* = 任意(联调)
|
||||
corsOrigins: "*"
|
||||
|
||||
# 改静态 IP 后未确认自动回滚的窗口(秒)
|
||||
rollbackTimeoutSeconds: 60
|
||||
|
||||
# 确认 IP 变更后自动重启本机 k3s/k3s-agent(flannel 重绑新 IP)
|
||||
k3sRestartOnIpChange: true
|
||||
|
||||
# 只在指定节点部署(为空 = 每个节点一个,推荐)
|
||||
nodeName: ""
|
||||
nodeSelector: {}
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
Reference in new issue
Block a user