### Test Flux MCP Server Installation Source: https://fluxcd.control-plane.io/mcp/install Verify your Flux MCP Server installation by interacting with your cluster using specific prompts. Successful interaction indicates a correct setup. ```English Which cluster contexts are available in my kubeconfig? What version of Flux is running in my current cluster? ``` -------------------------------- ### Build Flux MCP Server from Source Source: https://fluxcd.control-plane.io/mcp/install Steps to build the Flux MCP Server binary from its source code using make, requiring Go 1.24+. ```bash git cd ``` -------------------------------- ### Install Flux MCP Server with Homebrew Source: https://fluxcd.control-plane.io/mcp/install Instructions for installing the Flux MCP Server on macOS or Linux using the Homebrew package manager. ```bash brew ``` -------------------------------- ### Troubleshoot Flux MCP Server Source: https://fluxcd.control-plane.io/mcp/install Common troubleshooting steps for Flux MCP Server issues including server not found, AI assistant tool detection problems, kubeconfig errors, and permission issues. ```English kubectl get crds kubectl get fluxinstance -A ``` -------------------------------- ### Find flux-operator-mcp Binary Path Source: https://fluxcd.control-plane.io/mcp/install Command to locate the installed path of the flux-operator-mcp binary. ```bash which ``` -------------------------------- ### Upgrade Flux MCP Server Source: https://fluxcd.control-plane.io/mcp/install Instructions for upgrading the Flux MCP Server to a newer version by downloading the latest binary, replacing the existing one, and restarting associated applications. -------------------------------- ### Install Flux CLI Source: https://fluxcd.control-plane.io/guides/flux-cli-quick-reference Provides installation commands for the Flux CLI on macOS using Homebrew and on Windows using winget. ```bash brew ``` ```powershell winget=FluxCD.Flux ``` -------------------------------- ### Configure AI Assistants with Flux MCP Server (Claude, Cursor, Windsurf) Source: https://fluxcd.control-plane.io/mcp/install Configuration settings for AI assistants to connect to the Flux MCP Server using stdio or SSE. Includes specifying the server command, arguments, and environment variables like KUBECONFIG. ```json { "mcpServers":{ "flux-operator-mcp":{ "command":"/path/to/flux-operator-mcp", "args":["serve"], "env":{ "KUBECONFIG":"/path/to/.kube/config" } } } } ``` -------------------------------- ### Flux CLI Bootstrap (FIPS-compliant) Source: https://fluxcd.control-plane.io/distribution/install Example of bootstrapping Flux with the FIPS-compliant enterprise distribution using the Flux CLI. Requires specifying registry address, credentials, and image path. ```bash flux bootstrap \ --url=oci://ghcr.io/controlplaneio-fluxcd/distroless/source-controller \ --token-auth \ --username=flux \ --password=$ENTERPRISE_TOKEN \ --path=clusters/production \ --private-key=flux-enterprise-auth.pem ``` -------------------------------- ### Flux Reporting and Troubleshooting Prompts Source: https://fluxcd.control-plane.io/mcp/prompt-engineering Prompts to analyze Flux installation status, compare instances across clusters, identify reconciliation errors, verify configurations, track deployments, visualize dependency flows, and pinpoint root causes of failures. ```English Analyze the Flux installation in my current cluster and report the status of all components. List the clusters in my kubeconfig and compare the Flux instances across them. Are there any reconciliation errors in the Flux-managed resources? Are the Flux kustomizations and Helm releases configured correctly? Based on Flux events, what deployments have been updated today? Draw a diagram of the Flux dependency flow in the cluster. What is the Git source and revision of the Flux OCI repositories? Which Kubernetes deployments are managed by Flux in the current cluster? Which images are deployed by Flux in the monitoring namespace? Perform a root cause analysis of the last failed deployment in the frontend namespace. ``` -------------------------------- ### Prompting Strategies for Flux MCP Server Source: https://fluxcd.control-plane.io/mcp/prompt-engineering This section outlines effective prompting strategies for users interacting with the Flux MCP Server tools to ensure the best experience. It covers techniques like starting broad, including context, chaining operations, verifying changes, and utilizing documentation. ```APIDOC Prompting Strategies: - Start broad, then narrow: Begin with general queries about your Flux installation before drilling down. - Include context: Mention the namespace, cluster, and relevant details in your requests. - Chain operations: For complex workflows, ask the AI to perform a sequence of related operations. - Verify changes: After performing modifications, ask for verification of the new state. - Use documentation: When in doubt about Flux features, explicitly ask to search the Flux API documentation. ``` -------------------------------- ### Flux Bootstrap Command Example Source: https://fluxcd.control-plane.io/operator/flux-bootstrap-migration Example of a Flux bootstrap command used to initialize a cluster with Flux. ```bash flux bootstrap git \ --url=my-org/my-fleet \ --branch=main \ --path=./clusters/my-cluster \ --personal ``` -------------------------------- ### Find Kubeconfig File Path Source: https://fluxcd.control-plane.io/mcp/install Command to find the default path for the kubeconfig file. ```bash echo $HOME/.kube/config ``` -------------------------------- ### Configure VS Code Copilot Chat with Flux MCP Server Source: https://fluxcd.control-plane.io/mcp/install VS Code settings to enable and configure the Flux MCP Server for use with Copilot Chat, including enabling agent mode. ```json { "mcp":{ "servers":{ "flux-operator-mcp":{ "command":"/path/to/flux-operator-mcp", "args":["serve"], "env":{ "KUBECONFIG":"/path/to/.kube/config" } } } }, "chat.mcp.enabled":true } ``` -------------------------------- ### Flux Terraform Provider Bootstrap (Mainline) Source: https://fluxcd.control-plane.io/distribution/install Example of bootstrapping Flux using the Flux Terraform provider with mainline enterprise distribution images. Specifies resource configuration, path, image pull secret, and registry credentials. ```terraform resource "flux_bootstrap_git" "this" { embedded_manifests = true path = "clusters/my-cluster" image_pull_secret = "flux-enterprise-auth" registry_credentials = "flux:${var.enterprise_token}" registry = "ghcr.io/controlplaneio-fluxcd/alpine" } ``` -------------------------------- ### Flux Operator CLI Installation (Homebrew) Source: https://fluxcd.control-plane.io/operator/cli Installs the Flux Operator CLI using Homebrew on macOS or Linux. ```bash brew ``` -------------------------------- ### Flux ResourceSetInputProvider Example Source: https://fluxcd.control-plane.io/operator/resourcesetinputprovider Example of a ResourceSetInputProvider that fetches input values from GitHub Pull Requests labeled with 'deploy/flux-preview'. It includes the Kubernetes manifest and steps to apply and verify it. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSetInputProvider metadata: name:flux-appx-prs namespace:default annotations: fluxcd.controlplane.io/reconcile:"enabled" fluxcd.controlplane.io/reconcileEvery:"5m" spec: type:GitHubPullRequest url:https://github.com/controlplaneio-fluxcd/flux-appx filter: labels: -"deploy/flux-preview" defaultValues: chart:"charts/flux-appx" ``` ```bash kubectl apply -f flux-appx-prs.yaml ``` ```bash kubectl wait --for=condition=ready pod -n default --timeout=5m ``` ```bash $ kubectl get resourceSetInputProvider flux-appx-prs -n default -o yaml ``` ```bash kubectl delete resourceSetInputProvider flux-appx-prs -n default ``` -------------------------------- ### Flux ResourceSet Example: HelmRelease and OCIRepository Source: https://fluxcd.control-plane.io/operator/resourceset This example demonstrates a ResourceSet that generates a Flux HelmRelease and OCIRepository for each tenant, specifying version and replica count. It includes common metadata, inputs, and the resource definitions. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSet metadata: name:podinfo namespace:default annotations: fluxcd.controlplane.io/reconcile:"enabled" fluxcd.controlplane.io/reconcileEvery:"30m" fluxcd.controlplane.io/reconcileTimeout:"5m" spec: commonMetadata: labels: app.kubernetes.io/name:podinfo inputs: -tenant:"team1" app: version:"6.7.x" replicas:2 -tenant:"team2" app: version:"6.6.x" replicas:3 resources: -apiVersion:source.toolkit.fluxcd.io/v1 kind:OCIRepository metadata: name:podinfo-<< inputs.tenant >> namespace:default spec: interval:10m url:oci://ghcr.io/stefanprodan/charts/podinfo ref: semver:<< inputs.app.version | quote >> -apiVersion:helm.toolkit.fluxcd.io/v2 kind:HelmRelease metadata: name:podinfo-<< inputs.tenant >> namespace:default spec: interval:1h releaseName:podinfo-<< inputs.tenant >> chartRef: kind:OCIRepository name:podinfo-<< inputs.tenant >> values: replicaCount:<< inputs.app.replicas | int >> ``` -------------------------------- ### Flux MCP Server SSE Transport Setup Source: https://fluxcd.control-plane.io/mcp/config Instructions to set up and connect to the Flux MCP Server using Server-Sent Events (SSE) transport. Includes setting KUBECONFIG, starting the server, and VS Code client configuration. ```shell export KUBECONFIG=$HOME/.kube/config flux-operator-mcp 8080 ``` ```json { "mcp":{ "servers":{ "flux-operator-mcp":{ "type":"sse", "url":"http://localhost:8080/sse" } } } } ``` -------------------------------- ### Sync GitRepository Example (HTTP/S) Source: https://fluxcd.control-plane.io/operator/fluxinstance Example of configuring Flux to sync from a Git repository over HTTP/S. Includes the spec definition and the Kubernetes secret format for authentication. ```yaml spec: sync: kind:GitRepository url:"https://gitlab.com/my-group/my-fleet.git" ref:"refs/heads/main" path:"clusters/my-cluster" pullSecret:"git-token-auth" ``` ```yaml apiVersion:v1 kind:Secret metadata: name:git-token-auth namespace:flux-system type:Opaque stringData: username:"git-username" password:"git-token" ``` -------------------------------- ### Assigning GitRepository and Kustomization to Shard1 Source: https://fluxcd.control-plane.io/operator/flux-sharding Example of labeling a GitRepository and a Kustomization with `sharding.fluxcd.io/key: shard1` to assign them to the `shard1` controllers. ```yaml --- apiVersion:source.toolkit.fluxcd.io/v1 kind:GitRepository metadata: name:podinfo namespace:default labels: sharding.fluxcd.io/key:shard1 spec: interval:10m url:https://github.com/stefanprodan/podinfo ref: semver:6.x --- apiVersion:kustomize.toolkit.fluxcd.io/v1 kind:Kustomization metadata: name:podinfo namespace:default labels: sharding.fluxcd.io/key:shard1 spec: interval:10m targetNamespace:default sourceRef: kind:GitRepository name:podinfo path:./kustomize prune:true ``` -------------------------------- ### ResourceSetInputProvider Exported Inputs Examples Source: https://fluxcd.control-plane.io/operator/resourcesetinputprovider Examples of exported inputs status for different ResourceSetInputProvider types, including GitHub Pull Requests, GitHub latest semver tags, and OCI latest semver tags. ```APIDOC Exported Inputs Status Examples: GitHub Pull Request: status: exportedInputs: - author: stefanprodan branch: kubernetes/helm-set-limits id: "4" sha: bf5d6e01cf802734853f6f3417b237e3ad0ba35d title: 'kubernetes(helm):Adddefaultresourceslimits' - author: stefanprodan branch: feat/ui-footer id: "3" sha: 8492c0b5b2094fe720776c8ace1b9690ff258f53 title: 'feat(ui):Addfooter' - author: stefanprodan branch: feat/ui-color-scheme id: "2" sha: 8166bdecd6b078b9e5dd14fa3b7b67a847f76893 title: 'feat(ui):Defaultcolorscheme' GitHub latest semver tag: status: exportedInputs: - id: "48955639" tag: "6.0.4" sha: 11cf36d83818e64aaa60d523ab6438258ebb6009 OCI latest semver tag: status: exportedInputs: - id: "48955639" tag: "6.0.4" sha: sha256:d4ec9861522d4961b2acac5a070ef4f92d732480dff2062c2f3a1dcf9a5d1e91 ``` -------------------------------- ### Flux Operator CLI Shell Completion Setup Source: https://fluxcd.control-plane.io/operator/cli Configures your shell to load Bash completions for the flux-operator CLI. ```bash echo"source <(flux-operator completion bash)" ``` -------------------------------- ### Node Affinity and Tolerations Example Source: https://fluxcd.control-plane.io/operator/flux-kustomize Demonstrates how to apply node affinity and tolerations to Flux controller deployments using Kustomize patches. This example targets all deployments and sets specific affinity and toleration rules. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:FluxInstance spec: kustomize: patches: -patch:| apiVersion: apps/v1 kind: Deployment metadata: name: all spec: template: metadata: annotations: cluster-autoscaler.kubernetes.io/safe-to-evict: "true" spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: role operator: In values: - flux tolerations: - effect: NoSchedule key: role operator: Equal value: flux target: kind:Deployment ``` -------------------------------- ### Flux Learning Prompts Source: https://fluxcd.control-plane.io/mcp/prompt-engineering Prompts to learn about Flux configurations, including setting up mutual TLS for Git, understanding the role of the interval setting in Kustomizations, and triggering Flux reconciliations via webhooks, referencing the latest Flux documentation. ```English How to configure mutual TLS for Git? Answer using the latest Flux docs. What is the role of the interval setting in a Flux Kustomization? Search the latest docs. How to trigger a Flux reconciliation with a webhook? Search the latest docs. ``` -------------------------------- ### ResourceSetInputProvider with Zero-Duration Window Source: https://fluxcd.control-plane.io/operator/resourcesets/time-based-delivery Example of a ResourceSetInputProvider configuration with a zero-duration window. Reconciliations attempt to occur at the exact scheduled time. ```YAML apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSetInputProvider metadata: annotations: fluxcd.controlplane.io/reconcileEvery:"10m" spec: schedule: -cron:"08**1-5" timeZone:"UTC" window:"0s" ``` -------------------------------- ### FluxReport Spec: Distribution Information Example Source: https://fluxcd.control-plane.io/operator/fluxreport An example snippet illustrating the `.spec.distribution` field within a FluxReport. This section provides details about the Flux distribution, including its version, installation status, entitlement, and management method. ```yaml spec: distribution: entitlement:Issued by controlplane managedBy:'fluxbootstrap' status:Installed version:v2.3.0 ``` -------------------------------- ### Flux Operator Subscription Manifest for OLM Source: https://fluxcd.control-plane.io/operator/install Provides an example Kubernetes subscription manifest for installing the Flux Operator on OpenShift using Operator Lifecycle Manager (OLM). It specifies the channel, source, and default service account. ```yaml apiVersion:operators.coreos.com/v1alpha1 kind:Subscription metadata: name:flux-operator namespace:flux-system spec: channel:stable name:flux-operator source:operatorhubio-catalog sourceNamespace:olm config: env: -name:DEFAULT_SERVICE_ACCOUNT value:"flux-operator" -name:REPORTING_INTERVAL value:"30s" ``` -------------------------------- ### AI Assistant Instructions Configuration Source: https://fluxcd.control-plane.io/mcp/prompt-engineering This section details how to configure AI assistants with specific instructions for interacting with the Flux MCP Server. It outlines the methods for different platforms like Claude, Cursor, Windsurf, and GitHub Copilot, including file paths and sections for placing instructions. ```APIDOC AI Assistant Instructions Configuration: - Claude: Use the `Project Instructions` section in Claude Desktop. - Cursor: Use the `.cursor/rules` dir in your Git repository. - Windsurf: Use the `.windsurf/rules` dir in your Git repository. - GitHub Copilot: Use the `.github/copilot-instructions.md` file in your Git repository. ``` -------------------------------- ### Uninstall Flux Operator with Helm Source: https://fluxcd.control-plane.io/operator/install Example command to uninstall the Flux Operator using Helm. ```helm helm uninstall flux-operator -n flux-system ``` -------------------------------- ### Flux CLI: Build Kustomization Locally Source: https://fluxcd.control-plane.io/guides/flux-cli-quick-reference Builds a Flux Kustomization locally to test changes before pushing them to the Git repository. Displays the resulting Kubernetes manifests. ```bash flux \ --path \ --kustomization-file ``` -------------------------------- ### Uninstall Flux MCP Server Source: https://fluxcd.control-plane.io/mcp/install Steps to uninstall the Flux MCP Server by removing the binary and its configuration from AI assistant settings. -------------------------------- ### FluxInstance Default Configuration Source: https://fluxcd.control-plane.io/operator/flux-config Example of a minimal FluxInstance resource for the default Flux distribution. This resource installs and configures the automated update of the Flux distribution. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:FluxInstance metadata: name:flux namespace:flux-system spec: distribution: version:"2.6.x" registry:"ghcr.io/fluxcd" artifact:"oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests" cluster: type:kubernetes size:medium ``` -------------------------------- ### Flux ResourceSet for Multi-Instance App Deployment Source: https://fluxcd.control-plane.io/operator/resourcesets/app-definition This example demonstrates how to deploy multiple instances of an application using a single Flux ResourceSet manifest. It defines inputs for different tenants and references them within the OCI Repository and HelmRelease resources, reducing the need for separate Kustomize overlays. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSet metadata: name:app1 namespace:apps spec: inputs: -tenant:"tenant1" app: version:"6.7.x" replicas:2 -tenant:"tenant2" app: version:"6.6.x" replicas:3 resources: -apiVersion:source.toolkit.fluxcd.io/v1 kind:OCIRepository metadata: name:app1-<< inputs.tenant >> namespace:apps spec: interval:10m url:oci://my.registry/org/charts/app1 ref: semver:<< inputs.app.version | quote >> -apiVersion:helm.toolkit.fluxcd.io/v2 kind:HelmRelease metadata: name:app1-<< inputs.tenant >> namespace:apps spec: interval:1h releaseName:app1-<< inputs.tenant >> chartRef: kind:OCIRepository name:app1-<< inputs.tenant >> values: replicaCount:<< inputs.app.replicas | int >> ``` -------------------------------- ### Get Kubernetes Pod Metrics Source: https://fluxcd.control-plane.io/mcp/tools Retrieves CPU and Memory usage metrics for Kubernetes pods. Supports filtering by pod name, namespace, and label selectors. Requires the Kubernetes metrics-server to be installed. ```APIDOC get_kubernetes_metrics(pod_name: Optional[str] = None, pod_namespace: str, pod_selector: Optional[str] = None, limit: int = 100) Retrieves CPU and Memory usage for Kubernetes pods, allowing AI assistants to monitor resource consumption and performance. This tool depends on the Kubernetes metrics-server being installed in the cluster. Parameters: pod_name (optional): The name of the pod, when not specified all pods are selected. pod_namespace (required): The namespace of the pods. pod_selector (optional): Label selector in the format `key1=value1,key2=value2` limit (optional): Maximum number of metrics to return (default: 100) Output: Returns the metrics for the specified pods, including CPU and Memory for each container, in YAML format. ``` -------------------------------- ### Flux CLI to List Resources for Shard2 Source: https://fluxcd.control-plane.io/operator/flux-sharding Demonstrates using the `flux` CLI with a label selector to list all resources assigned to `shard2`. ```bash $ flux=shard2 NAME REVISION SUSPENDED READY MESSAGE helmrepository/podinfo sha256:3dfe15d8 False True stored artifact: revision 'sha256:3dfe15d8' NAME REVISION SUSPENDED READY MESSAGE helmchart/podinfo 6.7.0 False True pulled 'podinfo' chart with version '6.7.0' NAME REVISION SUSPENDED READY MESSAGE helmrelease/podinfo 6.7.0 False True Helm install succeeded for release podinfo-helm/podinfo.v1 with chart podinfo@6.7.0 ``` -------------------------------- ### Copying ControlPlane Images to Private Registry Source: https://fluxcd.control-plane.io/distribution/install Example script using the 'crane' CLI to copy FIPS-compliant ControlPlane Flux controller images to a private registry. Iterates through a list of controllers and pushes them. ```bash FLUX_CONTROLLERS=( "source-controller" "kustomize-controller" "helm-controller" "notification-controller" "image-reflector-controller" "image-automation-controller" ) for controller in "${FLUX_CONTROLLERS[@]}"; do crane cp ghcr.io/controlplaneio-fluxcd/distroless/$controller:$TAG /$controller:$TAG done ``` -------------------------------- ### Flux Kustomization Debugging Commands Source: https://fluxcd.control-plane.io/guides/flux-cli-quick-reference Provides commands for debugging Flux Kustomizations, including listing failed Kustomizations, displaying Kustomization configuration and events, viewing events of the Kustomization source (e.g., GitRepository), displaying kustomize-controller logs, and showing final variables for post-build substitutions. ```bash fluxready=false fluxexport flux flux flux flux ``` -------------------------------- ### FluxReport Custom Resource Example Source: https://fluxcd.control-plane.io/operator/fluxreport This YAML defines a FluxReport custom resource, providing detailed status and statistics for a Flux installation on a Kubernetes cluster. It includes information about the cluster, components, distribution, reconcilers, and synchronization status. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:FluxReport metadata: name:flux namespace:flux-system spec: cluster: platform:linux/arm64 serverVersion:v1.33.0 nodes:5 components: -image:ghcr.io/fluxcd/helm-controller:v1.0.1@sha256:a67a037faa850220ff94d8090253732079589ad9ff10b6ddf294f3b7cd0f3424 name:helm-controller ready:true status:'CurrentDeploymentisavailable.Replicas:1' -image:ghcr.io/fluxcd/kustomize-controller:v1.3.0@sha256:48a032574dd45c39750ba0f1488e6f1ae36756a38f40976a6b7a588d83acefc1 name:kustomize-controller ready:true status:'CurrentDeploymentisavailable.Replicas:1' -image:ghcr.io/fluxcd/notification-controller:v1.3.0@sha256:c0fab940c7e578ea519097d36c040238b0cc039ce366fdb753947428bbf0c3d6 name:notification-controller ready:true status:'CurrentDeploymentisavailable.Replicas:1' -image:ghcr.io/fluxcd/source-controller:v1.3.0@sha256:161da425b16b64dda4b3cec2ba0f8d7442973aba29bb446db3b340626181a0bc name:source-controller ready:true status:'CurrentDeploymentisavailable.Replicas:1' distribution: entitlement:Issued by controlplane managedBy:flux-operator status:Installed version:v2.3.0 operator: apiVersion:fluxcd.controlplane.io/v1 platform:linux/arm64 version:v0.24.0 reconcilers: -apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSet stats: failing:0 running:5 suspended:1 -apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSetInputProvider stats: failing:1 running:5 suspended:1 -apiVersion:helm.toolkit.fluxcd.io/v2 kind:HelmRelease stats: failing:1 running:42 suspended:3 -apiVersion:kustomize.toolkit.fluxcd.io/v1 kind:Kustomization stats: failing:0 running:5 suspended:0 -apiVersion:notification.toolkit.fluxcd.io/v1 kind:Receiver stats: failing:0 running:1 suspended:0 -apiVersion:notification.toolkit.fluxcd.io/v1beta3 kind:Alert stats: failing:0 running:1 suspended:0 -apiVersion:notification.toolkit.fluxcd.io/v1beta3 kind:Provider stats: failing:0 running:1 suspended:0 -apiVersion:source.toolkit.fluxcd.io/v1 kind:GitRepository stats: failing:0 running:2 suspended:0 totalSize:3.7 MiB -apiVersion:source.toolkit.fluxcd.io/v1 kind:HelmChart stats: failing:1 running:55 suspended:0 totalSize:15.7 MiB -apiVersion:source.toolkit.fluxcd.io/v1 kind:HelmRepository stats: failing:0 running:7 suspended:3 totalSize:40.5 MiB -apiVersion:source.toolkit.fluxcd.io/v1beta2 kind:Bucket stats: failing:0 running:0 suspended:0 -apiVersion:source.toolkit.fluxcd.io/v1beta2 kind:OCIRepository stats: failing:0 running:1 suspended:0 totalSize:78.1 KiB sync: ready:true id:kustomization/flux-system path:clusters/production source:https://github.com/my-org/my-fleet.git status:'Appliedrevision:refs/heads/main@sha1:a90cd1ac35de01c175f7199315d3f4cd60195911' status: conditions: -lastTransitionTime:"2024-06-20T19:59:30Z" message:Reporting finished in 272ms observedGeneration:4 reason:ReconciliationSucceeded status:"True" type:Ready ``` -------------------------------- ### Flux MCP Server Introduction Source: https://fluxcd.control-plane.io/mcp The Flux Model Context Protocol (MCP) Server connects AI assistants like Claude, Cursor, GitHub Copilot, and others directly to your Kubernetes clusters running Flux Operator, enabling seamless interaction through natural language. It serves as a bridge between AI tools and your GitOps pipelines, allowing you to analyze the cluster state, troubleshoot deployment issues, and perform operations using conversational prompts. ```Markdown # Flux MCP Server Introduction The Flux Model Context Protocol (MCP) Server connects AI assistants like Claude, Cursor, GitHub Copilot, and others directly to your Kubernetes clusters running Flux Operator, enabling seamless interaction through natural language. It serves as a bridge between AI tools and your GitOps pipelines, allowing you to analyze the cluster state, troubleshoot deployment issues, and perform operations using conversational prompts. Experimental Feature Please note that the Flux MCP Server is an experimental feature provided as-is without warranty or support guarantees. Enterprise customers should use this feature at their own discretion. ## Features * **Cluster State Analysis** * * * Quickly understand your Flux installation status, resource configurations, and deployment histories across environments. * **Cross-Cluster Comparisons** * * * Compare Flux configurations for applications and infrastructure between development, staging, and production. * **Enhanced On-Call Experience** * * * Reduce mean time to resolution (MTTR) during incidents with contextual analysis and actionable remediation steps. * **Root Cause Analysis** * * * Automatically correlate events, logs, and configuration changes to identify the source of failures in a GitOps pipeline. * **GitOps Automation** * * * Trigger reconciliations, suspend/resume Flux resources, and manage your delivery pipelines with simple requests. * **Visual GitOps Pipelines** * * * Generate diagrams that map out Flux dependencies, resource relationships, and delivery workflows across clusters. ## How It Works The Flux MCP Server integrates with AI assistants through the Model Context Protocol, providing them with purpose-built tools to interact with your clusters. When you ask a question or make a request, the AI uses these tools to gather information, analyze configurations, and perform operations based on your instructions. The AI assistants leveraging the Flux MCP Server can trace issues from high-level GitOps resources like ResourceSets, HelmReleases, and Kustomizations all the way down to individual pod logs. This comprehensive visibility means you can quickly identify where problems originate in your delivery pipeline – whether in Helm chart values, Kubernetes manifests, Flux configurations, or application runtime issues. AI Instructions For the best experience, we recommend configuring your AI assistants with custom instructions that guide them on how to interact with Kubernetes and the Flux MCP Server. ## Security Considerations The Flux MCP Server is designed with security in mind: * Operates with your existing kubeconfig permissions * Supports service account impersonation for limited access * Masks sensitive information in Kubernetes Secret values * Provides a Kubernetes read-only mode for observation without affecting the cluster state * Access to the local file system is read-only and restricted to the kubeconfig file For a detailed overview of configuring the Flux MCP Server, including security settings, see the Configuration Guide. ``` -------------------------------- ### Flux Actions Prompts Source: https://fluxcd.control-plane.io/mcp/prompt-engineering Prompts for performing actions such as reconciling Flux Kustomizations and Helm releases, suspending and deleting failing releases, resuming suspended Kustomizations, generating and applying namespaces, copying service accounts and RBAC, and deleting namespaces. ```English Reconcile the flux-system kustomization with its source in the current cluster. Reconcile all the Flux Kustomization from flux-system namespace in the depends-on order, then verify their status. Suspend all failing Helm releases in the test namespace, then delete them from the cluster. Search for all the suspended Flux Kustomizations in the cluster and resume them. Generate a namespace called test and apply it on my current cluster. Copy the flux service account and its RBAC from the frontend namespace into test (remove the fluxcd labels). Delete the test namespace from my current cluster. ``` -------------------------------- ### Leveraging Repository Context with Claude Desktop Source: https://fluxcd.control-plane.io/mcp/prompt-engineering This section explains how to use Git repository context with AI chat within an IDE, specifically detailing how to enable Claude Desktop to access Kubernetes manifests and Flux Operator documentation for accurate analysis. ```APIDOC Repository Context with Claude Desktop: - Install the filesystem MCP server and allow the assistant to access Kubernetes manifests in your Git repository. - In the Claude project knowledge, add the Flux Operator documentation using the `https://github.com/controlplaneio-fluxcd/distribution` repository and select the `docs/operator` folder. ``` -------------------------------- ### Flux Operator CLI for Testing ResourceSets Source: https://fluxcd.control-plane.io/operator/resourcesets/gitlab-merge-requests Demonstrates how to use the Flux Operator CLI to build and test ResourceSet templates locally. It shows the command structure and provides an example of a `test-inputs.yaml` file containing mock merge request data. ```bash flux-operator \ ``` ```yaml # test-inputs.yaml -author:test branch:feat/test id:"1" sha:bf5d6e01cf802734853f6f3417b237e3ad0ba35d title:'testing' ``` -------------------------------- ### Install Flux Operator with Helm Source: https://fluxcd.control-plane.io/operator/install Installs the Flux Operator using its Helm chart available in the GitHub Container Registry. It's recommended to install the operator in a dedicated namespace like 'flux-system'. ```helm helm install flux-operator oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator --version --namespace flux-system ``` -------------------------------- ### Install Flux Operator with Kubectl Source: https://fluxcd.control-plane.io/operator/install Installs the Flux Operator by applying Kubernetes manifests. These manifests are typically found on the project's releases page. ```kubectl kubectl apply -k ``` -------------------------------- ### Flux Kustomization for Production Deployment Source: https://fluxcd.control-plane.io/guides/flux-generic-helm-chart This Flux Kustomization resource defines how to deploy the 'my-java-apps' application to the production cluster. It specifies the interval, timeout, pruning behavior, and the source repository path for the production environment. ```yaml apiVersion:kustomize.toolkit.fluxcd.io/v1 kind:Kustomization metadata: name:my-java-apps namespace:flux-system spec: interval:10m timeout:5m prune:true sourceRef: kind:GitRepository name:flux-system path:my-java-apps/production targetNamespace:my-java-apps ``` -------------------------------- ### Install Flux Operator and Instance with Terraform Source: https://fluxcd.control-plane.io/operator/install Demonstrates installing the Flux Operator and a Flux instance using Terraform via the Helm provider. It specifies the chart repository, chart names, namespace, and uses a values file for configuration. ```terraform resource"helm_release""flux_operator"{ name="flux-operator" namespace="flux-system" repository="oci://ghcr.io/controlplaneio-fluxcd/charts" chart="flux-operator" create_namespace=true } resource"helm_release""flux_instance"{ depends_on=[helm_release.flux_operator] name="flux" namespace="flux-system" repository="oci://ghcr.io/controlplaneio-fluxcd/charts" chart="flux-instance" values=[ file("values/components.yaml") ] } ``` -------------------------------- ### Flux ResourceSetInputProvider for Static Input Definitions Source: https://fluxcd.control-plane.io/operator/resourcesets/app-definition These examples define ResourceSetInputProvider resources with the 'Static' input type. They provide tenant-specific default values for application versions and replicas, which can be referenced by a ResourceSet using label selectors. The ResourceSet and ResourceSetInputProvider must reside in the same namespace. ```yaml apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSetInputProvider metadata: name:app1-tenant1 namespace:apps labels: some:label anotherLabel:value1 spec: type:Static defaultValues: tenant:"tenant1" app: version:"6.7.x" replicas:2 --- apiVersion:fluxcd.controlplane.io/v1 kind:ResourceSetInputProvider metadata: name:app1-tenant2 namespace:apps labels: some:label anotherLabel:value2 spec: type:Static defaultValues: tenant:"tenant2" app: version:"6.6.x" replicas:3 ``` -------------------------------- ### Flux Components Configuration Source: https://fluxcd.control-plane.io/operator/fluxinstance Specifies the list of Flux components to install. If not specified, a default set is installed. ```yaml spec: components: - source-controller - kustomize-controller - helm-controller - notification-controller ``` -------------------------------- ### Flux Controllers (Distroless) Source: https://fluxcd.control-plane.io/releases/release-v2 Lists Flux controllers packaged as distroless images, their versions, and supported architectures (amd64/arm64). ```markdown Controller | Version | Architectures ---|---|--- `ghcr.io/controlplaneio-fluxcd/distroless/source-controller` | v1.5.0 | amd64 / arm64 `ghcr.io/controlplaneio-fluxcd/distroless/kustomize-controller` | v1.5.1 | amd64 / arm64 `ghcr.io/controlplaneio-fluxcd/distroless/helm-controller` | v1.2.0 | amd64 / arm64 `ghcr.io/controlplaneio-fluxcd/distroless/notification-controller` | v1.5.0 | amd64 / arm64 `ghcr.io/controlplaneio-fluxcd/distroless/image-reflector-controller` | v0.34.0 | amd64 / arm64 `ghcr.io/controlplaneio-fluxcd/distroless/image-automation-controller` | v0.40.0 | amd64 / arm64 ``` -------------------------------- ### Flux Bootstrap Repository Structure Example Source: https://fluxcd.control-plane.io/guides/flux-architecture Illustrates a typical repository structure used by platform teams to manage multiple Kubernetes clusters and tenants with Flux. This structure helps segregate cluster add-ons from tenant applications and define reconciliation order. ```yaml ├── ``` -------------------------------- ### Flux Operator Helm Installation Configuration Source: https://fluxcd.control-plane.io/operator/resourceset Shows how to configure the default service account for the Flux Operator during Helm installation. ```APIDOC helm install flux-operator fluxcd/flux-operator \ --set defaultServiceAccount=flux-operator \ --set createDefaultRBAC=true ``` -------------------------------- ### Install Flux Operator with Helm Source: https://fluxcd.control-plane.io/operator/flux-bootstrap-migration Installs the Flux Operator in the same namespace where Flux is currently deployed using Helm. ```bash helm install flux-operator fluxcd/flux-operator --namespace flux-system ``` -------------------------------- ### Flux Operator CLI Container Image Usage Source: https://fluxcd.control-plane.io/operator/cli Demonstrates how to use the Flux Operator CLI container image, including fetching the version and running help commands for both flux-operator and kubectl. ```bash version=$(gh'.tagName') docker=flux-operator$versionhelp docker=kubectl$versionhelp ``` -------------------------------- ### Sync OCIRepository Example Source: https://fluxcd.control-plane.io/operator/fluxinstance Example of configuring Flux to sync from an OCI repository. Includes the spec definition and the Kubernetes secret format for private registry authentication. ```yaml spec: sync: kind:OCIRepository url:"oci://ghcr.io/my-org/my-fleet-manifests" ref:"latest" path:"clusters/my-cluster" pullSecret:"oci-token-auth" ``` ```yaml apiVersion:v1 kind:Secret metadata: name:oci-token-auth namespace:flux-system type:kubernetes.io/dockerconfigjson data: .dockerconfigjson:"base64-encoded-docker-config" ``` -------------------------------- ### Flux Components Overview Source: https://fluxcd.control-plane.io/guides/flux-architecture Details the core components of Flux CD, including the CLI, Terraform Provider, APIs (CRDs), and controllers, which together enable GitOps for continuous delivery. ```Flux CD Flux CLI * * * A command-line tool for installing, upgrading, operating, monitoring and debugging the Flux controllers running on Kubernetes clusters. Flux Terraform Provider * * * An infrastructure-as-code provider for bootstrapping Flux with Terraform and OpenTofu. Flux APIs * * * A set of Kubernetes CRDs that allow defining continuous delivery workflows in a declarative manner. Flux controllers * * * A set of Kubernetes controllers that automate all aspects of continuous delivery based on the declarative workflows defined with the Flux APIs. ``` -------------------------------- ### Package and Push Helm Chart Source: https://fluxcd.control-plane.io/guides/flux-generic-helm-chart Commands for packaging a Helm chart with a Git tag and pushing it to a container registry, optionally signing it with cosign. ```bash helm${GIT_TAG} helm# Push the Helm chart to the container registry helm${GIT_TAG}.tgz# Sign the Helm chart cosign${GIT_TAG} ``` -------------------------------- ### Sync Bucket Example Source: https://fluxcd.control-plane.io/operator/fluxinstance Example of configuring Flux to sync from an S3-compatible storage bucket. Includes the spec definition and the Kubernetes secret format for private bucket authentication. ```yaml spec: sync: kind:Bucket url:"minio.my-org.com" ref:"my-bucket-fleet" path:"clusters/my-cluster" pullSecret:"bucket-auth" ``` ```yaml apiVersion:v1 kind:Secret metadata: name:bucket-auth namespace:flux-system type:Opaque stringData: accesskey:"my-accesskey" secretkey:"my-secretkey" ``` -------------------------------- ### Flux CLI: List Resources and Status Source: https://fluxcd.control-plane.io/guides/flux-cli-quick-reference Lists all Flux resources and their status at the cluster level. Supports filtering by namespace and resource kind. Also shows commands for displaying specific resource status and finding available get commands. ```bash flux flux --all-namespaces flux -A flux --namespace flux -n flux get flux get ``` -------------------------------- ### Assigning Default Values with get and default Source: https://fluxcd.control-plane.io/operator/resourceset Shows how to assign a default value to a field when an input is not specified, using the `get` and `default` functions in conjunction with input variables. ```Go text template spec: inputs: -namespace:team1 resources: -apiVersion:source.toolkit.fluxcd.io/v1 kind:OCIRepository metadata: name:<< get inputs "name" | default inputs.namespace >> namespace:<< inputs.namespace >> ```