Claude Skills Guide

Claude Code for Azure Arc Kubernetes Workflow

Azure Arc-enabled Kubernetes extends Azure’s management capabilities to Kubernetes clusters running anywhere—on-premises, on other cloud providers, or at the edge. Managing these hybrid Kubernetes environments can be complex, but Claude Code can significantly streamline your workflow. This guide shows you how to use Claude Code effectively for Azure Arc Kubernetes operations.

Understanding Azure Arc Kubernetes Architecture

Before diving into workflows, it’s essential to understand what you’re managing. Azure Arc-enabled Kubernetes allows you to attach Kubernetes clusters to Azure for consistent management, monitoring, and policy enforcement regardless of where they run.

Claude Code can help you navigate this architecture by:

Setting Up Claude Code for Azure Arc

First, ensure Claude Code has the necessary context about your Azure environment. Create a CLAUDE.md file in your project directory with relevant Azure Arc information:

# Azure Arc Kubernetes Project

## Environment
- Azure subscription: production-sub-001
- Resource group: arc-clusters-rg
- Connected clusters: 3 (prod-aks, staging-k3s, edge-cluster)

## Common Tasks
- Deploy workloads to Arc-enabled clusters
- Check cluster health and connectivity
- Troubleshoot Arc agent issues
- Configure GitOps for cluster management

This context helps Claude understand your specific setup and provide more relevant assistance.

Connecting Clusters to Azure Arc

One of the first tasks you’ll encounter is connecting an existing Kubernetes cluster to Azure Arc. Here’s how Claude Code can help you generate the necessary configuration:

Claude can help you create a service principal for authentication:

# Generate Azure service principal for Arc registration
az ad sp create-for-rbac --name "arc-cluster-sp" --role "Azure Connected Kubernetes Role"

Once you have the credentials, Claude can generate the appropriate az connectedk8s connect command with your specific parameters:

# Connect a cluster to Azure Arc
az connectedk8s connect --name my-cluster \
  --resource-group arc-clusters-rg \
  --location eastus \
  --tags "environment=production" "team=platform"

Claude Code can also help you verify the connection status and check that the Arc agents are running correctly on your cluster:

# Check Arc agent pods
kubectl get pods -n azure-arc

# Verify cluster connection status
az connectedk8s show --name my-cluster --resource-group arc-clusters-rg

Deploying Applications with GitOps

Azure Arc Kubernetes supports GitOps-based configuration management through Azure Flux. Claude Code excels at generating Flux configurations and helping you set up automated deployments.

Creating a GitOps Configuration

Here’s how you can use Claude to generate a GitOps configuration:

# Enable GitOps on your Arc-enabled cluster
az k8s-configuration flux create \
  --name cluster-config \
  --cluster-name my-cluster \
  --resource-group arc-clusters-rg \
  --namespace flux-system \
  --scope cluster \
  --url https://github.com/your-org/cluster-configs \
  --branch main \
  --kustomization name=app1 namespace=app1

Claude can help you understand the structure of your GitOps repository and generate appropriate Kustomize overlays for different environments.

Managing Multiple Environments

When managing multiple clusters (production, staging, development), Claude can help you create organized configurations:

# kustomization.yaml for production
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: production
resources:
  - base/deployment.yaml
  - base/service.yaml
  - overlays/common
patches:
  - path: patches/production-values.yaml

Monitoring and Troubleshooting

Azure Arc provides monitoring through Azure Monitor Container Insights. Claude Code can help you set up monitoring and diagnose issues.

Viewing Logs and Metrics

# Get logs from Arc agents
kubectl logs -n azure-arc \
  -l app.kubernetes.io/name=azure-arc-agent \
  --tail=100

# Check agent health
az connectedk8s show -n my-cluster -g arc-clusters-rg \
  --query "agentVersion"

Troubleshooting Common Issues

