Post by Project Sveltos
818 followers
Static ClusterProfiles handle the steady-state well: deploy these add-ons to these clusters. But some deployment needs are dynamic, they depend on what's ๐ฉ๐ข๐ฑ๐ฑ๐ฆ๐ฏ๐ช๐ฏ๐จ inside the cluster at runtime. Sveltos Event Framework handles this with two resources: ๐๐๐ฒ๐ป๐๐ฆ๐ผ๐๐ฟ๐ฐ๐ฒ (what to watch) and ๐๐๐ฒ๐ป๐๐ง๐ฟ๐ถ๐ด๐ด๐ฒ๐ฟ (what to do). ๐ฆ๐ฐ๐ฒ๐ป๐ฎ๐ฟ๐ถ๐ผ: every time a new namespace is created with label ๐ต๐ฆ๐ข๐ฎ: ๐ฃ๐ข๐ค๐ฌ๐ฆ๐ฏ๐ฅ, automatically deploy a NetworkPolicy isolating that namespace. ๐ฆ๐๐ฒ๐ฝ ๐ญ โ ๐ฑ๐ฒ๐ณ๐ถ๐ป๐ฒ ๐๐ต๐ฒ ๐ฒ๐๐ฒ๐ป๐: ```yaml apiVersion: https://lnkd.in/dA3iUwVH kind: EventSource metadata: ย name: new-backend-namespace spec: ย collectResources: true ย resourceSelectors: ย - group: "" ย ย version: v1 ย ย kind: Namespace ย ย labelFilters: ย ย - key: team ย ย ย operation: Equal ย ย ย value: backend ``` ๐ฆ๐๐ฒ๐ฝ ๐ฎ โ ๐ฑ๐ฒ๐ณ๐ถ๐ป๐ฒ ๐๐ต๐ฒ ๐ฟ๐ฒ๐๐ฝ๐ผ๐ป๐๐ฒ: ```yaml apiVersion: https://lnkd.in/dA3iUwVH kind: EventTrigger metadata: ย name: isolate-backend-namespace spec: ย eventSourceName: new-backend-namespace ย sourceClusterSelector: ย ย matchLabels: ย ย ย env: production ย policyRefs: ย - kind: ConfigMap ย ย name: backend-network-policy ย ย namespace: projectsveltos ย oneForEvent: false ``` The ConfigMap ๐ฃ๐ข๐ค๐ฌ๐ฆ๐ฏ๐ฅ-๐ฏ๐ฆ๐ต๐ธ๐ฐ๐ณ๐ฌ-๐ฑ๐ฐ๐ญ๐ช๐ค๐บ holds the NetworkPolicy manifest, which can itself use templates referencing the triggering namespace: {{ .๐๐ฆ๐ด๐ฐ๐ถ๐ณ๐ค๐ฆ.๐ฎ๐ฆ๐ต๐ข๐ฅ๐ข๐ต๐ข.๐ฏ๐ข๐ฎ๐ฆ }}. When the EventSource fires, Sveltos automatically generates a ClusterProfile scoped to that specific event. No manual reconciliation loop, no custom controller, no Operator SDK. For more complex matching logic, the EventSource evaluation block accepts ๐๐๐ฎ ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ or ๐๐๐ ๐ฒ๐ ๐ฝ๐ฟ๐ฒ๐๐๐ถ๐ผ๐ป๐โ enabling conditions on arbitrary resource fields, cross-field comparisons, or stateful evaluation across multiple resources. The event framework turns cluster state into a trigger. The ClusterProfile machinery handles the rest. https://lnkd.in/dT7cW4jq #Kubernetes #MultiCluster #EventDriven #PlatformEngineering #CloudNative #OpenSource