blockmine 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/README.md +469 -0
- package/.claude/agents/auth-route-debugger.md +118 -0
- package/.claude/agents/auth-route-tester.md +93 -0
- package/.claude/agents/auto-error-resolver.md +97 -0
- package/.claude/agents/build-optimizer.md +236 -0
- package/.claude/agents/code-architecture-reviewer.md +83 -0
- package/.claude/agents/code-refactor-master.md +94 -0
- package/.claude/agents/cost-optimizer.md +134 -0
- package/.claude/agents/deployment-orchestrator.md +113 -0
- package/.claude/agents/documentation-architect.md +82 -0
- package/.claude/agents/frontend-error-fixer.md +77 -0
- package/.claude/agents/iac-code-generator.md +71 -0
- package/.claude/agents/incident-responder.md +346 -0
- package/.claude/agents/infrastructure-architect.md +31 -0
- package/.claude/agents/kubernetes-specialist.md +56 -0
- package/.claude/agents/migration-planner.md +181 -0
- package/.claude/agents/network-architect.md +196 -0
- package/.claude/agents/plan-reviewer.md +52 -0
- package/.claude/agents/refactor-planner.md +63 -0
- package/.claude/agents/security-scanner.md +102 -0
- package/.claude/agents/web-research-specialist.md +78 -0
- package/.claude/commands/cost-analysis.md +315 -0
- package/.claude/commands/dev-docs-update.md +55 -0
- package/.claude/commands/dev-docs.md +51 -0
- package/.claude/commands/incident-debug.md +247 -0
- package/.claude/commands/infra-plan.md +81 -0
- package/.claude/commands/migration-plan.md +478 -0
- package/.claude/commands/route-research-for-testing.md +37 -0
- package/.claude/commands/security-review.md +66 -0
- package/.claude/hooks/CONFIG.md +448 -0
- package/.claude/hooks/README.md +163 -0
- package/.claude/hooks/SKILL_ACTIVATION_COMPLETE.md +226 -0
- package/.claude/hooks/WINDOWS_HOOKS_README.md +151 -0
- package/.claude/hooks/add-skill-activation-banners.ts +132 -0
- package/.claude/hooks/comprehensive-skill-test.ts +1315 -0
- package/.claude/hooks/error-handling-reminder.sh +12 -0
- package/.claude/hooks/error-handling-reminder.ts +222 -0
- package/.claude/hooks/k8s-manifest-validator.sh +56 -0
- package/.claude/hooks/package-lock.json +556 -0
- package/.claude/hooks/package.json +16 -0
- package/.claude/hooks/post-tool-use-tracker.ps1 +174 -0
- package/.claude/hooks/post-tool-use-tracker.sh +183 -0
- package/.claude/hooks/security-policy-check.sh +247 -0
- package/.claude/hooks/skill-activation-prompt.ps1 +10 -0
- package/.claude/hooks/skill-activation-prompt.sh +10 -0
- package/.claude/hooks/skill-activation-prompt.ts +141 -0
- package/.claude/hooks/stop-build-check-enhanced.sh +130 -0
- package/.claude/hooks/terraform-validator.sh +53 -0
- package/.claude/hooks/test-input.json +7 -0
- package/.claude/hooks/test-skill-activation.ts +427 -0
- package/.claude/hooks/trigger-build-resolver.sh +79 -0
- package/.claude/hooks/tsc-check.sh +173 -0
- package/.claude/hooks/tsconfig.json +19 -0
- package/.claude/settings.json +55 -0
- package/.claude/settings.local.json +28 -3
- package/.claude/skills/README.md +507 -0
- package/.claude/skills/api-engineering/SKILL.md +63 -0
- package/.claude/skills/api-engineering/resources/api-versioning.md +88 -0
- package/.claude/skills/api-engineering/resources/graphql-patterns.md +106 -0
- package/.claude/skills/api-engineering/resources/rate-limiting.md +118 -0
- package/.claude/skills/api-engineering/resources/rest-api-design.md +105 -0
- package/.claude/skills/backend-dev-guidelines/SKILL.md +306 -0
- package/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
- package/.claude/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
- package/.claude/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
- package/.claude/skills/backend-dev-guidelines/resources/configuration.md +275 -0
- package/.claude/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
- package/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
- package/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
- package/.claude/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
- package/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
- package/.claude/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
- package/.claude/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
- package/.claude/skills/budget-and-cost-management/SKILL.md +850 -0
- package/.claude/skills/build-engineering/SKILL.md +431 -0
- package/.claude/skills/build-engineering/resources/artifact-repositories.md +72 -0
- package/.claude/skills/build-engineering/resources/build-caching.md +96 -0
- package/.claude/skills/build-engineering/resources/build-pipelines.md +105 -0
- package/.claude/skills/build-engineering/resources/build-security.md +95 -0
- package/.claude/skills/build-engineering/resources/build-systems.md +389 -0
- package/.claude/skills/build-engineering/resources/compilation-optimization.md +201 -0
- package/.claude/skills/build-engineering/resources/dependency-management.md +73 -0
- package/.claude/skills/build-engineering/resources/monorepo-builds.md +110 -0
- package/.claude/skills/build-engineering/resources/performance-optimization.md +113 -0
- package/.claude/skills/build-engineering/resources/reproducible-builds.md +82 -0
- package/.claude/skills/cloud-engineering/SKILL.md +675 -0
- package/.claude/skills/cloud-engineering/resources/aws-patterns.md +742 -0
- package/.claude/skills/cloud-engineering/resources/azure-patterns.md +714 -0
- package/.claude/skills/cloud-engineering/resources/cleared-cloud-environments.md +987 -0
- package/.claude/skills/cloud-engineering/resources/cloud-cost-optimization.md +757 -0
- package/.claude/skills/cloud-engineering/resources/cloud-networking.md +1058 -0
- package/.claude/skills/cloud-engineering/resources/cloud-security-tools.md +1530 -0
- package/.claude/skills/cloud-engineering/resources/cloud-security.md +990 -0
- package/.claude/skills/cloud-engineering/resources/gcp-patterns.md +758 -0
- package/.claude/skills/cloud-engineering/resources/migration-strategies.md +820 -0
- package/.claude/skills/cloud-engineering/resources/multi-cloud-strategies.md +670 -0
- package/.claude/skills/cloud-engineering/resources/oci-patterns.md +1198 -0
- package/.claude/skills/cloud-engineering/resources/serverless-patterns.md +795 -0
- package/.claude/skills/cloud-engineering/resources/well-architected-frameworks.md +966 -0
- package/.claude/skills/cybersecurity/SKILL.md +409 -0
- package/.claude/skills/cybersecurity/resources/security-architecture.md +266 -0
- package/.claude/skills/database-engineering/SKILL.md +61 -0
- package/.claude/skills/database-engineering/resources/backup-and-recovery.md +72 -0
- package/.claude/skills/database-engineering/resources/database-replication.md +63 -0
- package/.claude/skills/database-engineering/resources/postgresql-fundamentals.md +70 -0
- package/.claude/skills/database-engineering/resources/query-optimization.md +68 -0
- package/.claude/skills/devsecops/SKILL.md +374 -0
- package/.claude/skills/devsecops/resources/ci-cd-security.md +204 -0
- package/.claude/skills/devsecops/resources/compliance-automation.md +530 -0
- package/.claude/skills/devsecops/resources/compliance-frameworks.md +2322 -0
- package/.claude/skills/devsecops/resources/container-security.md +915 -0
- package/.claude/skills/devsecops/resources/cspm-integration.md +1440 -0
- package/.claude/skills/devsecops/resources/policy-enforcement.md +619 -0
- package/.claude/skills/devsecops/resources/secrets-management.md +755 -0
- package/.claude/skills/devsecops/resources/security-monitoring.md +146 -0
- package/.claude/skills/devsecops/resources/security-scanning.md +887 -0
- package/.claude/skills/devsecops/resources/security-testing.md +203 -0
- package/.claude/skills/devsecops/resources/supply-chain-security.md +518 -0
- package/.claude/skills/devsecops/resources/vulnerability-management.md +481 -0
- package/.claude/skills/devsecops/resources/zero-trust-architecture.md +177 -0
- package/.claude/skills/documentation-as-code/SKILL.md +323 -0
- package/.claude/skills/documentation-as-code/resources/api-documentation.md +90 -0
- package/.claude/skills/documentation-as-code/resources/changelog-management.md +79 -0
- package/.claude/skills/documentation-as-code/resources/diagram-generation.md +44 -0
- package/.claude/skills/documentation-as-code/resources/docs-as-code-workflow.md +99 -0
- package/.claude/skills/documentation-as-code/resources/documentation-automation.md +68 -0
- package/.claude/skills/documentation-as-code/resources/documentation-sites.md +79 -0
- package/.claude/skills/documentation-as-code/resources/markdown-best-practices.md +162 -0
- package/.claude/skills/documentation-as-code/resources/openapi-specification.md +77 -0
- package/.claude/skills/documentation-as-code/resources/readme-engineering.md +60 -0
- package/.claude/skills/documentation-as-code/resources/technical-writing-guide.md +202 -0
- package/.claude/skills/engineering-management/SKILL.md +356 -0
- package/.claude/skills/engineering-management/resources/career-ladders.md +609 -0
- package/.claude/skills/engineering-management/resources/hiring-and-assessment.md +555 -0
- package/.claude/skills/engineering-management/resources/one-on-one-guides.md +609 -0
- package/.claude/skills/engineering-management/resources/resource-planning.md +557 -0
- package/.claude/skills/engineering-management/resources/team-organization-patterns.md +491 -0
- package/.claude/skills/engineering-management/resources/technical-interviews.md +474 -0
- package/.claude/skills/engineering-operations-management/SKILL.md +817 -0
- package/.claude/skills/error-tracking/SKILL.md +379 -0
- package/.claude/skills/frontend-dev-guidelines/SKILL.md +403 -0
- package/.claude/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
- package/.claude/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
- package/.claude/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
- package/.claude/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
- package/.claude/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
- package/.claude/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
- package/.claude/skills/frontend-dev-guidelines/resources/performance.md +406 -0
- package/.claude/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
- package/.claude/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
- package/.claude/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
- package/.claude/skills/general-it-engineering/SKILL.md +393 -0
- package/.claude/skills/general-it-engineering/resources/asset-management.md +712 -0
- package/.claude/skills/general-it-engineering/resources/automation-orchestration.md +817 -0
- package/.claude/skills/general-it-engineering/resources/business-continuity.md +786 -0
- package/.claude/skills/general-it-engineering/resources/change-management.md +715 -0
- package/.claude/skills/general-it-engineering/resources/enterprise-monitoring.md +729 -0
- package/.claude/skills/general-it-engineering/resources/help-desk-operations.md +738 -0
- package/.claude/skills/general-it-engineering/resources/incident-service-management.md +834 -0
- package/.claude/skills/general-it-engineering/resources/it-governance.md +753 -0
- package/.claude/skills/general-it-engineering/resources/itil-framework.md +503 -0
- package/.claude/skills/general-it-engineering/resources/service-management.md +669 -0
- package/.claude/skills/infrastructure-architecture/SKILL.md +328 -0
- package/.claude/skills/infrastructure-architecture/resources/architecture-decision-records.md +505 -0
- package/.claude/skills/infrastructure-architecture/resources/architecture-patterns.md +528 -0
- package/.claude/skills/infrastructure-architecture/resources/capacity-planning.md +453 -0
- package/.claude/skills/infrastructure-architecture/resources/cleared-environment-architecture.md +773 -0
- package/.claude/skills/infrastructure-architecture/resources/cost-architecture.md +499 -0
- package/.claude/skills/infrastructure-architecture/resources/data-architecture.md +501 -0
- package/.claude/skills/infrastructure-architecture/resources/disaster-recovery.md +535 -0
- package/.claude/skills/infrastructure-architecture/resources/migration-architecture.md +512 -0
- package/.claude/skills/infrastructure-architecture/resources/multi-region-design.md +608 -0
- package/.claude/skills/infrastructure-architecture/resources/reference-architectures.md +562 -0
- package/.claude/skills/infrastructure-architecture/resources/security-architecture.md +538 -0
- package/.claude/skills/infrastructure-architecture/resources/system-design-principles.md +489 -0
- package/.claude/skills/infrastructure-architecture/resources/workload-classification.md +1000 -0
- package/.claude/skills/infrastructure-strategy/SKILL.md +924 -0
- package/.claude/skills/network-engineering/SKILL.md +385 -0
- package/.claude/skills/network-engineering/resources/dns-management.md +738 -0
- package/.claude/skills/network-engineering/resources/load-balancing.md +820 -0
- package/.claude/skills/network-engineering/resources/network-architecture.md +546 -0
- package/.claude/skills/network-engineering/resources/network-security.md +921 -0
- package/.claude/skills/network-engineering/resources/network-troubleshooting.md +749 -0
- package/.claude/skills/network-engineering/resources/routing-switching.md +373 -0
- package/.claude/skills/network-engineering/resources/sdn-networking.md +695 -0
- package/.claude/skills/network-engineering/resources/service-mesh-networking.md +777 -0
- package/.claude/skills/network-engineering/resources/tcp-ip-protocols.md +444 -0
- package/.claude/skills/network-engineering/resources/vpn-connectivity.md +672 -0
- package/.claude/skills/observability-engineering/SKILL.md +101 -0
- package/.claude/skills/observability-engineering/resources/apm-tools.md +97 -0
- package/.claude/skills/observability-engineering/resources/correlation-strategies.md +87 -0
- package/.claude/skills/observability-engineering/resources/distributed-tracing.md +98 -0
- package/.claude/skills/observability-engineering/resources/logs-aggregation.md +118 -0
- package/.claude/skills/observability-engineering/resources/observability-cost-optimization.md +141 -0
- package/.claude/skills/observability-engineering/resources/opentelemetry.md +110 -0
- package/.claude/skills/platform-engineering/SKILL.md +555 -0
- package/.claude/skills/platform-engineering/resources/architecture-overview.md +600 -0
- package/.claude/skills/platform-engineering/resources/container-orchestration.md +916 -0
- package/.claude/skills/platform-engineering/resources/cost-optimization.md +634 -0
- package/.claude/skills/platform-engineering/resources/developer-platforms.md +670 -0
- package/.claude/skills/platform-engineering/resources/gitops-automation.md +650 -0
- package/.claude/skills/platform-engineering/resources/infrastructure-as-code.md +778 -0
- package/.claude/skills/platform-engineering/resources/infrastructure-standards.md +708 -0
- package/.claude/skills/platform-engineering/resources/multi-tenancy.md +602 -0
- package/.claude/skills/platform-engineering/resources/platform-security.md +711 -0
- package/.claude/skills/platform-engineering/resources/resource-management.md +592 -0
- package/.claude/skills/platform-engineering/resources/service-mesh.md +628 -0
- package/.claude/skills/release-engineering/SKILL.md +393 -0
- package/.claude/skills/release-engineering/resources/artifact-management.md +108 -0
- package/.claude/skills/release-engineering/resources/build-optimization.md +84 -0
- package/.claude/skills/release-engineering/resources/ci-cd-pipelines.md +411 -0
- package/.claude/skills/release-engineering/resources/deployment-strategies.md +197 -0
- package/.claude/skills/release-engineering/resources/pipeline-security.md +62 -0
- package/.claude/skills/release-engineering/resources/progressive-delivery.md +83 -0
- package/.claude/skills/release-engineering/resources/release-automation.md +68 -0
- package/.claude/skills/release-engineering/resources/release-orchestration.md +77 -0
- package/.claude/skills/release-engineering/resources/rollback-strategies.md +66 -0
- package/.claude/skills/release-engineering/resources/versioning-strategies.md +59 -0
- package/.claude/skills/route-tester/SKILL.md +392 -0
- package/.claude/skills/skill-developer/ADVANCED.md +197 -0
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
- package/.claude/skills/skill-developer/SKILL.md +430 -0
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
- package/.claude/skills/skill-rules.json +2940 -0
- package/.claude/skills/sre/SKILL.md +464 -0
- package/.claude/skills/sre/resources/alerting-best-practices.md +282 -0
- package/.claude/skills/sre/resources/capacity-planning.md +226 -0
- package/.claude/skills/sre/resources/chaos-engineering.md +193 -0
- package/.claude/skills/sre/resources/disaster-recovery.md +232 -0
- package/.claude/skills/sre/resources/incident-management.md +436 -0
- package/.claude/skills/sre/resources/observability-stack.md +240 -0
- package/.claude/skills/sre/resources/on-call-runbooks.md +167 -0
- package/.claude/skills/sre/resources/performance-optimization.md +108 -0
- package/.claude/skills/sre/resources/reliability-patterns.md +183 -0
- package/.claude/skills/sre/resources/slo-sli-sla.md +464 -0
- package/.claude/skills/sre/resources/toil-reduction.md +145 -0
- package/.claude/skills/systems-engineering/SKILL.md +648 -0
- package/.claude/skills/systems-engineering/resources/automation-patterns.md +771 -0
- package/.claude/skills/systems-engineering/resources/configuration-management.md +998 -0
- package/.claude/skills/systems-engineering/resources/linux-administration.md +672 -0
- package/.claude/skills/systems-engineering/resources/networking-fundamentals.md +982 -0
- package/.claude/skills/systems-engineering/resources/performance-tuning.md +871 -0
- package/.claude/skills/systems-engineering/resources/powershell-scripting.md +482 -0
- package/.claude/skills/systems-engineering/resources/security-hardening.md +739 -0
- package/.claude/skills/systems-engineering/resources/shell-scripting.md +915 -0
- package/.claude/skills/systems-engineering/resources/storage-management.md +628 -0
- package/.claude/skills/systems-engineering/resources/system-monitoring.md +787 -0
- package/.claude/skills/systems-engineering/resources/troubleshooting-guide.md +753 -0
- package/.claude/skills/systems-engineering/resources/windows-administration.md +738 -0
- package/.claude/skills/technical-leadership/SKILL.md +728 -0
- package/CHANGELOG.md +90 -39
- package/README.md +94 -0
- package/backend/docs/SECRETS_DOCUMENTATION.md +327 -0
- package/backend/jest.config.js +59 -0
- package/backend/package-lock.json +6129 -0
- package/backend/package.json +16 -4
- package/backend/prisma/migrations/20251026104609_add_websocket_api/migration.sql +33 -0
- package/backend/prisma/schema.prisma +33 -0
- package/backend/src/__tests__/core/DependencyService.test.js +336 -0
- package/backend/src/__tests__/core/UserService.test.js +875 -0
- package/backend/src/__tests__/repositories/BaseRepository.test.js +146 -0
- package/backend/src/__tests__/repositories/BotRepository.test.js +118 -0
- package/backend/src/__tests__/repositories/CommandRepository.test.js +132 -0
- package/backend/src/__tests__/repositories/EventGraphRepository.test.js +93 -0
- package/backend/src/__tests__/repositories/GroupRepository.test.js +155 -0
- package/backend/src/__tests__/repositories/PermissionRepository.test.js +130 -0
- package/backend/src/__tests__/repositories/PluginRepository.test.js +107 -0
- package/backend/src/__tests__/repositories/ServerRepository.test.js +80 -0
- package/backend/src/__tests__/repositories/UserRepository.test.js +128 -0
- package/backend/src/__tests__/secretsFilter.test.js +425 -0
- package/backend/src/__tests__/services/BotLifecycleService.test.js +411 -0
- package/backend/src/__tests__/services/BotProcessManager.test.js +285 -0
- package/backend/src/__tests__/services/CacheManager.test.js +125 -0
- package/backend/src/__tests__/services/CommandExecutionService.test.js +460 -0
- package/backend/src/__tests__/services/ResourceMonitorService.test.js +207 -0
- package/backend/src/__tests__/services/TelemetryService.test.js +291 -0
- package/backend/src/__tests__/setup.js +25 -0
- package/backend/src/api/routes/apiKeys.js +181 -0
- package/backend/src/api/routes/bots.js +49 -7
- package/backend/src/api/routes/plugins.js +2 -1
- package/backend/src/api/routes/system.js +174 -0
- package/backend/src/container.js +82 -0
- package/backend/src/core/BotManager.js +142 -871
- package/backend/src/core/BotManager.old.js +1093 -0
- package/backend/src/core/BotProcess.js +1092 -850
- package/backend/src/core/BreakLoopSignal.js +8 -0
- package/backend/src/core/EventGraphManager.js +280 -193
- package/backend/src/core/GraphExecutionEngine.js +321 -928
- package/backend/src/core/MessageQueue.js +27 -6
- package/backend/src/core/NodeRegistry.js +37 -991
- package/backend/src/core/PluginManager.js +62 -12
- package/backend/src/core/PrismaService.js +32 -0
- package/backend/src/core/UserService.js +3 -3
- package/backend/src/core/__tests__/PrismaService.test.js +24 -0
- package/backend/src/core/commands/README.md +305 -0
- package/backend/src/core/commands/dev.js +13 -7
- package/backend/src/core/commands/ping.js +10 -4
- package/backend/src/core/commands/whois.js +63 -0
- package/backend/src/core/config/validation.js +27 -0
- package/backend/src/core/constants/graphTypes.js +21 -0
- package/backend/src/core/node-registries/actions.js +132 -0
- package/backend/src/core/node-registries/arrays.js +137 -0
- package/backend/src/core/node-registries/bot.js +23 -0
- package/backend/src/core/node-registries/data.js +290 -0
- package/backend/src/core/node-registries/debug.js +26 -0
- package/backend/src/core/node-registries/events.js +187 -0
- package/backend/src/core/node-registries/flow.js +139 -0
- package/backend/src/core/node-registries/logic.js +45 -0
- package/backend/src/core/node-registries/math.js +42 -0
- package/backend/src/core/node-registries/objects.js +98 -0
- package/backend/src/core/node-registries/strings.js +153 -0
- package/backend/src/core/node-registries/time.js +113 -0
- package/backend/src/core/node-registries/users.js +79 -0
- package/backend/src/core/nodes/actions/bot_look_at.js +36 -0
- package/backend/src/core/nodes/actions/bot_set_variable.js +32 -0
- package/backend/src/core/nodes/actions/http_request.js +98 -0
- package/backend/src/core/nodes/actions/send_log.js +28 -0
- package/backend/src/core/nodes/actions/send_message.js +32 -0
- package/backend/src/core/nodes/actions/send_websocket_response.js +33 -0
- package/backend/src/core/nodes/arrays/add_element.js +23 -0
- package/backend/src/core/nodes/arrays/contains.js +40 -0
- package/backend/src/core/nodes/arrays/find_index.js +23 -0
- package/backend/src/core/nodes/arrays/get_by_index.js +23 -0
- package/backend/src/core/nodes/arrays/get_next.js +35 -0
- package/backend/src/core/nodes/arrays/get_random_element.js +32 -0
- package/backend/src/core/nodes/arrays/remove_by_index.js +30 -0
- package/backend/src/core/nodes/bot/get_position.js +20 -0
- package/backend/src/core/nodes/data/array_literal.js +31 -0
- package/backend/src/core/nodes/data/boolean_literal.js +21 -0
- package/backend/src/core/nodes/data/cast.js +42 -0
- package/backend/src/core/nodes/data/datetime_literal.js +27 -0
- package/backend/src/core/nodes/data/entity_info.js +69 -0
- package/backend/src/core/nodes/data/get_argument.js +23 -0
- package/backend/src/core/nodes/data/get_bot_look.js +14 -0
- package/backend/src/core/nodes/data/get_entity_field.js +18 -0
- package/backend/src/core/nodes/data/get_nearby_entities.js +32 -0
- package/backend/src/core/nodes/data/get_nearby_players.js +64 -0
- package/backend/src/core/nodes/data/get_server_players.js +18 -0
- package/backend/src/core/nodes/data/get_user_field.js +40 -0
- package/backend/src/core/nodes/data/get_variable.js +23 -0
- package/backend/src/core/nodes/data/length.js +25 -0
- package/backend/src/core/nodes/data/make_object.js +31 -0
- package/backend/src/core/nodes/data/number_literal.js +21 -0
- package/backend/src/core/nodes/data/string_literal.js +34 -0
- package/backend/src/core/nodes/data/type_check.js +53 -0
- package/backend/src/core/nodes/debug/log.js +16 -0
- package/backend/src/core/nodes/flow/branch.js +15 -0
- package/backend/src/core/nodes/flow/break.js +14 -0
- package/backend/src/core/nodes/flow/delay.js +43 -0
- package/backend/src/core/nodes/flow/for_each.js +39 -0
- package/backend/src/core/nodes/flow/sequence.js +16 -0
- package/backend/src/core/nodes/flow/switch.js +47 -0
- package/backend/src/core/nodes/flow/while.js +64 -0
- package/backend/src/core/nodes/logic/__tests__/compare.test.js +83 -0
- package/backend/src/core/nodes/logic/compare.js +33 -0
- package/backend/src/core/nodes/logic/operation.js +35 -0
- package/backend/src/core/nodes/math/__tests__/operation.test.js +65 -0
- package/backend/src/core/nodes/math/operation.js +31 -0
- package/backend/src/core/nodes/math/random_number.js +43 -0
- package/backend/src/core/nodes/objects/create.js +40 -0
- package/backend/src/core/nodes/objects/delete.js +26 -0
- package/backend/src/core/nodes/objects/get.js +23 -0
- package/backend/src/core/nodes/objects/has_key.js +30 -0
- package/backend/src/core/nodes/objects/set.js +27 -0
- package/backend/src/core/nodes/strings/__tests__/concat.test.js +89 -0
- package/backend/src/core/nodes/strings/concat.js +27 -0
- package/backend/src/core/nodes/strings/contains.js +41 -0
- package/backend/src/core/nodes/strings/ends_with.js +43 -0
- package/backend/src/core/nodes/strings/equals.js +36 -0
- package/backend/src/core/nodes/strings/length.js +36 -0
- package/backend/src/core/nodes/strings/matches.js +39 -0
- package/backend/src/core/nodes/strings/split.js +37 -0
- package/backend/src/core/nodes/strings/starts_with.js +43 -0
- package/backend/src/core/nodes/time/__tests__/now.test.js +24 -0
- package/backend/src/core/nodes/time/add.js +33 -0
- package/backend/src/core/nodes/time/compare.js +35 -0
- package/backend/src/core/nodes/time/diff.js +29 -0
- package/backend/src/core/nodes/time/format.js +32 -0
- package/backend/src/core/nodes/time/now.js +18 -0
- package/backend/src/core/nodes/users/check_blacklist.js +37 -0
- package/backend/src/core/nodes/users/get_groups.js +36 -0
- package/backend/src/core/nodes/users/get_permissions.js +36 -0
- package/backend/src/core/nodes/users/set_blacklist.js +37 -0
- package/backend/src/core/services/BotLifecycleService.js +596 -0
- package/backend/src/core/services/BotProcessManager.js +163 -0
- package/backend/src/core/services/CacheManager.js +111 -0
- package/backend/src/core/services/CommandExecutionService.js +351 -0
- package/backend/src/core/services/ResourceMonitorService.js +90 -0
- package/backend/src/core/services/TelemetryService.js +124 -0
- package/backend/src/core/services/ValidationService.js +132 -0
- package/backend/src/core/services/__tests__/ValidationService.test.js +148 -0
- package/backend/src/core/services.js +20 -5
- package/backend/src/core/system/CommandContext.js +84 -0
- package/backend/src/core/system/Transport.js +78 -0
- package/backend/src/core/utils/__tests__/jsonParser.test.js +44 -0
- package/backend/src/core/utils/jsonParser.js +18 -0
- package/backend/src/core/utils/secretsFilter.js +262 -0
- package/backend/src/core/utils/variableParser.js +89 -0
- package/backend/src/core/validation/__tests__/nodeSchemas.test.js +175 -0
- package/backend/src/core/validation/nodeSchemas.js +112 -0
- package/backend/src/lib/prisma.js +2 -4
- package/backend/src/real-time/botApi/handlers/commandHandlers.js +28 -0
- package/backend/src/real-time/botApi/handlers/graphHandlers.js +99 -0
- package/backend/src/real-time/botApi/handlers/graphWebSocketHandlers.js +147 -0
- package/backend/src/real-time/botApi/handlers/index.js +43 -0
- package/backend/src/real-time/botApi/handlers/messageHandlers.js +66 -0
- package/backend/src/real-time/botApi/handlers/statusHandlers.js +17 -0
- package/backend/src/real-time/botApi/handlers/userHandlers.js +141 -0
- package/backend/src/real-time/botApi/index.js +40 -0
- package/backend/src/real-time/botApi/middleware.js +79 -0
- package/backend/src/real-time/botApi/utils.js +54 -0
- package/backend/src/real-time/socketHandler.js +6 -2
- package/backend/src/repositories/BaseRepository.js +43 -0
- package/backend/src/repositories/BotRepository.js +42 -0
- package/backend/src/repositories/CommandRepository.js +53 -0
- package/backend/src/repositories/EventGraphRepository.js +40 -0
- package/backend/src/repositories/GroupRepository.js +69 -0
- package/backend/src/repositories/PermissionRepository.js +48 -0
- package/backend/src/repositories/PluginRepository.js +42 -0
- package/backend/src/repositories/ServerRepository.js +27 -0
- package/backend/src/repositories/UserRepository.js +48 -0
- package/backend/src/server.js +3 -0
- package/backend/src/test-refactor.js +85 -0
- package/frontend/dist/assets/index-CfTo92bP.css +1 -0
- package/frontend/dist/assets/index-CiFD5X9Z.js +8344 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/package.json +1 -5
- package/package.json +2 -1
- package/frontend/dist/assets/index-BFd7YoAj.css +0 -1
- package/frontend/dist/assets/index-CMMutadc.js +0 -8352
- package/nul +0 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
# Software-Defined Networking (SDN)
|
|
2
|
+
|
|
3
|
+
Comprehensive guide to software-defined networking covering SDN architecture, network overlays, Kubernetes CNI plugins (Calico, Cilium), network policies, and modern networking paradigms.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Overview](#overview)
|
|
8
|
+
- [SDN Architecture](#sdn-architecture)
|
|
9
|
+
- [Network Overlays](#network-overlays)
|
|
10
|
+
- [Kubernetes CNI](#kubernetes-cni)
|
|
11
|
+
- [Calico](#calico)
|
|
12
|
+
- [Cilium](#cilium)
|
|
13
|
+
- [Flannel](#flannel)
|
|
14
|
+
- [Network Policies](#network-policies)
|
|
15
|
+
- [Service Discovery](#service-discovery)
|
|
16
|
+
- [Best Practices](#best-practices)
|
|
17
|
+
- [Anti-Patterns](#anti-patterns)
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
Software-Defined Networking (SDN) separates the control plane from the data plane, enabling programmatic network management and dynamic configuration.
|
|
22
|
+
|
|
23
|
+
**Key Benefits:**
|
|
24
|
+
- Centralized network control
|
|
25
|
+
- Dynamic configuration
|
|
26
|
+
- Programmable networks
|
|
27
|
+
- Vendor independence
|
|
28
|
+
- Automation and orchestration
|
|
29
|
+
|
|
30
|
+
## SDN Architecture
|
|
31
|
+
|
|
32
|
+
### Traditional vs SDN
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Traditional Network: SDN Network:
|
|
36
|
+
┌─────────────────┐ ┌─────────────────┐
|
|
37
|
+
│ Control Plane │ │ SDN Controller │
|
|
38
|
+
│ (Routing) │ │ (Centralized) │
|
|
39
|
+
└────────┬────────┘ └────────┬────────┘
|
|
40
|
+
│ │
|
|
41
|
+
┌────▼─────┐ │ API
|
|
42
|
+
│ Switch 1 │ ┌──────┴──────┐
|
|
43
|
+
└──────────┘ │ │
|
|
44
|
+
┌─────▼──┐ ┌─────▼──┐
|
|
45
|
+
│Switch 1│ │Switch 2│
|
|
46
|
+
│(Data) │ │(Data) │
|
|
47
|
+
└────────┘ └────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### SDN Layers
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
┌─────────────────────────────────────┐
|
|
54
|
+
│ Application Layer │
|
|
55
|
+
│ (Network apps, orchestration) │
|
|
56
|
+
├─────────────────────────────────────┤
|
|
57
|
+
│ Control Layer │
|
|
58
|
+
│ (SDN controller, network logic) │
|
|
59
|
+
├─────────────────────────────────────┤
|
|
60
|
+
│ Infrastructure Layer │
|
|
61
|
+
│ (Physical/virtual network devices) │
|
|
62
|
+
└─────────────────────────────────────┘
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Network Overlays
|
|
66
|
+
|
|
67
|
+
### VXLAN (Virtual Extensible LAN)
|
|
68
|
+
|
|
69
|
+
**Characteristics:**
|
|
70
|
+
- Layer 2 over Layer 3 tunneling
|
|
71
|
+
- 24-bit VNID (16M networks)
|
|
72
|
+
- UDP encapsulation (port 4789)
|
|
73
|
+
- Multi-tenancy support
|
|
74
|
+
|
|
75
|
+
**VXLAN Frame:**
|
|
76
|
+
```
|
|
77
|
+
┌────────────────────────────────────────┐
|
|
78
|
+
│ Outer Ethernet Header │
|
|
79
|
+
├────────────────────────────────────────┤
|
|
80
|
+
│ Outer IP Header │
|
|
81
|
+
├────────────────────────────────────────┤
|
|
82
|
+
│ Outer UDP Header (port 4789) │
|
|
83
|
+
├────────────────────────────────────────┤
|
|
84
|
+
│ VXLAN Header (VNI) │
|
|
85
|
+
├────────────────────────────────────────┤
|
|
86
|
+
│ Inner Ethernet Header │
|
|
87
|
+
├────────────────────────────────────────┤
|
|
88
|
+
│ Inner IP Header │
|
|
89
|
+
├────────────────────────────────────────┤
|
|
90
|
+
│ Payload │
|
|
91
|
+
└────────────────────────────────────────┘
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Configuration Example:**
|
|
95
|
+
```bash
|
|
96
|
+
# Create VXLAN interface
|
|
97
|
+
ip link add vxlan0 type vxlan \
|
|
98
|
+
id 100 \
|
|
99
|
+
dev eth0 \
|
|
100
|
+
dstport 4789 \
|
|
101
|
+
local 10.0.1.10
|
|
102
|
+
|
|
103
|
+
# Assign IP address
|
|
104
|
+
ip addr add 192.168.100.1/24 dev vxlan0
|
|
105
|
+
|
|
106
|
+
# Bring up interface
|
|
107
|
+
ip link set vxlan0 up
|
|
108
|
+
|
|
109
|
+
# Add remote endpoint
|
|
110
|
+
bridge fdb append 00:00:00:00:00:00 dev vxlan0 dst 10.0.1.20
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### GENEVE (Generic Network Virtualization Encapsulation)
|
|
114
|
+
|
|
115
|
+
**Advantages over VXLAN:**
|
|
116
|
+
- Flexible option TLVs
|
|
117
|
+
- Better extensibility
|
|
118
|
+
- Standardized by IETF
|
|
119
|
+
|
|
120
|
+
### GRE (Generic Routing Encapsulation)
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Create GRE tunnel
|
|
124
|
+
ip tunnel add gre1 mode gre \
|
|
125
|
+
remote 203.0.113.20 \
|
|
126
|
+
local 203.0.113.10 \
|
|
127
|
+
ttl 255
|
|
128
|
+
|
|
129
|
+
ip addr add 10.10.10.1/30 dev gre1
|
|
130
|
+
ip link set gre1 up
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Kubernetes CNI
|
|
134
|
+
|
|
135
|
+
### Container Network Interface (CNI)
|
|
136
|
+
|
|
137
|
+
**CNI Plugin Workflow:**
|
|
138
|
+
```
|
|
139
|
+
1. Kubernetes creates pod
|
|
140
|
+
2. Calls CNI plugin ADD command
|
|
141
|
+
3. CNI plugin:
|
|
142
|
+
- Assigns IP address
|
|
143
|
+
- Creates network interface
|
|
144
|
+
- Sets up routes
|
|
145
|
+
- Configures network policies
|
|
146
|
+
4. Returns network config to Kubernetes
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CNI Configuration
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"cniVersion": "0.4.0",
|
|
154
|
+
"name": "k8s-pod-network",
|
|
155
|
+
"plugins": [
|
|
156
|
+
{
|
|
157
|
+
"type": "calico",
|
|
158
|
+
"log_level": "info",
|
|
159
|
+
"datastore_type": "kubernetes",
|
|
160
|
+
"nodename": "node1",
|
|
161
|
+
"ipam": {
|
|
162
|
+
"type": "calico-ipam"
|
|
163
|
+
},
|
|
164
|
+
"policy": {
|
|
165
|
+
"type": "k8s"
|
|
166
|
+
},
|
|
167
|
+
"kubernetes": {
|
|
168
|
+
"kubeconfig": "/etc/cni/net.d/calico-kubeconfig"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"type": "portmap",
|
|
173
|
+
"capabilities": {"portMappings": true}
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Calico
|
|
180
|
+
|
|
181
|
+
### Architecture
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
┌────────────────────────────────────────┐
|
|
185
|
+
│ Calico Components │
|
|
186
|
+
├────────────────────────────────────────┤
|
|
187
|
+
│ Felix (Agent on each node) │
|
|
188
|
+
│ - Routing, ACLs, policy enforcement │
|
|
189
|
+
├────────────────────────────────────────┤
|
|
190
|
+
│ BIRD (BGP client) │
|
|
191
|
+
│ - Route distribution │
|
|
192
|
+
├────────────────────────────────────────┤
|
|
193
|
+
│ Confd (Config manager) │
|
|
194
|
+
│ - Monitors datastore, updates config │
|
|
195
|
+
├────────────────────────────────────────┤
|
|
196
|
+
│ Typha (Optional) │
|
|
197
|
+
│ - Scaling component for large clusters│
|
|
198
|
+
└────────────────────────────────────────┘
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Installation
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
# Install Calico operator
|
|
205
|
+
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/tigera-operator.yaml
|
|
206
|
+
|
|
207
|
+
# Configure Calico
|
|
208
|
+
apiVersion: operator.tigera.io/v1
|
|
209
|
+
kind: Installation
|
|
210
|
+
metadata:
|
|
211
|
+
name: default
|
|
212
|
+
spec:
|
|
213
|
+
calicoNetwork:
|
|
214
|
+
ipPools:
|
|
215
|
+
- blockSize: 26
|
|
216
|
+
cidr: 192.168.0.0/16
|
|
217
|
+
encapsulation: VXLANCrossSubnet
|
|
218
|
+
natOutgoing: Enabled
|
|
219
|
+
nodeSelector: all()
|
|
220
|
+
registry: quay.io/
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### IP Pool Configuration
|
|
224
|
+
|
|
225
|
+
```yaml
|
|
226
|
+
apiVersion: crd.projectcalico.org/v1
|
|
227
|
+
kind: IPPool
|
|
228
|
+
metadata:
|
|
229
|
+
name: default-ipv4-ippool
|
|
230
|
+
spec:
|
|
231
|
+
cidr: 192.168.0.0/16
|
|
232
|
+
blockSize: 26
|
|
233
|
+
ipipMode: Never
|
|
234
|
+
vxlanMode: CrossSubnet
|
|
235
|
+
natOutgoing: true
|
|
236
|
+
nodeSelector: all()
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### BGP Configuration
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
# BGP peer configuration
|
|
243
|
+
apiVersion: crd.projectcalico.org/v1
|
|
244
|
+
kind: BGPPeer
|
|
245
|
+
metadata:
|
|
246
|
+
name: rack1-tor
|
|
247
|
+
spec:
|
|
248
|
+
peerIP: 10.0.1.1
|
|
249
|
+
asNumber: 65001
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
# Node-specific BGP config
|
|
253
|
+
apiVersion: crd.projectcalico.org/v1
|
|
254
|
+
kind: BGPConfiguration
|
|
255
|
+
metadata:
|
|
256
|
+
name: default
|
|
257
|
+
spec:
|
|
258
|
+
logSeverityScreen: Info
|
|
259
|
+
nodeToNodeMeshEnabled: true
|
|
260
|
+
asNumber: 64512
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Network Policies
|
|
264
|
+
|
|
265
|
+
```yaml
|
|
266
|
+
# Deny all ingress
|
|
267
|
+
apiVersion: crd.projectcalico.org/v1
|
|
268
|
+
kind: GlobalNetworkPolicy
|
|
269
|
+
metadata:
|
|
270
|
+
name: deny-all-ingress
|
|
271
|
+
spec:
|
|
272
|
+
order: 1000
|
|
273
|
+
selector: all()
|
|
274
|
+
types:
|
|
275
|
+
- Ingress
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
# Allow DNS
|
|
279
|
+
apiVersion: crd.projectcalico.org/v1
|
|
280
|
+
kind: GlobalNetworkPolicy
|
|
281
|
+
metadata:
|
|
282
|
+
name: allow-dns
|
|
283
|
+
spec:
|
|
284
|
+
order: 100
|
|
285
|
+
selector: all()
|
|
286
|
+
types:
|
|
287
|
+
- Egress
|
|
288
|
+
egress:
|
|
289
|
+
- action: Allow
|
|
290
|
+
protocol: UDP
|
|
291
|
+
destination:
|
|
292
|
+
selector: k8s-app == "kube-dns"
|
|
293
|
+
ports:
|
|
294
|
+
- 53
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
# Allow specific service communication
|
|
298
|
+
apiVersion: crd.projectcalico.org/v1
|
|
299
|
+
kind: NetworkPolicy
|
|
300
|
+
metadata:
|
|
301
|
+
name: allow-frontend-to-backend
|
|
302
|
+
namespace: production
|
|
303
|
+
spec:
|
|
304
|
+
selector: app == "backend"
|
|
305
|
+
types:
|
|
306
|
+
- Ingress
|
|
307
|
+
ingress:
|
|
308
|
+
- action: Allow
|
|
309
|
+
protocol: TCP
|
|
310
|
+
source:
|
|
311
|
+
selector: app == "frontend"
|
|
312
|
+
destination:
|
|
313
|
+
ports:
|
|
314
|
+
- 8080
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Cilium
|
|
318
|
+
|
|
319
|
+
### Architecture
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
┌────────────────────────────────────────┐
|
|
323
|
+
│ Cilium Components │
|
|
324
|
+
├────────────────────────────────────────┤
|
|
325
|
+
│ Cilium Agent │
|
|
326
|
+
│ - eBPF program management │
|
|
327
|
+
│ - Policy enforcement │
|
|
328
|
+
├────────────────────────────────────────┤
|
|
329
|
+
│ Cilium Operator │
|
|
330
|
+
│ - Cluster-wide operations │
|
|
331
|
+
│ - IPAM, CEP garbage collection │
|
|
332
|
+
├────────────────────────────────────────┤
|
|
333
|
+
│ Hubble (Optional) │
|
|
334
|
+
│ - Observability, service map │
|
|
335
|
+
└────────────────────────────────────────┘
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Installation with Helm
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# Add Cilium helm repo
|
|
342
|
+
helm repo add cilium https://helm.cilium.io/
|
|
343
|
+
|
|
344
|
+
# Install Cilium
|
|
345
|
+
helm install cilium cilium/cilium \
|
|
346
|
+
--version 1.14.0 \
|
|
347
|
+
--namespace kube-system \
|
|
348
|
+
--set ipam.mode=kubernetes \
|
|
349
|
+
--set kubeProxyReplacement=strict \
|
|
350
|
+
--set hubble.relay.enabled=true \
|
|
351
|
+
--set hubble.ui.enabled=true
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Cilium Network Policy
|
|
355
|
+
|
|
356
|
+
```yaml
|
|
357
|
+
# L3/L4 policy
|
|
358
|
+
apiVersion: cilium.io/v2
|
|
359
|
+
kind: CiliumNetworkPolicy
|
|
360
|
+
metadata:
|
|
361
|
+
name: allow-frontend-to-backend
|
|
362
|
+
namespace: production
|
|
363
|
+
spec:
|
|
364
|
+
endpointSelector:
|
|
365
|
+
matchLabels:
|
|
366
|
+
app: backend
|
|
367
|
+
ingress:
|
|
368
|
+
- fromEndpoints:
|
|
369
|
+
- matchLabels:
|
|
370
|
+
app: frontend
|
|
371
|
+
toPorts:
|
|
372
|
+
- ports:
|
|
373
|
+
- port: "8080"
|
|
374
|
+
protocol: TCP
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
# L7 HTTP policy
|
|
378
|
+
apiVersion: cilium.io/v2
|
|
379
|
+
kind: CiliumNetworkPolicy
|
|
380
|
+
metadata:
|
|
381
|
+
name: l7-http-policy
|
|
382
|
+
namespace: production
|
|
383
|
+
spec:
|
|
384
|
+
endpointSelector:
|
|
385
|
+
matchLabels:
|
|
386
|
+
app: api
|
|
387
|
+
ingress:
|
|
388
|
+
- fromEndpoints:
|
|
389
|
+
- matchLabels:
|
|
390
|
+
app: frontend
|
|
391
|
+
toPorts:
|
|
392
|
+
- ports:
|
|
393
|
+
- port: "80"
|
|
394
|
+
protocol: TCP
|
|
395
|
+
rules:
|
|
396
|
+
http:
|
|
397
|
+
- method: "GET"
|
|
398
|
+
path: "/api/v1/.*"
|
|
399
|
+
- method: "POST"
|
|
400
|
+
path: "/api/v1/users"
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
# DNS-aware policy
|
|
404
|
+
apiVersion: cilium.io/v2
|
|
405
|
+
kind: CiliumNetworkPolicy
|
|
406
|
+
metadata:
|
|
407
|
+
name: allow-external-api
|
|
408
|
+
namespace: production
|
|
409
|
+
spec:
|
|
410
|
+
endpointSelector:
|
|
411
|
+
matchLabels:
|
|
412
|
+
app: backend
|
|
413
|
+
egress:
|
|
414
|
+
- toFQDNs:
|
|
415
|
+
- matchName: "api.github.com"
|
|
416
|
+
- matchPattern: "*.amazonaws.com"
|
|
417
|
+
- toEndpoints:
|
|
418
|
+
- matchLabels:
|
|
419
|
+
"k8s:io.kubernetes.pod.namespace": kube-system
|
|
420
|
+
"k8s:k8s-app": kube-dns
|
|
421
|
+
toPorts:
|
|
422
|
+
- ports:
|
|
423
|
+
- port: "53"
|
|
424
|
+
protocol: UDP
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Hubble Observability
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Install Hubble CLI
|
|
431
|
+
curl -L https://github.com/cilium/hubble/releases/latest/download/hubble-linux-amd64.tar.gz | tar xz
|
|
432
|
+
sudo mv hubble /usr/local/bin
|
|
433
|
+
|
|
434
|
+
# Enable port-forward to Hubble relay
|
|
435
|
+
kubectl port-forward -n kube-system svc/hubble-relay 4245:80
|
|
436
|
+
|
|
437
|
+
# Observe flows
|
|
438
|
+
hubble observe
|
|
439
|
+
|
|
440
|
+
# Filter by pod
|
|
441
|
+
hubble observe --pod production/frontend
|
|
442
|
+
|
|
443
|
+
# Filter by verdict
|
|
444
|
+
hubble observe --verdict DROPPED
|
|
445
|
+
|
|
446
|
+
# Service map
|
|
447
|
+
hubble observe --http-status
|
|
448
|
+
|
|
449
|
+
# Top connections
|
|
450
|
+
hubble observe --last 1000 -o jsonpb | \
|
|
451
|
+
jq -r '.flow | "\(.source.namespace)/\(.source.pod_name) -> \(.destination.namespace)/\(.destination.pod_name)"' | \
|
|
452
|
+
sort | uniq -c | sort -rn
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Flannel
|
|
456
|
+
|
|
457
|
+
### Configuration
|
|
458
|
+
|
|
459
|
+
```yaml
|
|
460
|
+
apiVersion: v1
|
|
461
|
+
kind: ConfigMap
|
|
462
|
+
metadata:
|
|
463
|
+
name: kube-flannel-cfg
|
|
464
|
+
namespace: kube-system
|
|
465
|
+
data:
|
|
466
|
+
net-conf.json: |
|
|
467
|
+
{
|
|
468
|
+
"Network": "10.244.0.0/16",
|
|
469
|
+
"Backend": {
|
|
470
|
+
"Type": "vxlan",
|
|
471
|
+
"Port": 8472
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Backend Types
|
|
477
|
+
|
|
478
|
+
**VXLAN:**
|
|
479
|
+
```json
|
|
480
|
+
{
|
|
481
|
+
"Backend": {
|
|
482
|
+
"Type": "vxlan",
|
|
483
|
+
"Port": 8472,
|
|
484
|
+
"VNI": 1
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Host-GW (No overlay):**
|
|
490
|
+
```json
|
|
491
|
+
{
|
|
492
|
+
"Backend": {
|
|
493
|
+
"Type": "host-gw"
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**WireGuard:**
|
|
499
|
+
```json
|
|
500
|
+
{
|
|
501
|
+
"Backend": {
|
|
502
|
+
"Type": "wireguard",
|
|
503
|
+
"PersistentKeepalive": 25,
|
|
504
|
+
"ListenPort": 51820
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## Network Policies
|
|
510
|
+
|
|
511
|
+
### Default Deny All
|
|
512
|
+
|
|
513
|
+
```yaml
|
|
514
|
+
apiVersion: networking.k8s.io/v1
|
|
515
|
+
kind: NetworkPolicy
|
|
516
|
+
metadata:
|
|
517
|
+
name: default-deny-all
|
|
518
|
+
namespace: production
|
|
519
|
+
spec:
|
|
520
|
+
podSelector: {}
|
|
521
|
+
policyTypes:
|
|
522
|
+
- Ingress
|
|
523
|
+
- Egress
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### Allow All Egress
|
|
527
|
+
|
|
528
|
+
```yaml
|
|
529
|
+
apiVersion: networking.k8s.io/v1
|
|
530
|
+
kind: NetworkPolicy
|
|
531
|
+
metadata:
|
|
532
|
+
name: allow-all-egress
|
|
533
|
+
namespace: production
|
|
534
|
+
spec:
|
|
535
|
+
podSelector: {}
|
|
536
|
+
policyTypes:
|
|
537
|
+
- Egress
|
|
538
|
+
egress:
|
|
539
|
+
- to:
|
|
540
|
+
- podSelector: {}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Multi-Tier Application Policy
|
|
544
|
+
|
|
545
|
+
```yaml
|
|
546
|
+
# Database tier - only from app tier
|
|
547
|
+
apiVersion: networking.k8s.io/v1
|
|
548
|
+
kind: NetworkPolicy
|
|
549
|
+
metadata:
|
|
550
|
+
name: database-policy
|
|
551
|
+
namespace: production
|
|
552
|
+
spec:
|
|
553
|
+
podSelector:
|
|
554
|
+
matchLabels:
|
|
555
|
+
tier: database
|
|
556
|
+
policyTypes:
|
|
557
|
+
- Ingress
|
|
558
|
+
ingress:
|
|
559
|
+
- from:
|
|
560
|
+
- podSelector:
|
|
561
|
+
matchLabels:
|
|
562
|
+
tier: application
|
|
563
|
+
ports:
|
|
564
|
+
- protocol: TCP
|
|
565
|
+
port: 5432
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
# Application tier - from frontend and to database
|
|
569
|
+
apiVersion: networking.k8s.io/v1
|
|
570
|
+
kind: NetworkPolicy
|
|
571
|
+
metadata:
|
|
572
|
+
name: application-policy
|
|
573
|
+
namespace: production
|
|
574
|
+
spec:
|
|
575
|
+
podSelector:
|
|
576
|
+
matchLabels:
|
|
577
|
+
tier: application
|
|
578
|
+
policyTypes:
|
|
579
|
+
- Ingress
|
|
580
|
+
- Egress
|
|
581
|
+
ingress:
|
|
582
|
+
- from:
|
|
583
|
+
- podSelector:
|
|
584
|
+
matchLabels:
|
|
585
|
+
tier: frontend
|
|
586
|
+
ports:
|
|
587
|
+
- protocol: TCP
|
|
588
|
+
port: 8080
|
|
589
|
+
egress:
|
|
590
|
+
- to:
|
|
591
|
+
- podSelector:
|
|
592
|
+
matchLabels:
|
|
593
|
+
tier: database
|
|
594
|
+
ports:
|
|
595
|
+
- protocol: TCP
|
|
596
|
+
port: 5432
|
|
597
|
+
- to:
|
|
598
|
+
- namespaceSelector:
|
|
599
|
+
matchLabels:
|
|
600
|
+
name: kube-system
|
|
601
|
+
ports:
|
|
602
|
+
- protocol: UDP
|
|
603
|
+
port: 53
|
|
604
|
+
|
|
605
|
+
---
|
|
606
|
+
# Frontend tier - from ingress
|
|
607
|
+
apiVersion: networking.k8s.io/v1
|
|
608
|
+
kind: NetworkPolicy
|
|
609
|
+
metadata:
|
|
610
|
+
name: frontend-policy
|
|
611
|
+
namespace: production
|
|
612
|
+
spec:
|
|
613
|
+
podSelector:
|
|
614
|
+
matchLabels:
|
|
615
|
+
tier: frontend
|
|
616
|
+
policyTypes:
|
|
617
|
+
- Ingress
|
|
618
|
+
- Egress
|
|
619
|
+
ingress:
|
|
620
|
+
- from:
|
|
621
|
+
- namespaceSelector:
|
|
622
|
+
matchLabels:
|
|
623
|
+
name: ingress-nginx
|
|
624
|
+
ports:
|
|
625
|
+
- protocol: TCP
|
|
626
|
+
port: 80
|
|
627
|
+
egress:
|
|
628
|
+
- to:
|
|
629
|
+
- podSelector:
|
|
630
|
+
matchLabels:
|
|
631
|
+
tier: application
|
|
632
|
+
ports:
|
|
633
|
+
- protocol: TCP
|
|
634
|
+
port: 8080
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
## Service Discovery
|
|
638
|
+
|
|
639
|
+
### CoreDNS Configuration
|
|
640
|
+
|
|
641
|
+
```yaml
|
|
642
|
+
apiVersion: v1
|
|
643
|
+
kind: ConfigMap
|
|
644
|
+
metadata:
|
|
645
|
+
name: coredns
|
|
646
|
+
namespace: kube-system
|
|
647
|
+
data:
|
|
648
|
+
Corefile: |
|
|
649
|
+
.:53 {
|
|
650
|
+
errors
|
|
651
|
+
health {
|
|
652
|
+
lameduck 5s
|
|
653
|
+
}
|
|
654
|
+
ready
|
|
655
|
+
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
|
656
|
+
pods insecure
|
|
657
|
+
fallthrough in-addr.arpa ip6.arpa
|
|
658
|
+
ttl 30
|
|
659
|
+
}
|
|
660
|
+
prometheus :9153
|
|
661
|
+
forward . /etc/resolv.conf {
|
|
662
|
+
max_concurrent 1000
|
|
663
|
+
}
|
|
664
|
+
cache 30
|
|
665
|
+
loop
|
|
666
|
+
reload
|
|
667
|
+
loadbalance
|
|
668
|
+
}
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
## Best Practices
|
|
672
|
+
|
|
673
|
+
1. **Choose appropriate CNI** - Calico for policy, Cilium for eBPF, Flannel for simplicity
|
|
674
|
+
2. **Enable network policies** - Default deny, explicit allow
|
|
675
|
+
3. **Use eBPF when possible** - Better performance than iptables
|
|
676
|
+
4. **Monitor network traffic** - Use Hubble or flow logs
|
|
677
|
+
5. **Implement proper IPAM** - Avoid IP exhaustion
|
|
678
|
+
6. **Use BGP for large clusters** - Better than full mesh
|
|
679
|
+
7. **Enable encryption** - WireGuard or IPsec for pod-to-pod
|
|
680
|
+
8. **Test failover** - Ensure network resilience
|
|
681
|
+
9. **Document network architecture** - IP ranges, policies
|
|
682
|
+
10. **Use L7 policies** - Fine-grained HTTP/gRPC control
|
|
683
|
+
|
|
684
|
+
## Anti-Patterns
|
|
685
|
+
|
|
686
|
+
- **No network policies** - All pods can communicate
|
|
687
|
+
- **Using deprecated CNI** - Stick to maintained plugins
|
|
688
|
+
- **Ignoring MTU** - Can cause packet fragmentation
|
|
689
|
+
- **Overlapping IP ranges** - Conflicts with on-prem networks
|
|
690
|
+
- **No monitoring** - Can't diagnose network issues
|
|
691
|
+
- **Single CNI plugin** - No failover capability
|
|
692
|
+
- **Insufficient IP space** - Running out of addresses
|
|
693
|
+
- **Complex policy chains** - Hard to debug
|
|
694
|
+
- **No encryption** - Pod traffic exposed
|
|
695
|
+
- **Ignoring performance** - Not optimizing for workload
|