3.2 KiB
3.2 KiB
sidebar_position
| sidebar_position |
|---|
| 1 |
Kubernetes (K3s)
Overview
We use K3s, a lightweight Kubernetes distribution, as our container orchestration platform.
Cluster Setup
Nodes
-
Master Node:
oracle-master- Control plane components
- etcd database
- ArgoCD installation
-
Worker Nodes:
mayne-worker-1,mayne-worker-2, etc.- Application workloads
- Monitoring stack
- Service deployments
Access
# SSH to master node
ssh oracle-master
# Use kubectl (requires sudo on master)
sudo kubectl get nodes
sudo kubectl get pods -A
Common Operations
View All Resources
# Get all namespaces
sudo kubectl get namespaces
# Get all pods in all namespaces
sudo kubectl get pods -A
# Get services
sudo kubectl get services -A
Check Application Status
# Check specific namespace
sudo kubectl get all -n <namespace>
# View pod logs
sudo kubectl logs -n <namespace> <pod-name>
# Describe pod for troubleshooting
sudo kubectl describe pod -n <namespace> <pod-name>
Managing Applications
Most applications are managed by ArgoCD, so manual kubectl operations are rarely needed.
# Check ArgoCD applications
sudo kubectl get applications -n argocd
# Force sync an application (if needed)
sudo kubectl patch application -n argocd <app-name> \
-p '{"metadata": {"annotations": {"argocd.argoproj.io/refresh": "hard"}}}' \
--type merge
Namespaces
Each service runs in its own namespace for isolation:
| Namespace | Purpose |
|---|---|
argocd |
ArgoCD deployment |
cert-manager |
Certificate management |
ingress-nginx |
Ingress controller |
monitoring |
Prometheus, Grafana |
gitea |
Git service |
vault |
Secrets management |
Storage
Storage Classes
- local-path: Default storage class
- Uses local disk on worker nodes
- Good for development and non-critical data
Persistent Volumes
# View PVCs
sudo kubectl get pvc -A
# View PVs
sudo kubectl get pv
Networking
Ingress
External traffic flows through nginx-ingress-controller:
Internet → nginx-ingress → Service → Pod
Services
- ClusterIP: Internal only (default)
- LoadBalancer: External access (rarely used)
- Ingress: HTTPS with custom domains
Troubleshooting
Pod Not Starting
# Check pod events
sudo kubectl describe pod -n <namespace> <pod-name>
# Check logs
sudo kubectl logs -n <namespace> <pod-name>
# Check previous container logs (if crashed)
sudo kubectl logs -n <namespace> <pod-name> --previous
Resource Issues
# Check node resources
sudo kubectl top nodes
# Check pod resources
sudo kubectl top pods -A
Network Issues
# Check services
sudo kubectl get svc -A
# Check ingress
sudo kubectl get ingress -A
# Test connectivity from a pod
sudo kubectl run -it --rm debug --image=nicolaka/netshoot --restart=Never -- /bin/bash
Best Practices
- Use namespaces for logical separation
- Set resource limits on all containers
- Use health checks (readiness and liveness probes)
- Label everything for better organization
- Don't run as root (use securityContext)