Post
Cancel

Shlink Kubernetes Cheat Sheet

Shlink Kubernetes Cheat Sheet

Quick Commands

Status Checks

1
2
3
4
5
6
7
8
9
10
11
12
# All pods
kubectl get pods -n shlink

# Services
kubectl get svc -n shlink

# Secrets
kubectl get secrets -n shlink

# Logs
kubectl logs -n shlink -l app=shlink --tail=50
kubectl logs -n shlink -l app=shlink-db --tail=50

Create Short URL

1
2
3
4
5
6
7
8
# Get API key
API_KEY=$(kubectl get secret shlink-app-secret -n shlink -o jsonpath='{.data.INITIAL_API_KEY}' | base64 -d)

# Create short URL
curl -X POST https://sh.yourdomain.com/rest/v3/short-urls \
  -H "X-Api-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"longUrl": "https://example.com", "customSlug": "ex"}'

List Short URLs

1
2
curl https://sh.yourdomain.com/rest/v3/short-urls \
  -H "X-Api-Key: $API_KEY"

Backup & Restore

1
2
3
4
5
6
7
# Backup
kubectl exec -n shlink $(kubectl get pod -n shlink -l app=shlink-db -o jsonpath='{.items[0].metadata.name}') \
  -- mysqldump -u root -pYOUR_ROOT_PASSWORD --all-databases > backup.sql

# Restore
kubectl exec -i -n shlink $(kubectl get pod -n shlink -l app=shlink-db -o jsonpath='{.items[0].metadata.name}') \
  -- mysql -u root -pYOUR_ROOT_PASSWORD < backup.sql

Scale

1
2
3
4
5
# Scale up
kubectl scale deployment shlink -n shlink --replicas=3

# Scale down
kubectl scale deployment shlink -n shlink --replicas=1

Update

1
2
3
4
5
# Update image
kubectl set image deployment/shlink shlink=shlinkio/shlink:4.3.0 -n shlink

# Restart
kubectl rollout restart deployment shlink -n shlink

Delete

1
2
# Delete everything
kubectl delete namespace shlink
Featured Blog Posts
Disclaimer
The postings on this site are my own and don`t necessarily represent Harian Jogja positions, strategies or opinions.
Contents