henriqueatila/golang-gin-best-practices / skills/golang-gin-deploy
golang-gin-deploy
VerifiedDeploy Go Gin APIs with Docker, docker-compose, Kubernetes. Use when Dockerizing a Go app, setting up docker-compose, deploying to K8s, or configuring CI/CD and health probes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.4 KB |
| metadata.json | config | 481 B |
| references/configuration-docker-quickref.md | markdown | 2.9 KB |
| references/configuration-health-and-config-loader.md | markdown | 3.1 KB |
| references/docker-compose-dev-setup.md | markdown | 3.4 KB |
| references/docker-compose-test-and-prod.md | markdown | 5.0 KB |
| references/dockerfile-build-args-security-and-healthcheck.md | markdown | 3.2 KB |
| references/dockerfile-multistage-and-base-images.md | markdown | 3.1 KB |
| references/dockerfile-size-optimization-and-complete-example.md | markdown | 3.1 KB |
| references/kubernetes-complete-helm-cicd.md | markdown | 3.5 KB |
| references/kubernetes-deployment-service-config.md | markdown | 3.5 KB |
| references/kubernetes-probes-hpa-ingress-pvc.md | markdown | 3.8 KB |
| references/observability-docker-stack-and-shutdown.md | markdown | 4.0 KB |
| references/observability-metrics-logs-sampling.md | markdown | 4.4 KB |
| references/observability-otel-sdk-and-middleware.md | markdown | 4.2 KB |
references/kubernetes-deployment-service-config.md
View on GitHub# Kubernetes — Deployment, Service, ConfigMap, and Secret
> Kubernetes patterns for Go Gin APIs. Not part of the Gin framework — mainstream cloud-native Go community patterns.
## Deployment Manifest
```yaml
# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: myapp
labels:
app: myapp
spec:
replicas: 2
selector:
matchLabels:
app: myapp
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0 # never reduce below desired replicas during update
maxSurge: 1 # allow one extra pod during rollout
template:
metadata:
labels:
app: myapp
spec:
terminationGracePeriodSeconds: 30
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: myapp
topologyKey: kubernetes.io/hostname
containers:
- name: myapp
image: ghcr.io/myorg/myapp:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
envFrom:
- configMapRef:
name: myapp-config
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: myapp-secret
key: database-url
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: myapp-secret
key: jwt-secret
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
# probes: see kubernetes-probes-hpa-ingress-pvc.md
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65532
capabilities:
drop: ["ALL"]
securityContext:
seccompProfile:
type: RuntimeDefault
```
---
## Service Manifest
```yaml
# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
name: myapp
namespace: myapp
spec:
type: ClusterIP
selector:
app: myapp
ports:
- name: http
port: 80
targetPort: http
```
| Type | Use case |
|------|----------|
| `ClusterIP` | Internal only — use with Ingress |
| `NodePort` | Dev/testing only |
| `LoadBalancer` | Cloud provider external LB |
---
## ConfigMap and Secret
```yaml
# k8s/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp-config
namespace: myapp
data:
PORT: "8080"
GIN_MODE: "release"
READ_TIMEOUT: "10s"
WRITE_TIMEOUT: "10s"
SHUTDOWN_TIMEOUT: "30s"
```
```yaml
# k8s/secret.yaml — values must be base64-encoded
apiVersion: v1
kind: Secret
metadata:
name: myapp-secret
namespace: myapp
type: Opaque
data:
database-url: <base64>
jwt-secret: <base64>
```
**Critical:** Never commit real Secret values. Use Vault, AWS Secrets Manager, or External Secrets Operator.
```bash
# Preferred: create secret from CLI (avoids base64 in files)
kubectl create secret generic myapp-secret \
--from-literal=database-url="postgres://..." \
--from-literal=jwt-secret="..." \
--namespace=myapp
```
> For probes, HPA, Ingress, PVC, PDB, NetworkPolicy: see [kubernetes-probes-hpa-ingress-pvc.md](kubernetes-probes-hpa-ingress-pvc.md). For complete manifests, Helm, and CI/CD: see [kubernetes-complete-helm-cicd.md](kubernetes-complete-helm-cicd.md).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |