ci: streamline server deployment by reducing SSH prompts
Generate a temporary merged YAML file locally before copying to the server. This reduces the number of SSH/SCP commands from multiple to two, minimizing password prompts and connection overhead.
This commit is contained in:
14
Makefile
14
Makefile
@@ -21,12 +21,14 @@ deploy: build
|
|||||||
|
|
||||||
deploy-server:
|
deploy-server:
|
||||||
@echo "Deploying to remote server $(SERVER_IP)..."
|
@echo "Deploying to remote server $(SERVER_IP)..."
|
||||||
ssh $(SERVER_USER)@$(SERVER_IP) "mkdir -p $(SERVER_PATH)/k8s"
|
@# Generate temporary merged YAML for server
|
||||||
scp .env $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/.env
|
@kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > k8s/server_deploy.yaml
|
||||||
scp k8s/deployment.yaml $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/k8s/deployment.yaml
|
@echo "---" >> k8s/server_deploy.yaml
|
||||||
ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && \
|
@cat k8s/deployment.yaml >> k8s/server_deploy.yaml
|
||||||
kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml | kubectl apply -f - && \
|
@# Single SCP/SSH call to reduce password prompts
|
||||||
kubectl apply -f k8s/deployment.yaml"
|
scp k8s/server_deploy.yaml $(SERVER_USER)@$(SERVER_IP):/tmp/server_deploy.yaml
|
||||||
|
ssh $(SERVER_USER)@$(SERVER_IP) "kubectl apply -f /tmp/server_deploy.yaml && rm /tmp/server_deploy.yaml"
|
||||||
|
@rm k8s/server_deploy.yaml
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
|
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user