Skip to content

Commit 5ad09f7

Browse files
committed
Update diagram and examples with clearer naming convention
Improve the architecture flow diagram and YAML examples to avoid confusion about namespaces and ServiceAccount names: Changes: 1. Architecture diagram step 1: Use clearer format - Before: 'namespace: argocd' (ambiguous - SubjectMapping or SA?) - After: 'argocd/argocd-hub-sa → argocd-sa-for-hub' (shows mapping) 2. Update ServiceAccount naming convention: - Before: hub-argocd-sa, hub-admin-user - After: argocd-sa-for-hub, admin-sa-for-hub - Rationale: '-for-hub' suffix is self-documenting and clearer 3. Show correct namespace where managed SA is created: - ServiceAccount created in 'open-cluster-management-agent-addon' namespace on managed clusters (where addon agent runs) - Updated TokenRequest API call to show full path 4. Update step 6 to reference correct token name 5. Clarify ManagedServiceAccount creation bullets to show both the MSA resource location (cluster namespace) and the actual ServiceAccount location (addon namespace) This makes the flow easier to understand and aligns with how managed-serviceaccount addon actually works. Signed-off-by: zhujian <jiazhu@redhat.com>
1 parent 581d52b commit 5ad09f7

1 file changed

Lines changed: 26 additions & 30 deletions

File tree

  • enhancements/sig-architecture/233-subject-mapping

enhancements/sig-architecture/233-subject-mapping/README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ The following diagram illustrates the complete end-to-end flow:
9393
│ │
9494
│ ┌──────────────────────────────────────────────────────────┐ │
9595
│ │ 1. Admin Creates SubjectMapping │ │
96-
│ │ namespace: argocd │ │
97-
│ │ hubServiceAccount: argocd-hub-sa │ │
98-
│ │ managedServiceAccount: argocd-spoke-sa │ │
96+
│ │ argocd-hub-sa → argocd-sa-for-hub │ │
9997
│ └──────────────────────────────────────────────────────────┘ │
10098
│ │ │
10199
│ ▼ │
@@ -104,8 +102,8 @@ The following diagram illustrates the complete end-to-end flow:
104102
│ │ - Finds ManagedClusterSetBinding in argocd namespace │ │
105103
│ │ - Discovers bound clusters (cluster1...cluster100) │ │
106104
│ │ - Creates ManagedServiceAccount in each cluster NS: │ │
107-
│ │ * cluster1/argocd-spoke-sa (MSA in cluster1 NS) │ │
108-
│ │ * cluster2/argocd-spoke-sa (MSA in cluster2 NS) │ │
105+
│ │ * cluster1/argocd-sa-for-hub (MSA in cluster1 NS) │ │
106+
│ │ * cluster2/argocd-sa-for-hub (MSA in cluster2 NS) │ │
109107
│ │ * ... │ │
110108
│ └──────────────────────────────────────────────────────────┘ │
111109
│ │
@@ -133,11 +131,12 @@ The following diagram illustrates the complete end-to-end flow:
133131
│ │ - Receives request via tunnel │ │
134132
│ │ - Detects caller: argocd-hub-sa (from request auth) │ │
135133
│ │ - Looks up mapping in local cache │ │
136-
│ │ argocd/argocd-hub-sa → argocd-spoke-sa │ │
134+
│ │ argocd/argocd-hub-sa → argocd-sa-for-hub │ │
137135
│ │ - Checks token cache (miss) │ │
138136
│ │ - Calls LOCAL TokenRequest API │ │
139-
│ │ POST /api/v1/namespaces/argocd/serviceaccounts/ │ │
140-
│ │ argocd-spoke-sa/token │ │
137+
│ │ POST /api/v1/namespaces/ │ │
138+
│ │ open-cluster-management-agent-addon/ │ │
139+
│ │ serviceaccounts/argocd-sa-for-hub/token │ │
141140
│ │ - Caches token (55 minutes) │ │
142141
│ │ - Injects token into Authorization header │ │
143142
│ │ - Forwards to local API server │ │
@@ -146,7 +145,7 @@ The following diagram illustrates the complete end-to-end flow:
146145
│ ▼ │
147146
│ ┌──────────────────────────────────────────────────────────┐ │
148147
│ │ 6. Kubernetes API Server │ │
149-
│ │ - Receives request with argocd-spoke-sa token │ │
148+
│ │ - Receives request with argocd-sa-for-hub token │ │
150149
│ │ - Processes request │ │
151150
│ │ - Returns response │ │
152151
│ └──────────────────┬───────────────────────────────────────┘ │
@@ -189,12 +188,10 @@ spec:
189188
namespace: argocd
190189
name: argocd-application-controller
191190

