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:
|
||||
@echo "Deploying to remote server $(SERVER_IP)..."
|
||||
ssh $(SERVER_USER)@$(SERVER_IP) "mkdir -p $(SERVER_PATH)/k8s"
|
||||
scp .env $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/.env
|
||||
scp k8s/deployment.yaml $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/k8s/deployment.yaml
|
||||
ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && \
|
||||
kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml | kubectl apply -f - && \
|
||||
kubectl apply -f k8s/deployment.yaml"
|
||||
@# Generate temporary merged YAML for server
|
||||
@kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > k8s/server_deploy.yaml
|
||||
@echo "---" >> k8s/server_deploy.yaml
|
||||
@cat k8s/deployment.yaml >> k8s/server_deploy.yaml
|
||||
@# Single SCP/SSH call to reduce password prompts
|
||||
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:
|
||||
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
|
||||
|
||||
Reference in New Issue
Block a user