Skip to content

Commit 7839ad9

Browse files
author
Marcel Zapf
committed
update
1 parent c0e5133 commit 7839ad9

2 files changed

Lines changed: 63 additions & 183 deletions

File tree

README.md

Lines changed: 62 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,240 +1,121 @@
11
# K8s DevMachine
22

3-
A containerized development environment for Kubernetes that provides a VM-like dev experience with SSH access.
3+
Containerized development environment for Kubernetes with SSH access. Perfect for VS Code Remote SSH development.
44

55
## ✨ Features
66

7-
- **Complete development toolkit** with pre-installed tools:
8-
- Terraform
9-
- Packer
10-
- Ansible with Python libraries
11-
- Git, Vim, SSH utilities
12-
- MinIO Client
13-
- **SSH access** on port 2222
7+
- **Development Tools**: Terraform, Packer, Ansible, Python 3, Git, Vim
8+
- **System Tools**: htop, tmux, mc, mcli (minio cli), curl, jq, ping, dig, dmidecode, lshw
9+
- **Cloud Tools**: MinIO Client, SSH server with key-based auth
10+
- **VS Code Remote SSH ready** - full IDE experience
11+
- **Go development support** - easily install Go SDK
1412
- **Persistent storage** for home directory
15-
- **Secure configuration** with non-root user
16-
- **Python virtual environment** auto-activated
17-
- **Customizable SSH keys** via ConfigMap
13+
- **Non-root user** (UID 1001) with auto-activated Python venv
1814

1915
## 🚀 Quick Start
2016

21-
### Prerequisites
22-
23-
- Kubernetes cluster (>= 1.20)
24-
- Helm 3.x
25-
- Storage class (Longhorn recommended)
26-
- LoadBalancer support (for external access)
27-
28-
### Installation
29-
30-
1. **Clone the repository**
3117
```bash
18+
# 1. Clone repo
3219
git clone https://github.com/syntax3rror404/k8s-devmachine.git
3320
cd k8s-devmachine
34-
```
35-
36-
2. **Configure SSH keys**
37-
Edit `chart/values.yaml` and add your public SSH keys:
3821

39-
```yaml
22+
# 2. Add your SSH keys to chart/values.yaml
4023
ssh:
4124
authorizedKeys: |
4225
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC... user@hostname
43-
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@hostname
44-
```
4526

46-
3. **Deploy with Helm**
47-
```bash
27+
# 3. Deploy
4828
helm install devmachine ./chart
49-
```
5029

51-
4. **Get external IP and connect**
52-
```bash
30+
# 4. Connect
5331
kubectl get svc devmachine-service
5432
ssh -p 2222 dev@<EXTERNAL-IP>
5533
```
5634

57-
## 🔧 Configuration
58-
59-
### values.yaml
60-
61-
```yaml
62-
replicaCount: 1
63-
64-
image:
65-
source: ghcr.io/syntax3rror404/k8s-devmachine@sha256:...
66-
pullPolicy: IfNotPresent
67-
68-
service:
69-
type: LoadBalancer
70-
port: 2222
71-
targetPort: 2222
72-
73-
persistence:
74-
enabled: true
75-
size: 10Gi
76-
storageClass: "longhorn"
35+
## 💻 VS Code Remote SSH
7736

78-
ssh:
79-
authorizedKeys: |
80-
# Add your SSH public keys here
37+
1. Install "Remote - SSH" extension in VS Code
38+
2. Add to `~/.ssh/config`:
8139
```
82-
83-
### Resource limits (optional)
84-
85-
```yaml
86-
resources:
87-
requests:
88-
memory: "512Mi"
89-
cpu: "250m"
90-
limits:
91-
memory: "2Gi"
92-
cpu: "1000m"
40+
Host k8s-devmachine
41+
HostName <EXTERNAL-IP>
42+
Port 2222
43+
User dev
9344
```
45+
3. Connect via VS Code: `Ctrl+Shift+P` → "Remote-SSH: Connect to Host"
9446

95-
## 🔐 Access
47+
## 🛠️ Install Additional Tools
9648

97-
### SSH Connection
49+
### Go Installation
9850
```bash
99-
# Get external IP
100-
EXTERNAL_IP=$(kubectl get svc devmachine-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
101-
102-
# Connect via SSH
103-
ssh -p 2222 dev@$EXTERNAL_IP
51+
ssh -p 2222 dev@<EXTERNAL-IP>
52+
cd /tmp
53+
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
54+
tar -xzf go1.21.5.linux-amd64.tar.gz
55+
mv go ~/bin/
56+
go version # Already in PATH
10457
```
10558

106-
### Port Forwarding (alternative)
59+
### Node.js
10760
```bash
108-
kubectl port-forward svc/devmachine-service 2222:2222
109-
ssh -p 2222 dev@localhost
61+
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
62+
sudo apt-get install -y nodejs
11063
```
11164

112-
## 📁 Container Structure
113-
114-
```
115-
/home/dev/
116-
├── .ssh/authorized_keys # Your SSH keys
117-
├── .bashrc # Shell configuration
118-
├── venv/ # Python virtual environment
119-
├── ssh_keys/ # SSH host keys (persistent)
120-
└── run/ # Runtime files
121-
```
122-
123-
## 🛠️ Development
124-
125-
### Building the image
126-
127-
The container image is automatically built via GitHub Actions on push to master branch.
65+
## 🔧 Configuration
12866

