chore: ci文件补充 #1
							
								
								
									
										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 | ||||
| app/services/sales-api/sales-api | ||||
							
								
								
									
										23
									
								
								makefile
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								makefile
									
									
									
									
									
								
							| @ -9,14 +9,14 @@ build: | ||||
| # =========================================================
 | ||||
| # Building containers
 | ||||
| 
 | ||||
| VERSION :=1.0 | ||||
| VERSION :=1.1 | ||||
| 
 | ||||
| all: service | ||||
| all: sales-api | ||||
| 
 | ||||
| service: | ||||
| sales-api: | ||||
| 	docker build \
 | ||||
|     -f zarf/docker/Dockerfile \
 | ||||
|     -t service-amd64:$(VERSION) \
 | ||||
|     -f zarf/docker/dockerfile.sales-api \
 | ||||
|     -t sales-api-amd64:$(VERSION) \
 | ||||
|     --build-arg BUILD_REF=$(VERSION) \
 | ||||
|     --build-arg BUILD_DATA=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
 | ||||
|     . | ||||
| @ -31,7 +31,7 @@ kind-up: | ||||
| 		--image kindest/node:v1.21.1 \
 | ||||
| 		--name $(KIND_CLUSTER) \
 | ||||
| 		--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 delete cluster --name $(KIND_CLUSTER) | ||||
| @ -42,16 +42,17 @@ kind-status: | ||||
| 	kubectl get pods -o wide | ||||
| 
 | ||||
| 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: | ||||
| 	kustomize build zarf/k8s/kind/service-pod|kubectl apply -f - | ||||
| 	kustomize build zarf/k8s/kind/sales-pod|kubectl apply -f - | ||||
| 
 | ||||
| kind-logs: | ||||
| 	kubectl logs -f -l app=service --all-containers=true | ||||
| 	kubectl logs -f -l app=sales --all-containers=true | ||||
| 
 | ||||
| kind-restart: | ||||
| 	kubectl rollout restart deployment service-pod | ||||
| 	kubectl rollout restart deployment sales-pod | ||||
| 
 | ||||
| kind-update: all kind-load kind-restart | ||||
| 
 | ||||
| @ -60,7 +61,7 @@ kind-update-apply: all kind-load kind-apply | ||||
| kind-describe: | ||||
| 	kubectl describe node | ||||
| 	kubectl describe svc | ||||
| 	kubectl describe deployment service-pod | ||||
| 	kubectl describe deployment sales-pod | ||||
| 
 | ||||
| # =========================================================
 | ||||
| # Modules support
 | ||||
|  | ||||
| @ -8,7 +8,7 @@ ARG BUILD_REF | ||||
| COPY . /service | ||||
| 
 | ||||
| # Build the service binary | ||||
| WORKDIR /service | ||||
| WORKDIR /service/app/services/sales-api | ||||
| 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 | ||||
| ARG BUILD_DATE | ||||
| 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 | ||||
| CMD ["./service"] | ||||
| CMD ["./sales-api"] | ||||
| 
 | ||||
| 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.title="sales-api" \ | ||||
|       org.opencontainers.image.author="Xiaoweihong" \ | ||||
|       org.opencontainers.image.source="https://git.hongxiaowei.com/xiaowei/service/app/sales-api" \ | ||||
|       org.opencontainers.image.revision="${BUILD_REF}" \ | ||||
|       org.opencontainers.image.vendor="Xiao Wei" | ||||
| @ -1,26 +1,26 @@ | ||||
| apiVersion: v1 | ||||
| kind: Namespace | ||||
| metadata: | ||||
|   name: service-system | ||||
|   name: sales-system | ||||
| --- | ||||
| apiVersion: apps/v1 | ||||
| kind: Deployment | ||||
| metadata: | ||||
|   name: service-pod | ||||
|   namespace: service-system | ||||
|   name: sales-pod | ||||
|   namespace: sales-system | ||||
| spec: | ||||
|   replicas: 1 | ||||
|   selector: | ||||
|     matchLabels: | ||||
|       app: service | ||||
|       app: sales | ||||
|   strategy: | ||||
|     type: Recreate | ||||
|   template: | ||||
|     metadata: | ||||
|       labels: | ||||
|         app: service | ||||
|         app: sales | ||||
|     spec: | ||||
|       hostNetwork: true | ||||
|       containers: | ||||
|         - name: service-api | ||||
|           image: service-amd64:1.0 | ||||
|         - name: sales-api | ||||
|           image: sales-api-image | ||||
| @ -1,4 +1,4 @@ | ||||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||||
| kind: Kustomization | ||||
| resources: | ||||
|   - ./base-service.yaml | ||||
|   - ./base-sales.yaml | ||||
| @ -1,23 +1,23 @@ | ||||
| apiVersion: apps/v1 | ||||
| kind: Deployment | ||||
| metadata: | ||||
|   name: service-pod | ||||
|   namespace: service-system | ||||
|   name: sales-pod | ||||
|   namespace: sales-system | ||||
| spec: | ||||
|   replicas: 1 | ||||
|   strategy: | ||||
|     type: Recreate | ||||
|   selector: | ||||
|     matchLabels: | ||||
|       app: service | ||||
|       app: sales | ||||
|   template: | ||||
|     metadata: | ||||
|       labels: | ||||
|         app: service | ||||
|         app: sales | ||||
|     spec: | ||||
|       containers: | ||||
|         # service container configuration | ||||
|         - name: service-api | ||||
|         # sales container configuration | ||||
|         - name: sales-api | ||||
|           resources: | ||||
|             limits: | ||||
|               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