Skip to content

Lab 0: Setup

Lab 000 - Environment Setup

  • Welcome to K-Agent Labs!
  • In this first lab, you’ll set up your development environment with all the tools needed for the K-Agent infrastructure.
  • This lab covers Docker, Kubernetes, and the K-Agent labs environment container.

What you’ll learn in this workshop:
  • Install and configure required tools (Docker, kubectl, Helm, Ollama, MCP Inspector, K-Agent etc.)
  • Build and run the K-Agent labs environment (Docker container or locally)
  • Verify Kubernetes cluster connectivity
  • Prepare the MCP server setup

01. Prerequisites Installation

🐳 Docker Installation
# Install Docker Desktop
brew install --cask docker

# Start Docker Desktop from Applications
# Or use command line:
open /Applications/Docker.app
# Update package index
sudo apt-get update

# Install Docker
curl -fsSL https://get.docker.com | sh

# Add user to docker group
sudo usermod -aG docker $USER

# Restart session or run:
newgrp docker
# Set up the repository
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
# Start Docker
sudo systemctl start docker
# Add user to docker group
sudo usermod -aG docker $USER
# Restart session or run:
newgrp docker
# Docker is pre-installed in Cloud Shell
docker --version
☸️ kubectl Installation
brew install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# kubectl is pre-installed
kubectl version --client
βš“ Helm Installation
brew install helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Helm is pre-installed
helm version
πŸ™ Git Installation
brew install git
sudo apt-get install -y git
sudo yum install -y git
# Git is pre-installed
git --version
🐍 Python3 Installation
brew install python
sudo apt-get install -y python3 python3-pip
sudo yum install -y python3 python3-pip
# Python3 is pre-installed
python3 --version
πŸ“¦ Node.js Installation
brew install node
sudo apt-get install -y nodejs npm
sudo yum install -y nodejs npm
# Node.js is pre-installed
node --version
πŸ€– Ollama Installation
brew install ollama

# Start Ollama service
ollama serve
curl -fsSL https://ollama.ai/install.sh | sh

# Start Ollama service
ollama serve
curl -fsSL https://ollama.ai/install.sh | sh

# Start Ollama service
ollama serve
# Ollama is not supported in Cloud Shell
echo "Ollama is not supported in Cloud Shell"
πŸ” MCP Inspector Installation
npm install -g @modelcontextprotocol/inspector
npm install -g @modelcontextprotocol/inspector
npm install -g @modelcontextprotocol/inspector
npm install -g @modelcontextprotocol/inspector
Kubernetes Cluster Setup (minikube)
brew install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Minikube is already installed in Cloud Shell
minikube version
Kubernetes Cluster Setup (kind)
brew install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
Kind is not supported in Cloud Shell - Use minikube instead

02. Verify Tools Installation

  • Verify that all the tools are installed
# Verify Docker
docker --version
# Verify kubectl
kubectl version --client
# Verify Helm
helm version
# Verify Git
git --version
# Verify Python3
python3 --version
# Verify Node.js
node --version
# Verify Ollama (if installed)
ollama --version
# Verify MCP Inspector
mcp-inspector --version
# Verify Kind (if installed)
kind --version
# Verify Minikube (if installed)
minikube version
# Verify Cluster Info (if cluster is running)
kubectl cluster-info

03. Install the K-Agent

  • The K-Agent labs environment is the fundamental building block for all labs.
  • Its an Open Source framework to write MCP tools and interact with Kubernetes clusters.
brew install kagent
curl https://raw.githubusercontent.com/kagent-dev/kagent/refs/heads/main/scripts/get-kagent | bash
curl https://raw.githubusercontent.com/kagent-dev/kagent/refs/heads/main/scripts/get-kagent | bash
curl https://raw.githubusercontent.com/kagent-dev/kagent/refs/heads/main/scripts/get-kagent | bash
Verify K-Agent Installation
kagent version

04. Ollama Setup

  • Ollama will be used as our LLM model for the labs.
  • Ollama is a local LLM server that allows you to run large language models on your machine.
  • Ollama supports various models, for example: Qwen and Llama.
  • We will use the qwen3-coder model which is optimized for coding tasks or the llama2 model.

Pulling Models (Ollama)

_ Pulling models can take a while depending on your internet speed and system performance. _ You can skip this step and return to it later when needed.

Setup Ollama models
# Start Ollama service
ollama serve

# In a new terminal, pull the qwen3-coder model (optimized for coding tasks)
ollama pull qwen3-coder:30b

# Alternatively, pull the gpt-oos model
ollama pull gpt-oos:7b

# Verify
ollama list
Pull a Model
# In a new terminal, pull the qwen3-coder model (optimized for coding tasks)
ollama pull qwen3-coder:30b

# Verify
ollama list

07. Verify Setup

  • Let’s verify your setup by running a simple test.
Task 01: Check Cluster Information
# Check cluster info
kubectl cluster-info
kubectl get nodes
kubectl get namespaces

Exercise 2: Test Container Environment

# Start labs environment if not running
cd labs-environment
docker compose up -d

# Execute commands in container
docker exec kagent-controller bash -c "
echo '=== Environment Check ==='
echo 'Node.js:' \$(node --version)
echo 'Python:' \$(python --version)
echo 'kubectl:' \$(kubectl version --client --short)
echo 'Helm:' \$(helm version --short)
echo '========================='
"

Expected Output:

=== Environment Check ===
Node.js: v18.x.x
Python: Python 3.10.x
kubectl: Client Version: v1.28.x
Helm: v3.13.x
=========================

08. Troubleshooting

Container Won’t Start

If the container fails to start, check:

docker compose logs
docker images | grep kagent
docker ps -a

Kubectl Not Working in Container

If kubectl commands fail in the container:

# Verify kubeconfig is mounted correctly
docker exec kagent-controller ls -la /root/.kube/

# Try copying kubeconfig again
cp ~/.kube/config $(git rev-parse --show-toplevel)/runtime/.kube/config

# Restart container
cd labs-environment
docker compose restart

Platform Issues (M1/M2 Mac)

If you encounter platform errors:

# Verify platform in .env file
cat labs-environment/.env

# Should show: TARGET_PLATFORM=linux/arm64
# If not, update it manually