init: 基础部署文件(项目可参考)
This commit is contained in:
29
zarf/docker/Dockerfile
Normal file
29
zarf/docker/Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# Build the Go Binary
|
||||
FROM golang:1.17 as build_sales-api
|
||||
ENV CGO_ENABLE 0
|
||||
ENV GOPROXY https://goproxy.io,direct
|
||||
ARG BUILD_REF
|
||||
|
||||
# Copy the source code into the container
|
||||
COPY . /service
|
||||
|
||||
# Build the service binary
|
||||
WORKDIR /service
|
||||
RUN go build -ldflags "-X main.build=${BUILD_REF}"
|
||||
|
||||
|
||||
# todo 设置时区
|
||||
# Run the Go Binary in Alpine
|
||||
FROM alpine:3.14
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_REF
|
||||
COPY --from=build_sales-api /service/service /service/service
|
||||
WORKDIR /service
|
||||
CMD ["./service"]
|
||||
|
||||
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
|
||||
org.opencontainers.image.title="service" \
|
||||
org.opencontainers.image.author="xiaoweihong" \
|
||||
org.opencontainers.image.source="git.hongxiaowei.com/xiaowei/service" \
|
||||
org.opencontainers.image.revision="${BUILD_REF}" \
|
||||
org.opencontainers.image.vendor="Xiao Wei"
|
||||
26
zarf/k8s/base/service-pod/base-service.yaml
Normal file
26
zarf/k8s/base/service-pod/base-service.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: service-system
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-pod
|
||||
namespace: service-system
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: service
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: service
|
||||
spec:
|
||||
hostNetwork: true
|
||||
containers:
|
||||
- name: service-api
|
||||
image: service-amd64:1.0
|
||||
4
zarf/k8s/base/service-pod/kustomization.yaml
Normal file
4
zarf/k8s/base/service-pod/kustomization.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- ./base-service.yaml
|
||||
2
zarf/k8s/kind/kind-config.yaml
Normal file
2
zarf/k8s/kind/kind-config.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
kind: Cluster
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
25
zarf/k8s/kind/service-pod/kind-servicepatch.yaml
Normal file
25
zarf/k8s/kind/service-pod/kind-servicepatch.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-pod
|
||||
namespace: service-system
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: service
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: service
|
||||
spec:
|
||||
containers:
|
||||
# service container configuration
|
||||
- name: service-api
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1000m" # Up to 2 full cores
|
||||
requests:
|
||||
cpu: "10m" # Use 1 full cores
|
||||
6
zarf/k8s/kind/service-pod/kustomization.yaml
Normal file
6
zarf/k8s/kind/service-pod/kustomization.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- ../../base/service-pod/
|
||||
patchesStrategicMerge:
|
||||
- kind-servicepatch.yaml
|
||||
Reference in New Issue
Block a user