Merge pull request 'chore: ci文件补充' (#1) from customize into master
Reviewed-on: #1
This commit is contained in:
commit
176599e9dc
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.git/
|
||||||
|
makefile
|
||||||
|
readme.md
|
||||||
|
zarf/docker
|
||||||
|
zarf/k8s
|
||||||
|
.dockerignore
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
app/services/sales-api/sales-api
|
23
makefile
23
makefile
@ -9,14 +9,14 @@ build:
|
|||||||
# =========================================================
|
# =========================================================
|
||||||
# Building containers
|
# Building containers
|
||||||
|
|
||||||
VERSION :=1.0
|
VERSION :=1.1
|
||||||
|
|
||||||
all: service
|
all: sales-api
|
||||||
|
|
||||||
service:
|
sales-api:
|
||||||
docker build \
|
docker build \
|
||||||
-f zarf/docker/Dockerfile \
|
-f zarf/docker/dockerfile.sales-api \
|
||||||
-t service-amd64:$(VERSION) \
|
-t sales-api-amd64:$(VERSION) \
|
||||||
--build-arg BUILD_REF=$(VERSION) \
|
--build-arg BUILD_REF=$(VERSION) \
|
||||||
--build-arg BUILD_DATA=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
--build-arg BUILD_DATA=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||||
.
|
.
|
||||||
@ -31,7 +31,7 @@ kind-up:
|
|||||||
--image kindest/node:v1.21.1 \
|
--image kindest/node:v1.21.1 \
|
||||||
--name $(KIND_CLUSTER) \
|
--name $(KIND_CLUSTER) \
|
||||||
--config zarf/k8s/kind/kind-config.yaml
|
--config zarf/k8s/kind/kind-config.yaml
|
||||||
kubectl config set-context --current --namespace service-system
|
kubectl config set-context --current --namespace sales-system
|
||||||
|
|
||||||
kind-down:
|
kind-down:
|
||||||
kind delete cluster --name $(KIND_CLUSTER)
|
kind delete cluster --name $(KIND_CLUSTER)
|
||||||
@ -42,16 +42,17 @@ kind-status:
|
|||||||
kubectl get pods -o wide
|
kubectl get pods -o wide
|
||||||
|
|
||||||
kind-load:
|
kind-load:
|
||||||
kind load docker-image service-amd64:$(VERSION) --name $(KIND_CLUSTER)
|
cd zarf/k8s/kind/sales-pod; kustomize edit set image sales-api-image=sales-api-amd64:$(VERSION)
|
||||||
|
kind load docker-image sales-api-amd64:$(VERSION) --name $(KIND_CLUSTER)
|
||||||
|
|
||||||
kind-apply:
|
kind-apply:
|
||||||
kustomize build zarf/k8s/kind/service-pod|kubectl apply -f -
|
kustomize build zarf/k8s/kind/sales-pod|kubectl apply -f -
|
||||||
|
|
||||||
kind-logs:
|
kind-logs:
|
||||||
kubectl logs -f -l app=service --all-containers=true
|
kubectl logs -f -l app=sales --all-containers=true
|
||||||
|
|
||||||
kind-restart:
|
kind-restart:
|
||||||
kubectl rollout restart deployment service-pod
|
kubectl rollout restart deployment sales-pod
|
||||||
|
|
||||||
kind-update: all kind-load kind-restart
|
kind-update: all kind-load kind-restart
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ kind-update-apply: all kind-load kind-apply
|
|||||||
kind-describe:
|
kind-describe:
|
||||||
kubectl describe node
|
kubectl describe node
|
||||||
kubectl describe svc
|
kubectl describe svc
|
||||||
kubectl describe deployment service-pod
|
kubectl describe deployment sales-pod
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Modules support
|
# Modules support
|
||||||
|
@ -8,7 +8,7 @@ ARG BUILD_REF
|
|||||||
COPY . /service
|
COPY . /service
|
||||||
|
|
||||||
# Build the service binary
|
# Build the service binary
|
||||||
WORKDIR /service
|
WORKDIR /service/app/services/sales-api
|
||||||
RUN go build -ldflags "-X main.build=${BUILD_REF}"
|
RUN go build -ldflags "-X main.build=${BUILD_REF}"
|
||||||
|
|
||||||
|
|
||||||
@ -17,13 +17,13 @@ RUN go build -ldflags "-X main.build=${BUILD_REF}"
|
|||||||
FROM alpine:3.14
|
FROM alpine:3.14
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
ARG BUILD_REF
|
ARG BUILD_REF
|
||||||
COPY --from=build_sales-api /service/service /service/service
|
COPY --from=build_sales-api /service/app/services/sales-api/sales-api /service/sales-api
|
||||||
WORKDIR /service
|
WORKDIR /service
|
||||||
CMD ["./service"]
|
CMD ["./sales-api"]
|
||||||
|
|
||||||
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
|
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
|
||||||
org.opencontainers.image.title="service" \
|
org.opencontainers.image.title="sales-api" \
|
||||||
org.opencontainers.image.author="xiaoweihong" \
|
org.opencontainers.image.author="Xiaoweihong" \
|
||||||
org.opencontainers.image.source="git.hongxiaowei.com/xiaowei/service" \
|
org.opencontainers.image.source="https://git.hongxiaowei.com/xiaowei/service/app/sales-api" \
|
||||||
org.opencontainers.image.revision="${BUILD_REF}" \
|
org.opencontainers.image.revision="${BUILD_REF}" \
|
||||||
org.opencontainers.image.vendor="Xiao Wei"
|
org.opencontainers.image.vendor="Xiao Wei"
|
@ -1,26 +1,26 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: service-system
|
name: sales-system
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: service-pod
|
name: sales-pod
|
||||||
namespace: service-system
|
namespace: sales-system
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: service
|
app: sales
|
||||||
strategy:
|
strategy:
|
||||||
type: Recreate
|
type: Recreate
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: service
|
app: sales
|
||||||
spec:
|
spec:
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
containers:
|
containers:
|
||||||
- name: service-api
|
- name: sales-api
|
||||||
image: service-amd64:1.0
|
image: sales-api-image
|
@ -1,4 +1,4 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- ./base-service.yaml
|
- ./base-sales.yaml
|
@ -1,23 +1,23 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: service-pod
|
name: sales-pod
|
||||||
namespace: service-system
|
namespace: sales-system
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
strategy:
|
strategy:
|
||||||
type: Recreate
|
type: Recreate
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: service
|
app: sales
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: service
|
app: sales
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
# service container configuration
|
# sales container configuration
|
||||||
- name: service-api
|
- name: sales-api
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: "1000m" # Up to 2 full cores
|
cpu: "1000m" # Up to 2 full cores
|
10
zarf/k8s/kind/sales-pod/kustomization.yaml
Normal file
10
zarf/k8s/kind/sales-pod/kustomization.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- ../../base/sales-pod/
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- kind-sales-patch.yaml
|
||||||
|
images:
|
||||||
|
- name: sales-api-image
|
||||||
|
newName: sales-api-amd64
|
||||||
|
newTag: "1.1"
|
@ -1,6 +0,0 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
resources:
|
|
||||||
- ../../base/service-pod/
|
|
||||||
patchesStrategicMerge:
|
|
||||||
- kind-servicepatch.yaml
|
|
Loading…
Reference in New Issue
Block a user