Skip to content

Commit f8b03d1

Browse files
vredchenkoclaude
andcommitted
refactor: move k8s scripts to tools/k8s/ directory
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 4555ac9 commit f8b03d1

19 files changed

+45
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ ADRs document significant technical decisions:
124124
## Links
125125

126126
- [Documentation](https://diamondlightsource.github.io/smartem-decisions/)
127-
- [Project Board](https://github.com/orgs/DiamondLightSource/projects/33/views/1)
127+
- [Project Board](https://github.com/orgs/DiamondLightSource/projects/51/views/1)
128128
- [SmartEM Backend](https://github.com/DiamondLightSource/smartem-decisions)
129129

130130
## Licence

claude-code/shared/skills/devops/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Kubernetes deployment, container management, and CI/CD operations for the SmartE
2525
cd repos/DiamondLightSource/smartem-decisions
2626

2727
# Start local k3s cluster with all services
28-
./tools/dev-k8s.sh up
28+
./tools/k8s/dev-k8s.sh up
2929

3030
# Stop and cleanup
31-
./tools/dev-k8s.sh down
31+
./tools/k8s/dev-k8s.sh down
3232

3333
# Check cluster status
3434
kubectl get pods -n smartem-decisions

claude-code/smartem-decisions/REPO-GUIDELINES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ python -m alembic upgrade head
6565
python -m alembic revision --autogenerate -m "Description"
6666

6767
# Local Kubernetes operations
68-
./tools/dev-k8s.sh up # Start local k3s cluster with services
69-
./tools/dev-k8s.sh down # Stop cluster and cleanup
68+
./tools/k8s/dev-k8s.sh up # Start local k3s cluster with services
69+
./tools/k8s/dev-k8s.sh down # Stop cluster and cleanup
7070
```
7171

7272
## Project Architecture

claude-code/smartem-decisions/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"Bash(psql:*)",
3535
"Bash(pg_dump:*)",
3636
"Bash(pg_restore:*)",
37-
"Bash(./tools/dev-k8s.sh:*)",
37+
"Bash(./tools/k8s/dev-k8s.sh:*)",
3838
"Bash(./tools/*)",
3939
"WebFetch(domain:github.com)",
4040
"WebFetch(domain:diamondlightsource.github.io)",

docs/explanations/decisions/0006-sealed-secrets-kubernetes-secrets-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ be safely committed to version control whilst maintaining security.
4646

4747
Implementation will include:
4848
- Installation of sealed-secrets controller in each Kubernetes environment
49-
- Integration with existing deployment workflow via tools/generate-sealed-secrets.sh script
49+
- Integration with existing deployment workflow via tools/k8s/generate-sealed-secrets.sh script
5050
- Documentation in docs/how-to/manage-kubernetes-secrets.md for team procedures
5151
- Environment-specific encryption keys for development, staging, and production clusters
5252

docs/how-to/configure-environment-variables.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ HTTP_API_PORT=8000
5959
**Use Case**: Deploying SmartEM to local K8s cluster (k3s) for development.
6060

6161
**When to Use**:
62-
- Running `./tools/dev-k8s.sh up`
62+
- Running `./tools/k8s/dev-k8s.sh up`
6363
- Setting up local development cluster with all services
6464

6565
**Setup**:
@@ -89,7 +89,7 @@ RABBITMQ_PASSWORD=password
8989
```
9090

9191
**Used By**:
92-
- `./tools/dev-k8s.sh` script to create K8s Secrets and ConfigMaps
92+
- `./tools/k8s/dev-k8s.sh` script to create K8s Secrets and ConfigMaps
9393

9494
### 3. Kubernetes Staging: `.env.k8s.staging`
9595

@@ -109,7 +109,7 @@ cp .env.example.k8s.staging .env.k8s.staging
109109

110110
**Used By**:
111111
- CI/CD pipelines for staging deployments
112-
- `DEPLOY_ENV=staging ./tools/dev-k8s.sh up` (if adapted for remote clusters)
112+
- `DEPLOY_ENV=staging ./tools/k8s/dev-k8s.sh up` (if adapted for remote clusters)
113113

114114
### 4. Kubernetes Production: `.env.k8s.production`
115115

@@ -167,7 +167,7 @@ cp .env.example.k8s.development .env.k8s.development
167167
nano .env.k8s.development
168168

169169
# 3. Start K8s cluster (creates infrastructure)
170-
./tools/dev-k8s.sh up
170+
./tools/k8s/dev-k8s.sh up
171171

172172
# 4. .env is already configured to connect to K8s NodePorts
173173
# No changes needed unless you want custom ports
@@ -236,7 +236,7 @@ When running in Kubernetes:
236236

237237
```bash
238238
# 1. Start K8s cluster
239-
./tools/dev-k8s.sh up
239+
./tools/k8s/dev-k8s.sh up
240240

241241
# 2. Use .env (already configured for NodePorts)
242242
cat .env
@@ -261,7 +261,7 @@ cp .env.example.k8s.development .env.k8s.development
261261
# Edit with your credentials
262262

263263
# 2. Deploy
264-
./tools/dev-k8s.sh up
264+
./tools/k8s/dev-k8s.sh up
265265

266266
# 3. All services run in pods
267267
kubectl get pods -n smartem-decisions
@@ -280,7 +280,7 @@ kubectl get pods -n smartem-decisions
280280
test -f .env || cp .env.example .env
281281

282282
# 2. Start K8s cluster
283-
./tools/dev-k8s.sh up
283+
./tools/k8s/dev-k8s.sh up
284284

285285
# 3. Run E2E test (script loads .env automatically)
286286
./tools/run-e2e-test.sh

docs/how-to/deploy-kubernetes.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ For local development, use the convenient script that provides a docker-compose-
88

99
```bash
1010
# Start the development environment (equivalent to docker-compose up -d)
11-
./tools/dev-k8s.sh
11+
./tools/k8s/dev-k8s.sh
1212

1313
# Check status (equivalent to docker ps)
14-
./tools/dev-k8s.sh status
14+
./tools/k8s/dev-k8s.sh status
1515

1616
# View logs for a service
17-
./tools/dev-k8s.sh logs smartem-http-api
17+
./tools/k8s/dev-k8s.sh logs smartem-http-api
1818

1919
# Stop the environment (equivalent to docker-compose down)
20-
./tools/dev-k8s.sh down
20+
./tools/k8s/dev-k8s.sh down
2121

2222
# Restart everything
23-
./tools/dev-k8s.sh restart
23+
./tools/k8s/dev-k8s.sh restart
2424

2525
# Get help
26-
./tools/dev-k8s.sh --help
26+
./tools/k8s/dev-k8s.sh --help
2727
```
2828

2929
### Access URLs
@@ -55,14 +55,14 @@ deploying to any environment, you must generate the appropriate sealed secrets:
5555

5656
```bash
5757
# Auto-generate secure credentials for development
58-
./tools/generate-sealed-secrets.sh development
58+
./tools/k8s/generate-sealed-secrets.sh development
5959
```
6060

6161
### Generate Secrets for Production
6262

6363
```bash
6464
# Interactive credential input for production security
65-
./tools/generate-sealed-secrets.sh production
65+
./tools/k8s/generate-sealed-secrets.sh production
6666
```
6767

6868
Sealed secrets are encrypted with the cluster's public key and safe to commit to version control. The sealed-secrets

docs/how-to/manage-kubernetes-secrets.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ The project includes a convenient script that handles the entire sealed secret g
6262

6363
```bash
6464
# Generate secrets for development (auto-generated passwords)
65-
./tools/generate-sealed-secrets.sh development
65+
./tools/k8s/generate-sealed-secrets.sh development
6666

6767
# Generate secrets for production (interactive prompts)
68-
./tools/generate-sealed-secrets.sh production
68+
./tools/k8s/generate-sealed-secrets.sh production
6969

7070
# Generate secrets for all environments
71-
./tools/generate-sealed-secrets.sh all
71+
./tools/k8s/generate-sealed-secrets.sh all
7272
```
7373

7474
## Environment-Specific Workflows
@@ -78,7 +78,7 @@ The project includes a convenient script that handles the entire sealed secret g
7878
Development environments use automatically generated secure passwords for convenience:
7979

8080
```bash
81-
./tools/generate-sealed-secrets.sh development
81+
./tools/k8s/generate-sealed-secrets.sh development
8282
```
8383

8484
This will:
@@ -92,7 +92,7 @@ This will:
9292
Production and staging environments require interactive credential input for security:
9393

9494
```bash
95-
./tools/generate-sealed-secrets.sh production
95+
./tools/k8s/generate-sealed-secrets.sh production
9696
```
9797

9898
You'll be prompted to provide:
@@ -147,7 +147,7 @@ Regular secret rotation is essential for security. Follow these steps to rotate
147147

148148
```bash
149149
# Use the generation script with new credentials
150-
./tools/generate-sealed-secrets.sh production
150+
./tools/k8s/generate-sealed-secrets.sh production
151151
```
152152

153153
### 2. Apply Updated Secrets
@@ -274,7 +274,7 @@ For issues with the generation script:
274274

275275
```bash
276276
# Run with verbose output
277-
bash -x ./tools/generate-sealed-secrets.sh development
277+
bash -x ./tools/k8s/generate-sealed-secrets.sh development
278278

279279
# Check prerequisites manually
280280
kubectl cluster-info
@@ -326,7 +326,7 @@ For complex applications requiring multiple secret sources:
326326

327327
```bash
328328
# Database secrets
329-
./tools/generate-sealed-secrets.sh production
329+
./tools/k8s/generate-sealed-secrets.sh production
330330

331331
# Additional API secrets
332332
kubectl create secret generic api-secrets \
@@ -355,7 +355,7 @@ rm plain-secret.yaml
355355
## Files and Structure
356356

357357
```
358-
├── tools/generate-sealed-secrets.sh # Main secret generation script
358+
├── tools/k8s/generate-sealed-secrets.sh # Main secret generation script
359359
├── k8s/environments/
360360
│ ├── development/
361361
│ │ ├── secrets.yaml # Development sealed secrets

docs/how-to/run-backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The core backend service providing HTTP API, database operations, and message qu
66

77
```bash
88
# create env and launch service stack locally:
9-
./tools/dev-k8s.sh up
9+
./tools/k8s/dev-k8s.sh up
1010

1111
# launch RabbitMQ worker (consumer)
1212
python -m smartem_backend.consumer # ERROR level (default)

docs/how-to/run-e2e-dev-simulation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For the simplest test execution, use the automated test runner script:
88

99
```bash
1010
# Check k3s status first (DO NOT restart if already running)
11-
./tools/dev-k8s.sh status
11+
./tools/k8s/dev-k8s.sh status
1212

1313
# Run automated test (Test Type 2: Pre-Acquisition Agent Setup)
1414
./tools/run-e2e-test.sh
@@ -64,7 +64,7 @@ If you've already set up once and just need to run another test:
6464

6565
```bash
6666
# 1. Check k3s status (DO NOT restart if already running)
67-
./tools/dev-k8s.sh status
67+
./tools/k8s/dev-k8s.sh status
6868

6969
# 2. Prepare clean environment
7070
unset POSTGRES_HOST POSTGRES_PORT POSTGRES_DB POSTGRES_USER POSTGRES_PASSWORD
@@ -115,7 +115,7 @@ For testing multiple concurrent microscopes and acquisition sessions simultaneou
115115

116116
```bash
117117
# Check k3s status first (DO NOT restart if already running)
118-
./tools/dev-k8s.sh status
118+
./tools/k8s/dev-k8s.sh status
119119

120120
# Run multi-microscope test with 3 microscopes (default)
121121
./tools/run-e2e-test-multi-microscope.sh
@@ -239,7 +239,7 @@ The test setup simulates a complete SmartEM workflow:
239239
### Environment Setup
240240
- Python 3.12+ with venv activated: `source .venv/bin/activate`
241241
- Full development install: `pip install -e .[all]`
242-
- Local k3s cluster running: `./tools/dev-k8s.sh up`
242+
- Local k3s cluster running: `./tools/k8s/dev-k8s.sh up`
243243
- Environment file: `.env` (created from `.env.example` - see Environment File Setup below)
244244

245245
### Test Data
@@ -506,7 +506,7 @@ pkill -f uvicorn
506506
pkill -f fastapi
507507

508508
# 5. Verify k3s services are running (DO NOT restart if already running)
509-
./tools/dev-k8s.sh status
509+
./tools/k8s/dev-k8s.sh status
510510

511511
# 6. Clean RabbitMQ (restart to ensure empty queue)
512512
kubectl rollout restart deployment/rabbitmq -n smartem-decisions
@@ -773,7 +773,7 @@ pgrep -f "smartem_backend|smartem_agent|fsrecorder"
773773
rm -rf ../epu-test-dir
774774

775775
# Stop k3s cluster (if needed)
776-
./tools/dev-k8s.sh down
776+
./tools/k8s/dev-k8s.sh down
777777
```
778778

779779
## Troubleshooting

0 commit comments

Comments
 (0)