192-
# Service account name to create on managed clusters
191+
# Service account to create on managed clusters
193192
managedServiceAccount:
194-
name: hub-argocd-sa
195-
196-
# Token expiration duration (default: 3600 seconds)
197-
tokenExpirationSeconds: 3600
193+
name: argocd-sa-for-hub
194+
tokenExpirationSeconds: 3600 # Token expiration (default: 3600 seconds)
198195
```
199196
200197
**ManagedServiceAccount Creation**:
@@ -203,9 +200,9 @@ The SubjectMapping controller creates ManagedServiceAccount resources in **clust
203200

204201
For this example with 3 bound clusters (via ManagedClusterSetBinding in `argocd` namespace):
205202

206-
- ManagedServiceAccount `cluster1/hub-argocd-sa` → creates ServiceAccount on cluster1
207-
- ManagedServiceAccount `cluster2/hub-argocd-sa` → creates ServiceAccount on cluster2
208-
- ManagedServiceAccount `cluster3/hub-argocd-sa` → creates ServiceAccount on cluster3
203+
- ManagedServiceAccount `cluster1/argocd-sa-for-hub` → creates ServiceAccount `argocd-sa-for-hub` in `open-cluster-management-agent-addon` namespace on cluster1
204+
- ManagedServiceAccount `cluster2/argocd-sa-for-hub` → creates ServiceAccount `argocd-sa-for-hub` in `open-cluster-management-agent-addon` namespace on cluster2
205+
- ManagedServiceAccount `cluster3/argocd-sa-for-hub` → creates ServiceAccount `argocd-sa-for-hub` in `open-cluster-management-agent-addon` namespace on cluster3
209206

210207
**Example 2: User Mapping with Placement (Future)**
211208

@@ -223,13 +220,12 @@ spec:
223220
name: "admin@example.com"
224221
225222
managedServiceAccount:
226-
name: hub-admin-user
223+
name: admin-sa-for-hub
224+
tokenExpirationSeconds: 3600
227225
228226
# Reference a Placement for cluster selection
229227
placementRef:
230228
name: production-clusters
231-
232-
tokenExpirationSeconds: 3600
233229
---
234230
apiVersion: cluster.open-cluster-management.io/v1beta1
235231
kind: Placement
@@ -594,16 +590,6 @@ type SubjectMappingSpec struct {
594590
// Ignored for ServiceAccount subjects (uses ManagedClusterSetBinding instead).
595591
// +optional
596592
PlacementRef *PlacementRef `json:"placementRef,omitempty"`
597-
598-
// TokenExpirationSeconds represents the seconds of a token to expire.
599-
// Default: 3600 (1 hour)
600-
// Minimum: 600 (10 minutes)
601-
// Maximum: 86400 (24 hours)
602-
// +optional
603-
// +kubebuilder:default=3600
604-
// +kubebuilder:validation:Minimum=600
605-
// +kubebuilder:validation:Maximum=86400
606-
TokenExpirationSeconds int64 `json:"tokenExpirationSeconds,omitempty"`
607593
}
608594

609595
// +kubebuilder:validation:XValidation:rule="self.kind == 'ServiceAccount' ? has(self.serviceAccount) : true",message="serviceAccount is required when kind is ServiceAccount"
@@ -662,6 +648,16 @@ type ManagedServiceAccountSpec struct {
662648
// +required
663649
// +kubebuilder:validation:MinLength=1
664650
Name string `json:"name"`
651+
652+
// TokenExpirationSeconds represents the seconds of a token to expire.
653+
// Default: 3600 (1 hour)
654+
// Minimum: 600 (10 minutes)
655+
// Maximum: 86400 (24 hours)
656+
// +optional
657+
// +kubebuilder:default=3600
658+
// +kubebuilder:validation:Minimum=600
659+
// +kubebuilder:validation:Maximum=86400
660+
TokenExpirationSeconds int64 `json:"tokenExpirationSeconds,omitempty"`
665661
}
666662

667663
type SubjectMappingStatus struct {

0 commit comments

Comments
 (0)