9.0 KiB
Contributing Labs to CK-X Simulator
This guide explains how to create and contribute your own practice labs for the CK-X Simulator. By following these steps, you can create custom assessment scenarios for Kubernetes certification preparation (CKAD, CKA, CKS) or other container-related topics.
Lab Structure Overview
Each lab in CK-X Simulator consists of:
- Lab Entry in the main labs registry
- Configuration File for lab settings
- Assessment File containing questions and verification steps
- Setup and Verification Scripts to prepare environments and validate student solutions
- Answers File with solution documentation
Considerations Before Creating a Lab
- The cluster will consist of one control-plane node and multiple worker nodes.
- SSH access to the nodes is not provided, which may restrict the development of labs that require access to Kubernetes internals or node internals.
- All setup scripts will be executed simultaneously, so ensure that the questions are independent of each other.
- Limit the setup to a maximum of two worker nodes to reduce system resource consumption during the exam.
- When creating files in the cluster, use the /tmp/exam directory. This directory will be created during setup and removed during cleanup.
Step 1: Create Lab Directory Structure
First, create a directory structure for your lab using this pattern:
facilitator/
└── assets/
└── exams/
└── [category]/
└── [id]/
├── config.json
├── assessment.json
├── answers.md
└── scripts/
├── setup/
│ └── [setup scripts]
└── validation/
└── [verification scripts]
Where:
[category]is the certification type (e.g.,ckad,cka,cks,other)[id]is a numeric identifier (e.g.,001,002)
For example, to create a new CKAD lab with ID 003:
facilitator/assets/exams/ckad/003/
Step 2: Create Configuration File
Create a config.json file in your lab directory with the following structure:
{
"lab": "ckad-003",
"workerNodes": 1,
"answers": "assets/exams/ckad/003/answers.md",
"questions": "assessment.json",
"totalMarks": 100,
"lowScore": 40,
"mediumScore": 60,
"highScore": 90
}
Parameters:
lab: Unique identifier for the lab (should match directory structure)workerNodes: Number of worker nodes required for this labanswers: Path to answers markdown filequestions: sessment JSON filenametotalMarks: Maximum possible scorelowScore,mediumScore,highScore: Score thresholds for result categorization
Step 3: Create Assessment File
Create an assessment.json file that defines questions, namespaces, and verification steps:
{
"questions": [
{
"id": "1",
"namespace": "default",
"machineHostname": "node01",
"question": "Create a deployment named `nginx-deploy` with 3 replicas using the nginx:1.19 image.\n\nEnsure the deployment is created in the `default` namespace.",
"concepts": ["deployments", "replication"],
"verification": [
{
"id": "1",
"description": "Deployment exists",
"verificationScriptFile": "q1_s1_validate_deployment.sh",
"expectedOutput": "0",
"weightage": 2
},
{
"id": "2",
"description": "Deployment has 3 replicas",
"verificationScriptFile": "q1_s2_validate_replicas.sh",
"expectedOutput": "0",
"weightage": 1
},
{
"id": "3",
"description": "Deployment uses correct image",
"verificationScriptFile": "q1_s3_validate_image.sh",
"expectedOutput": "0",
"weightage": 1
}
]
}
// Add more questions...
]
}
Each question should include:
id: Unique question identifiernamespace: Kubernetes namespace for the questionmachineHostname: The hostname to display for SSH connectionquestion: The actual task description with formatting:- Use
\nfor line breaks to improve readability - Put code references, commands, or file paths in backtick (e.g.,
nginx:1.19) which will be highlighted in the UI - Structure your question with clear paragraphs separated by blank lines
- Use
concepts: Array of concepts/topics coveredverification: Array of verification steps
Each verification step includes:
id: Unique step identifierdescription: Human-readable description of what's being checkedverificationScriptFile: Script file path to validate the step (present in /scripts/validation directory)expectedOutput: Expected return code (usually "0" for success)weightage: Point value for this verification step
Step 4: Create Setup and Verification Scripts
The CK-X Simulator uses two types of scripts:
Setup Scripts
Create setup scripts in the scripts/setup/ directory to prepare the environment for each question. These scripts run before the student starts the exam to ensure the necessary resources are available.
Example setup script (scripts/setup/q1_setup.sh):
#!/bin/bash
# Setup environment for Question 1
# Create namespace if it doesn't exist
kubectl create namespace default --dry-run=client -o yaml | kubectl apply -f -
# Create any prerequisite resources
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
namespace: default
data:
nginx.conf: |
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
EOF
echo "Environment setup complete for Question 1"
exit 0
Verification Scripts
Create verification scripts in the scripts/validation/ directory to validate student solutions. Each script should:
- Check a specific aspect of the solution
- Return exit code 0 for success, non-zero for failure
- Output useful information for student feedback
Example verification script (scripts/validation/q1_s1_validate_deployment.sh):
#!/bin/bash
# Check if deployment exists
DEPLOYMENT_NAME="nginx-deploy"
NAMESPACE="default"
kubectl get deployment $DEPLOYMENT_NAME -n $NAMESPACE &> /dev/null
if [ $? -eq 0 ]; then
echo "✅ Deployment '$DEPLOYMENT_NAME' exists in namespace '$NAMESPACE'"
exit 0
else
echo "❌ Deployment '$DEPLOYMENT_NAME' not found in namespace '$NAMESPACE'"
exit 1
fi
Step 5: Create Answers File
Create an answers.md file containing solutions to your questions. This file will be displayed directly to students when they view the exam answers.
Focus on providing clear, educational solutions with detailed explanations. The file is rendered as standard Markdown, so you can use all Markdown formatting features. Include complete solution commands, explanations of why certain approaches work, and any relevant tips or best practices.
For each question, provide the question text as a heading followed by a comprehensive solution that would help someone understand not just what to do but why that approach is correct.
Step 6: Register Your Lab
Finally, add your lab to the main labs.json file:
{
"labs": [
// ... existing labs ...
{
"id": "ckad-003",
"assetPath": "assets/exams/ckad/003",
"name": "CKAD Practice Lab - Advanced Deployments",
"category": "CKAD",
"description": "Practice advanced deployment patterns and strategies",
"warmUpTimeInSeconds": 60,
"difficulty": "medium"
}
]
}
Parameters:
id: Unique identifier (should match directory structure)assetPath: Path to lab resourcesname: Display name for the labcategory: Lab category (CKAD, CKA, CKS, etc.)description: Brief description of the lab contentwarmUpTimeInSeconds: Preparation time before exam startsdifficulty: Difficulty level (easy, medium, hard)
Best Practices
- Realistic Scenarios: Design questions that mimic real certification exam tasks
- Clear Instructions: Write concise, unambiguous question descriptions
- Thorough Verification: Create scripts that verify all aspects of the solution
- Comprehensive Answers: Provide complete, educational solutions
- Progressive Difficulty: Arrange questions from simple to complex
- Namespaces: Use separate namespaces for different questions to avoid conflicts
- Resource Requirements: Keep resource requirements reasonable
Testing Your Lab
Before submitting your lab:
- Build and deploy the simulator with your new lab
- Go through each question as a student would
- Verify that all verification scripts work correctly
- Ensure the answers solve the questions as expected
- Check that scoring and evaluation work properly
Contribution Process
- Fork the CK-X Simulator repository
- Add your lab following these guidelines
- Test thoroughly
- Submit a pull request with a description of your lab
Thank you for contributing to the CK-X community!