feat(config): 移除Agent配置中的共享基础设施PostgreSQL凭据配置
移除了applications/demo/agents.yaml和applications/dev/disabled/agents.yaml中 的sharedInfra.postgres配置部分,同时从environments/demo/agent-common-values.yaml 和environments/dev/agent-common-values.yaml中调整了PostgreSQL配置结构, 将adminUsername改为username并添加了默认密码配置。 删除了不再需要的agent-postgres-role-rollout.md文档和 upsert-agent-postgres-credentials.sh脚本,简化了数据库凭据管理流程。 更新了environments/demo/agents.yaml和environments/dev/agents.yaml中 的Agent配置,移除了databaseUsername和postgresCredentialsSecret字段。
This commit is contained in:
1 parent
067c15f023
commit
1c96858a74
8 files changed
+4
-112
No files matched your search
@@ -35,11 +35,6 @@ spec:
|
|||||||
site: "{{ .id }}"
|
site: "{{ .id }}"
|
||||||
description: "{{ .description }}"
|
description: "{{ .description }}"
|
||||||
phaseType: "{{ .phaseType }}"
|
phaseType: "{{ .phaseType }}"
|
||||||
sharedInfra:
|
|
||||||
postgres:
|
|
||||||
appUsername: "{{ .databaseUsername }}"
|
|
||||||
credentialsSecret:
|
|
||||||
name: "{{ .postgresCredentialsSecret }}"
|
|
||||||
{{- if hasKey . "nodeLabel" }}
|
{{- if hasKey . "nodeLabel" }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
mixingx.io/edge-node: "{{ .nodeLabel }}"
|
mixingx.io/edge-node: "{{ .nodeLabel }}"
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ spec:
|
|||||||
site: "{{ .id }}"
|
site: "{{ .id }}"
|
||||||
description: "{{ .description }}"
|
description: "{{ .description }}"
|
||||||
phaseType: "{{ .phaseType }}"
|
phaseType: "{{ .phaseType }}"
|
||||||
sharedInfra:
|
|
||||||
postgres:
|
|
||||||
appUsername: "{{ .databaseUsername }}"
|
|
||||||
credentialsSecret:
|
|
||||||
name: "{{ .postgresCredentialsSecret }}"
|
|
||||||
{{- if .nodeLabel }}
|
{{- if .nodeLabel }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
mixingx.io/edge-node: "{{ .nodeLabel }}"
|
mixingx.io/edge-node: "{{ .nodeLabel }}"
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ images:
|
|||||||
|
|
||||||
sharedInfra:
|
sharedInfra:
|
||||||
postgres:
|
postgres:
|
||||||
adminUsername: postgres
|
username: postgres
|
||||||
|
password: "Admin12345"
|
||||||
port: 5432
|
port: 5432
|
||||||
idleInTransactionSessionTimeout: 60s
|
idleInTransactionSessionTimeout: 60s
|
||||||
credentialsSecret:
|
|
||||||
adminPasswordKey: admin-password
|
|
||||||
appPasswordKey: app-password
|
|
||||||
connectionStringKey: connection-string
|
|
||||||
redis:
|
redis:
|
||||||
host: redis-service
|
host: redis-service
|
||||||
port: 6379
|
port: 6379
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# Agent PostgreSQL runtime role rollout
|
|
||||||
|
|
||||||
The demo Agent uses a dedicated PostgreSQL login. Passwords and the complete
|
|
||||||
connection string are stored only in a Kubernetes Secret and are not committed.
|
|
||||||
|
|
||||||
## Prepare the Secret
|
|
||||||
|
|
||||||
Load the administrator password already used by the Agent PostgreSQL instance
|
|
||||||
and a distinct application password from the approved vault into the operator
|
|
||||||
shell environment, then run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
AGENT_POSTGRES_ADMIN_PASSWORD='<from-vault>' \
|
|
||||||
AGENT_POSTGRES_APP_PASSWORD='<from-vault>' \
|
|
||||||
./scripts/upsert-agent-postgres-credentials.sh mixingx demo-2 agent_demo_2
|
|
||||||
```
|
|
||||||
|
|
||||||
The script is idempotent. Do not place either value in a values file, command
|
|
||||||
argument, or shell history. It writes short-lived mode-`0700` input files and
|
|
||||||
removes them on exit, so the values are not exposed through `kubectl` process
|
|
||||||
arguments. The generated Secret contains `admin-password`, `app-password`, and
|
|
||||||
a `connection-string` whose username is `agent_demo_2`.
|
|
||||||
|
|
||||||
## Roll out
|
|
||||||
|
|
||||||
1. Sync `mixingx-agent-demo-2` in Argo CD. The PostgreSQL StatefulSet consumes
|
|
||||||
the administrator password; the Agent init container waits for PostgreSQL,
|
|
||||||
provisions the runtime role, transfers existing `public` objects, and applies
|
|
||||||
the database-local timeout.
|
|
||||||
2. When rotating an existing Secret, restart the Agent deployment explicitly:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl --namespace mixingx rollout restart deployment/agent-demo-2-deployment
|
|
||||||
kubectl --namespace mixingx rollout status deployment/agent-demo-2-deployment --timeout=300s
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Verify the backend container receives only the application connection string.
|
|
||||||
The administrator login remains reserved for provisioning, backup, and manual
|
|
||||||
maintenance. Startup EF Core migrations run as the database-owning application
|
|
||||||
role; `statement_timeout` and `lock_timeout` are explicitly left unset.
|
|
||||||
|
|
||||||
## Verify
|
|
||||||
|
|
||||||
Run the following through a temporary `psql` Pod or an approved database client,
|
|
||||||
using the application credential from the Secret:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SHOW idle_in_transaction_session_timeout;
|
|
||||||
SHOW statement_timeout;
|
|
||||||
SHOW lock_timeout;
|
|
||||||
SELECT rolname, rolsuper, rolcreatedb, rolcreaterole
|
|
||||||
FROM pg_roles
|
|
||||||
WHERE rolname = current_user;
|
|
||||||
```
|
|
||||||
|
|
||||||
Expected values are `1min`, `0`, `0`, and all three privilege flags `false`.
|
|
||||||
@@ -2,5 +2,3 @@ agents:
|
|||||||
- id: demo-2
|
- id: demo-2
|
||||||
description: Demo Agent 2
|
description: Demo Agent 2
|
||||||
phaseType: DieCasting
|
phaseType: DieCasting
|
||||||
databaseUsername: agent_demo_2
|
|
||||||
postgresCredentialsSecret: agent-demo-2-postgres-credentials
|
|
||||||
@@ -14,13 +14,10 @@ images:
|
|||||||
|
|
||||||
sharedInfra:
|
sharedInfra:
|
||||||
postgres:
|
postgres:
|
||||||
adminUsername: postgres
|
username: postgres
|
||||||
|
password: "Admin12345"
|
||||||
port: 5432
|
port: 5432
|
||||||
idleInTransactionSessionTimeout: 60s
|
idleInTransactionSessionTimeout: 60s
|
||||||
credentialsSecret:
|
|
||||||
adminPasswordKey: admin-password
|
|
||||||
appPasswordKey: app-password
|
|
||||||
connectionStringKey: connection-string
|
|
||||||
redis:
|
redis:
|
||||||
host: redis-service
|
host: redis-service
|
||||||
port: 6379
|
port: 6379
|
||||||
|
|||||||
@@ -3,5 +3,3 @@ agents:
|
|||||||
description: Dev Agent
|
description: Dev Agent
|
||||||
phaseType: DieCasting # 工序类型(注入 AGENT_PHASE_TYPE),对应 apphost WithPhaseType
|
phaseType: DieCasting # 工序类型(注入 AGENT_PHASE_TYPE),对应 apphost WithPhaseType
|
||||||
nodeLabel: node1
|
nodeLabel: node1
|
||||||
databaseUsername: agent_dev
|
|
||||||
postgresCredentialsSecret: agent-demo-postgres-credentials
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
namespace="${1:?usage: $0 <namespace> <site> <app-username>}"
|
|
||||||
site="${2:?usage: $0 <namespace> <site> <app-username>}"
|
|
||||||
app_username="${3:?usage: $0 <namespace> <site> <app-username>}"
|
|
||||||
|
|
||||||
: "${AGENT_POSTGRES_ADMIN_PASSWORD:?set AGENT_POSTGRES_ADMIN_PASSWORD}"
|
|
||||||
: "${AGENT_POSTGRES_APP_PASSWORD:?set AGENT_POSTGRES_APP_PASSWORD}"
|
|
||||||
|
|
||||||
database_name="agent-db-${site}"
|
|
||||||
postgres_host="agent-${site}-postgres-service"
|
|
||||||
secret_name="agent-${site}-postgres-credentials"
|
|
||||||
escaped_app_password=${AGENT_POSTGRES_APP_PASSWORD//\"/\"\"}
|
|
||||||
connection_string="Host=${postgres_host};Port=5432;Username=${app_username};Password=\"${escaped_app_password}\";Database=${database_name}"
|
|
||||||
|
|
||||||
credentials_directory=$(mktemp -d)
|
|
||||||
trap 'rm -rf -- "${credentials_directory}"' EXIT
|
|
||||||
chmod 700 "${credentials_directory}"
|
|
||||||
printf '%s' "${AGENT_POSTGRES_ADMIN_PASSWORD}" > "${credentials_directory}/admin-password"
|
|
||||||
printf '%s' "${AGENT_POSTGRES_APP_PASSWORD}" > "${credentials_directory}/app-password"
|
|
||||||
printf '%s' "${connection_string}" > "${credentials_directory}/connection-string"
|
|
||||||
|
|
||||||
kubectl --namespace "${namespace}" create secret generic "${secret_name}" \
|
|
||||||
--from-file=admin-password="${credentials_directory}/admin-password" \
|
|
||||||
--from-file=app-password="${credentials_directory}/app-password" \
|
|
||||||
--from-file=connection-string="${credentials_directory}/connection-string" \
|
|
||||||
--dry-run=client \
|
|
||||||
--output=yaml \
|
|
||||||
| kubectl apply --filename=-
|
|
||||||
|
|
||||||
echo "Updated ${namespace}/${secret_name}; restart the Agent Deployment to consume changed values."
|
|
||||||
Reference in new issue
Block a user