This project implements a complete Kubernetes-based infrastructure using K3d and K3s, with GitLab integration for CI/CD capabilities.
- Project Overview
- Architecture
- Prerequisites
- Part 3: K3d and K3s Setup
- Bonus: GitLab Integration
- Usage Guide
- Troubleshooting
- Cleanup
This project consists of two main parts:
- Part 3: Setting up a local Kubernetes cluster using K3d and K3s
- Bonus: Integrating GitLab for CI/CD capabilities
- Local Kubernetes cluster using K3d
- K3s lightweight Kubernetes distribution
- Argo CD for GitOps
- GitLab for source code management and CI/CD
- Automated deployment scripts
- Comprehensive monitoring and logging
┌─────────────────────────────────────────────────────────┐
│ Local Development │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ K3d │ │ GitLab │ │ Argo CD │ │
│ │ Cluster │◄──►│ Instance │◄──►│ Server │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
- Docker Desktop
- kubectl
- Helm
- K3d
- Git
- Sufficient system resources (recommended: 8GB RAM, 4 CPU cores)
p3/
├── scripts/
│ ├── install.sh # Main installation script
│ ├── setup_k3d.sh # K3d cluster setup
│ ├── setup_k3s.sh # K3s installation
│ └── setup_networking.sh # Network configuration
├── confs/
│ └── k3d-config.yaml # K3d configuration
├── Makefile # Automation commands
└── README.md # Documentation
-
Setup K3d Cluster
cd p3 make setup-k3dThis creates a local K3d cluster with:
- 3 worker nodes
- Custom networking
- Load balancer
- Ingress controller
-
Install K3s
make setup-k3s
Installs K3s on the cluster with:
- Lightweight Kubernetes distribution
- Built-in container runtime
- Automatic TLS management
-
Configure Networking
make setup-networking
Sets up:
- Network policies
- Service mesh
- Ingress rules
-
Deploy Applications
make deploy
Deploys:
- Argo CD
- Monitoring stack
- Sample applications
-
Argo CD
make argocd-info
- URL: http://localhost:8080
- Username: admin
- Password: (generated during installation)
-
Cluster Status
make status
Shows:
- Node status
- Pod status
- Service status
bonus/
├── scripts/
│ └── install.sh # GitLab installation script
├── confs/ # Configuration files
├── Makefile # Automation commands
└── README.md # Documentation
-
Install GitLab
cd bonus make installThis:
- Installs Helm (if not present)
- Adds GitLab Helm repository
- Creates GitLab namespace
- Installs GitLab components
- Sets up port forwarding
-
Access GitLab
make gitlab-info
- URL: http://localhost:8080
- Username: root
- Password: (generated during installation)
- Create a new project in GitLab
- Configure Argo CD to use GitLab repository:
- Update repository URL
- Configure authentication
- Set up webhooks
make setup-k3d # Setup K3d cluster
make setup-k3s # Install K3s
make setup-networking # Configure networking
make deploy # Deploy applications
make status # Check cluster status
make argocd-info # Show Argo CD credentialsmake install # Install GitLab
make status # Check GitLab status
make gitlab-info # Show GitLab credentials
make gitlab-port-forward # Start port forwarding-
Cluster Monitoring
kubectl get nodes kubectl get pods -A kubectl get svc -A
-
Application Monitoring
- Argo CD dashboard
- GitLab monitoring
- Kubernetes dashboard
-
K3d Cluster Issues
k3d cluster list k3d cluster start k3d cluster stop
-
GitLab Issues
make check-gitlab make gitlab-port-forward
-
Network Issues
kubectl get networkpolicies -A kubectl get ingress -A
# K3d logs
k3d cluster logs
# GitLab logs
kubectl logs -n gitlab -l app=gitlab
# Argo CD logs
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-server# Part 3 cleanup
cd p3
make clean
# Bonus cleanup
cd bonus
make clean# Clean K3d cluster
k3d cluster delete
# Clean GitLab
kubectl delete namespace gitlab
helm uninstall gitlab -n gitlab-
Cluster Security
- Network policies
- RBAC configuration
- TLS management
- Secret management
-
GitLab Security
- Change default passwords
- Configure access controls
- Set up SSL
- Regular updates
-
Argo CD Security
- Secure repository access
- Configure authentication
- Set up webhook security
-
Resource Management
- Monitor resource usage
- Adjust resource limits
- Configure persistence
- Optimize networking
-
Best Practices
- Regular backups
- Monitoring setup
- Log management
- Update procedures
- Update Kubernetes components
- Monitor resource usage
- Check security patches
- Backup configurations
- Review logs
- Export configurations
- Backup persistent data
- Document procedures
- Test recovery process