129-
For local development:
130-
```bash
131-
docker build -t k8s-devmachine .
132-
docker run -p 2222:2222 k8s-devmachine
67+
Key `values.yaml` options:
68+
```yaml
69+
replicaCount: 1
70+
service:
71+
type: LoadBalancer # or NodePort
72+
port: 2222
73+
persistence:
74+
size: 10Gi
75+
storageClass: "longhorn"
76+
ssh:
77+
authorizedKeys: |
78+
# Your SSH public keys here
13379
```
13480
135-
### Installed Tools
81+
## 🔐 Access Options
13682
137-
- **Infrastructure**: Terraform, Packer, TF-Helper
138-
- **Configuration Management**: Ansible with extensive Python libraries
139-
- **Utilities**: Git, Vim, curl, jq, openssh, MinIO client
140-
- **System Tools**: ping, dig, dmidecode, lshw
83+
**SSH Direct**: `ssh -p 2222 dev@<EXTERNAL-IP>`
84+
**Port Forward**: `kubectl port-forward svc/devmachine-service 2222:2222`
85+
**NodePort**: `kubectl patch svc devmachine-service -p '{"spec":{"type":"NodePort"}}'`
14186

14287
## 🐛 Troubleshooting
14388

144-
### Common Issues
145-
146-
**SSH connection refused**
14789
```bash
148-
# Check pod status
90+
# Check status
14991
kubectl get pods -l app=devmachine
150-
151-
# View logs
15292
kubectl logs -l app=devmachine
15393
154-
# Debug inside pod
155-
kubectl exec -it devmachine-0 -- /bin/bash
156-
```
157-
158-
**LoadBalancer pending**
159-
```bash
160-
# Use NodePort instead
161-
kubectl patch svc devmachine-service -p '{"spec":{"type":"NodePort"}}'
162-
163-
# Or use port-forwarding
164-
kubectl port-forward svc/devmachine-service 2222:2222
165-
```
166-
167-
**Storage issues**
168-
```bash
169-
# Check storage class
170-
kubectl get storageclass
94+
# Debug connection
95+
kubectl exec -it devmachine-0 -- ss -tuln | grep 2222
17196
172-
# Check PVC status
97+
# Storage issues
17398
kubectl get pvc
99+
kubectl describe pvc home-volume-devmachine-0
174100
```
175101

176-
### Debug Commands
102+
## 📁 Directory Structure
177103

178-
```bash
179-
# Check service endpoints
180-
kubectl get endpoints devmachine-service
181-
182-
# Describe pod for events
183-
kubectl describe pod devmachine-0
184-
185-
# Test SSH service inside pod
186-
kubectl exec devmachine-0 -- ss -tuln | grep 2222
187-
```
188-
189-
## 📊 Operations
190-
191-
### Backup
192-
```bash
193-
# Backup home directory
194-
kubectl exec devmachine-0 -- tar czf - /home/dev > backup.tar.gz
195-
196-
# Restore
197-
kubectl exec -i devmachine-0 -- tar xzf - -C / < backup.tar.gz
198104
```
199-
200-
### Updates
201-
```bash
202-
# Update image tag in values.yaml, then:
203-
helm upgrade devmachine ./chart
204-
205-
# Rolling restart
206-
kubectl rollout restart statefulset/devmachine
207-
```
208-
209-
### Scaling
210-
```bash
211-
# Scale to multiple instances
212-
helm upgrade devmachine ./chart --set replicaCount=3
105+
/home/dev/
106+
├── .ssh/authorized_keys # SSH keys
107+
├── venv/ # Python venv (auto-activated)
108+
├── bin/ # Your binaries or optional bin/go installation
109+
└── projects/ # Your code
213110
```
214111
215112
## 🔒 Security
216113
217-
- Runs as non-root user (UID 1001)
218-
- Password authentication disabled
219-
- Key-based SSH authentication only
114+
- Non-root user (UID 1001)
115+
- Key-based SSH only
220116
- Seccomp profile enabled
221-
- Read-only root filesystem (where possible)
222-
223-
## 🤝 Contributing
224-
225-
1. Fork the repository
226-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
227-
3. Commit your changes (`git commit -m 'Add amazing feature'`)
228-
4. Push to the branch (`git push origin feature/amazing-feature`)
229-
5. Open a Pull Request
230-
231-
## 🙏 Acknowledgments
232-
233-
- Built with Debian Bookworm Slim
234-
- Uses HashiCorp tools (Terraform, Packer)
235-
- Ansible automation platform
236-
- Kubernetes community
117+
- No privilege escalation
237118
238119
---
239120
240-
> **Note**: This development machine is designed for development and testing purposes. Consider additional security measures for production environments.
121+
Perfect for remote development with persistent storage and full tool access with VSCode!

chart/values.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
replicaCount: 1
22

33
image:
4-
source: ghcr.io/syntax3rror404/k8s-devmachine@sha256:989cf449c639285da581399c36e12c83401ad7583dd44231ef1d2b7c95759aa7
4+
source: ghcr.io/syntax3rror404/k8s-devmachine@sha256:510352ea9a57812d776f095fbc51244349a0d89913e3a5af08ed365fd344bc4b
55
pullPolicy: IfNotPresent
66

77
service:
@@ -24,7 +24,6 @@ ssh:
2424
# Place auth keys here ...
2525
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu...
2626
27-
2827
securityContext:
2928
runAsNonRoot: true
3029
runAsUser: 1001

0 commit comments

Comments
 (0)