Claude can guide you through common Azure Arc Kubernetes problems:

  1. Cluster shows as disconnected: Check network connectivity and ensure the Arc agents can reach Azure endpoints
  2. Configuration sync failures: Review Flux logs and verify Git repository accessibility
  3. Permission issues: Verify the service principal has the correct role assignments

Here’s a diagnostic script Claude can help generate:

#!/bin/bash
# Azure Arc cluster diagnostic script

CLUSTER_NAME="my-cluster"
RG="arc-clusters-rg"

echo "=== Azure Arc Cluster Diagnostics ==="

# Check cluster connection status
echo -e "\n1. Cluster Connection Status:"
az connectedk8s show -n $CLUSTER_NAME -g $RG \
  --query "{name:name, state:provisioningState, location:location}"

# Check Arc agents
echo -e "\n2. Arc Agents Status:"
kubectl get pods -n azure-arc -o wide

# Check for errors
echo -e "\n3. Recent Agent Logs:"
kubectl logs -n azure-arc \
  -l app.kubernetes.io/component=hub-agent \
  --tail=50

# Check Flux configurations
echo -e "\n4. GitOps Configurations:"
az k8s-configuration flux show \
  -n cluster-config \
  -c $CLUSTER_NAME \
  -g $RG

Policy Enforcement with Azure Policy

Azure Arc Kubernetes supports Azure Policy for cluster governance. Claude can help you create and apply policies:

# List available built-in policies for Kubernetes
az policy definition list \
  --query "[?contains(displayName, 'Kubernetes')].{name:displayName, mode:mode}"

You can then assign policies to your Arc-enabled cluster:

# Enable Kubernetes cluster pod security policy
az policy assignment create \
  --name "pod-security-policy" \
  --policy "Kubernetes cluster containers should only use allowed capabilities" \
  --scope "/subscriptions/xxx/resourceGroups/arc-clusters-rg/providers/Microsoft.Kubernetes/connectedClusters/my-cluster"

Best Practices for Claude Code with Azure Arc

To get the most out of Claude Code when working with Azure Arc Kubernetes:

  1. Provide specific context: Include your cluster names, namespaces, and Azure resource details in your prompts
  2. Ask for explanations: When Claude generates commands, ask it to explain what each part does
  3. Iterate on configurations: Use Claude to generate initial configurations, then refine them based on your requirements
  4. Verify before applying: Always review generated manifests before applying them to production clusters
  5. Use version-specific help: Specify your Kubernetes version and Azure CLI version when asking for help

Automating Routine Tasks

Claude Code can help you create automation scripts for common Azure Arc operations. For example, a script to check all connected clusters:

#!/bin/bash
# Check health of all Arc-enabled clusters

SUBSCRIPTION="your-subscription-id"
az account set --subscription $SUBSCRIPTION

echo "=== Arc-Enabled Kubernetes Cluster Health ==="

for cluster in $(az connectedk8s list --query "[].name" -o tsv); do
  RG=$(az connectedk8s show -n $cluster --query "resourceGroup" -o tsv)
  STATE=$(az connectedk8s show -n $cluster -g $RG --query "provisioningState" -o tsv)
  AGENT_VERSION=$(az connectedk8s show -n $cluster -g $RG --query "agentVersion" -o tsv)
  
  echo "Cluster: $cluster"
  echo "  State: $STATE"
  echo "  Agent Version: $AGENT_VERSION"
  echo ""
done

Conclusion

Claude Code is a powerful assistant for Azure Arc Kubernetes management. By providing the right context about your environment and asking specific questions, you can use Claude to:

The key is to be specific about your cluster names, namespaces, and requirements when interacting with Claude. With practice, you’ll find Claude Code becomes an invaluable partner in managing your hybrid Kubernetes infrastructure.


Remember to always verify commands and configurations before applying them to production environments. Azure Arc Kubernetes management requires careful attention to security and network configuration.

Built by theluckystrike — More at zovo.one