shared-sqs: Этапы 7+8 — Dockerfile, K8s manifests, Makefile
This commit is contained in:
+14
-25
@@ -1,28 +1,17 @@
|
||||
# build image
|
||||
FROM golang:alpine as build
|
||||
# Dockerfile — shared-sqs multi-stage build
|
||||
# Updated: 2026-04-09
|
||||
|
||||
WORKDIR /go/src/github.com/Admiral-Piett/goaws
|
||||
|
||||
COPY ./app/ ./app/
|
||||
COPY ./go.mod .
|
||||
COPY ./go.sum .
|
||||
|
||||
RUN ls -la
|
||||
RUN CGO_ENABLED=0 go test ./app/...
|
||||
RUN go build -o goaws app/cmd/goaws.go
|
||||
|
||||
# release image
|
||||
FROM alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /go/src/github.com/Admiral-Piett/goaws/goaws ./goaws
|
||||
|
||||
COPY app/conf/goaws.yaml ./conf/
|
||||
FROM golang:1.22-alpine AS builder
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -o shared-sqs app/cmd/goaws.go
|
||||
|
||||
FROM alpine:3.19
|
||||
RUN apk --no-cache add ca-certificates
|
||||
COPY --from=builder /build/shared-sqs /usr/local/bin/shared-sqs
|
||||
EXPOSE 4100
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
|
||||
CMD wget localhost:4100/health -q -O - > /dev/null
|
||||
|
||||
ENTRYPOINT ["./goaws"]
|
||||
HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
|
||||
CMD wget -q -O - http://localhost:4100/health || exit 1
|
||||
ENTRYPOINT ["shared-sqs"]
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Makefile — shared-sqs
|
||||
# Created: 2026-04-09
|
||||
|
||||
IMAGE_REPO=pearlharbor.registryk8s.services.ngcloud.ru/naeel/shared-sqs
|
||||
VERSION=v0.1.0
|
||||
BINARY=shared-sqs
|
||||
|
||||
.PHONY: build docker-build docker-push test run clean
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 go build -o $(BINARY) app/cmd/goaws.go
|
||||
|
||||
docker-build:
|
||||
docker build -t $(IMAGE_REPO):$(VERSION) .
|
||||
|
||||
docker-push:
|
||||
docker push $(IMAGE_REPO):$(VERSION)
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
run:
|
||||
./$(BINARY) --admin-token=dev-token-123 --port=4100 --debug
|
||||
|
||||
clean:
|
||||
rm -f $(BINARY)
|
||||
@@ -0,0 +1,55 @@
|
||||
# deployments/k8s/deployment.yaml
|
||||
# Deployment shared-sqs — strategy Recreate (НЕ RollingUpdate: in-memory state, Trap #14)
|
||||
# Created: 2026-04-09
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: shared-sqs
|
||||
namespace: shared-sqs
|
||||
labels:
|
||||
app: shared-sqs
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: shared-sqs
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: shared-sqs
|
||||
spec:
|
||||
containers:
|
||||
- name: shared-sqs
|
||||
image: pearlharbor.registryk8s.services.ngcloud.ru/naeel/shared-sqs:v0.1.0
|
||||
ports:
|
||||
- containerPort: 4100
|
||||
name: http
|
||||
env:
|
||||
- name: SHARED_SQS_ADMIN_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: shared-sqs-admin
|
||||
key: token
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "500m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 4100
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 4100
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 5
|
||||
imagePullSecrets:
|
||||
- name: pearlharbor-registry-secret
|
||||
@@ -0,0 +1,9 @@
|
||||
# deployments/k8s/namespace.yaml
|
||||
# Namespace для shared-sqs сервиса
|
||||
# Created: 2026-04-09
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: shared-sqs
|
||||
labels:
|
||||
app: shared-sqs
|
||||
@@ -0,0 +1,13 @@
|
||||
# deployments/k8s/secret.yaml
|
||||
# Секрет для admin token shared-sqs
|
||||
# Created: 2026-04-09
|
||||
# ВНИМАНИЕ: заполнить реальным токеном перед деплоем
|
||||
# kubectl create secret generic shared-sqs-admin --from-literal=token=YOUR_TOKEN -n shared-sqs
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: shared-sqs-admin
|
||||
namespace: shared-sqs
|
||||
type: Opaque
|
||||
stringData:
|
||||
token: "REPLACE_WITH_REAL_TOKEN"
|
||||
@@ -0,0 +1,19 @@
|
||||
# deployments/k8s/service.yaml
|
||||
# Service для shared-sqs
|
||||
# Created: 2026-04-09
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: shared-sqs
|
||||
namespace: shared-sqs
|
||||
labels:
|
||||
app: shared-sqs
|
||||
spec:
|
||||
selector:
|
||||
app: shared-sqs
|
||||
ports:
|
||||
- name: http
|
||||
port: 4100
|
||||
targetPort: 4100
|
||||
protocol: TCP
|
||||
type: ClusterIP
|
||||
Reference in New Issue
Block a user