Skip to content

Commit 1601c9c

Browse files
committed
Updated deployment file
1 parent dae3e93 commit 1601c9c

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

.github/workflows/deploy-azure.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,14 @@ jobs:
4343
- name: Import Existing Resources
4444
run: |
4545
cd infra/azure
46+
chmod +x ./import_resources.sh
4647
ENVIRONMENT=${{ env.ENVIRONMENT }} \
4748
SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }} \
4849
TENANT_ID=${{ secrets.AZURE_TENANT_ID }} \
4950
OBJECT_ID=${{ secrets.AZURE_SP_OBJECT_ID }} \
5051
CI_MODE=true \
5152
./import_resources.sh
5253
53-
- name: Terraform Plan
54-
run: |
55-
cd infra/azure
56-
terraform plan -var="environment=${{ env.ENVIRONMENT }}" \
57-
-var="memgraph_username=${{ secrets.MEMGRAPH_USERNAME }}" \
58-
-var="memgraph_password=${{ secrets.MEMGRAPH_PASSWORD }}" \
59-
-var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}" \
60-
-var="tenant_id=${{ secrets.AZURE_TENANT_ID }}" \
61-
-var="object_id=${{ secrets.AZURE_SP_OBJECT_ID }}"
62-
6354
- name: Terraform Apply
6455
run: |
6556
cd infra/azure
@@ -107,33 +98,24 @@ jobs:
10798
done
10899
fi
109100
110-
# Create a credentials hash to force pod restart when credentials change using maximum security approach
111-
# Create a random file name to prevent predictable access
112-
TEMP_FILE=$(mktemp)
113-
114-
# Write credentials directly to file descriptor to prevent command line visibility
115-
{
116-
printf "%s" "${{ secrets.MEMGRAPH_USERNAME }}"
117-
printf "%s" "${{ secrets.MEMGRAPH_PASSWORD }}"
118-
} > "$TEMP_FILE"
119-
120-
# Generate hash and immediately remove the file
121-
CREDENTIALS_HASH=$(sha256sum "$TEMP_FILE" | awk '{print $1}')
122-
rm -f "$TEMP_FILE"
123-
124-
# Store hash in environment variable for later use
101+
# Create a credentials hash to force pod restart when credentials change
102+
CREDENTIALS_HASH=$(echo -n "${{ secrets.MEMGRAPH_USERNAME }}${{ secrets.MEMGRAPH_PASSWORD }}" | sha256sum | awk '{print $1}')
125103
echo "CREDENTIALS_HASH=$CREDENTIALS_HASH" >> $GITHUB_ENV
126104
127-
# Apply the kubernetes secret with the new credentials
105+
# Create secret directly using kubectl command
128106
kubectl create secret generic memgraph-credentials \
129-
--from-literal=username=${{ secrets.MEMGRAPH_USERNAME }} \
130-
--from-literal=password=${{ secrets.MEMGRAPH_PASSWORD }} \
107+
--from-literal=username="${{ secrets.MEMGRAPH_USERNAME }}" \
108+
--from-literal=password="${{ secrets.MEMGRAPH_PASSWORD }}" \
131109
--dry-run=client -o yaml | kubectl apply -f -
110+
111+
echo "Memgraph credentials secret created successfully"
132112
133113
- name: Deploy to AKS
134114
run: |
135-
# Replace the placeholder with the actual credentials hash
136-
cat infra/k8s/memgraph.yaml | CREDENTIALS_HASH=${CREDENTIALS_HASH} envsubst > memgraph_deploy.yaml
115+
# Replace the placeholder with the actual credentials hash and environment
116+
cat infra/k8s/memgraph.yaml | \
117+
sed "s/\${CREDENTIALS_HASH}/$CREDENTIALS_HASH/g" | \
118+
sed "s/\${ENVIRONMENT}/${{ env.ENVIRONMENT }}/g" > memgraph_deploy.yaml
137119
138120
# Apply the updated deployment manifest
139121
kubectl apply -f memgraph_deploy.yaml
@@ -167,7 +149,7 @@ jobs:
167149
sleep 30
168150
fi
169151
170-
# Wait for pod to be ready with increased timeout and check interval
152+
# Wait for pod to be ready with increased timeout
171153
if ! kubectl wait --for=condition=ready pod -l app=memgraph --timeout=10m; then
172154
echo "Error: Memgraph pod did not become ready within the timeout period."
173155
echo "Checking Memgraph pod logs:"
@@ -212,4 +194,14 @@ jobs:
212194
echo "Warning: Could not obtain external IP for Memgraph service within timeout."
213195
echo "Checking LoadBalancer service status:"
214196
kubectl describe service memgraph
197+
else
198+
MEMGRAPH_HOST="memgraph-aiagent-${{ env.ENVIRONMENT }}.${{ env.AZURE_LOCATION }}.cloudapp.azure.com"
199+
echo "=========================================================="
200+
echo "Memgraph Connection Information:"
201+
echo "Host: $MEMGRAPH_HOST"
202+
echo "Port: 7687 (Bolt), 7444 (HTTP API), 3000 (UI)"
203+
echo "Username: ${{ secrets.MEMGRAPH_USERNAME }}"
204+
echo "Password: [Configured in secrets]"
205+
echo "Connection URL: bolt://${{ secrets.MEMGRAPH_USERNAME }}@$MEMGRAPH_HOST:7687"
206+
echo "=========================================================="
215207
fi

infra/azure/import_resources.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ fi
5858

5959
# Import Key Vault Secrets if they exist
6060
if az keyvault show --name "$KV_NAME" --resource-group "$RESOURCE_GROUP" &>/dev/null; then
61-
# Check for memgraph-username secret
61+
# Check for memgraph-username secret - get specific version
6262
if az keyvault secret show --name "memgraph-username" --vault-name "$KV_NAME" &>/dev/null; then
63-
SECRET_URI=$(az keyvault secret show --name "memgraph-username" --vault-name "$KV_NAME" --query id -o tsv)
64-
terraform import azurerm_key_vault_secret.memgraph_username "$SECRET_URI" || true
63+
SECRET_ID=$(az keyvault secret show --name "memgraph-username" --vault-name "$KV_NAME" --query id -o tsv)
64+
terraform import azurerm_key_vault_secret.memgraph_username "$SECRET_ID" || true
6565
fi
6666

67-
# Check for memgraph-password secret
67+
# Check for memgraph-password secret - get specific version
6868
if az keyvault secret show --name "memgraph-password" --vault-name "$KV_NAME" &>/dev/null; then
69-
SECRET_URI=$(az keyvault secret show --name "memgraph-password" --vault-name "$KV_NAME" --query id -o tsv)
70-
terraform import azurerm_key_vault_secret.memgraph_password "$SECRET_URI" || true
69+
SECRET_ID=$(az keyvault secret show --name "memgraph-password" --vault-name "$KV_NAME" --query id -o tsv)
70+
terraform import azurerm_key_vault_secret.memgraph_password "$SECRET_ID" || true
7171
fi
7272
fi
7373

@@ -97,4 +97,6 @@ fi
9797
# Clean up the temporary tfvars file if in CI mode
9898
if [ "$CI_MODE" = "true" ]; then
9999
rm -f terraform.tfvars
100-
fi
100+
fi
101+
102+
echo "Resource import completed!"

infra/k8s/memgraph.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,26 @@ spec:
7171
mountPath: /etc/memgraph
7272
resources:
7373
requests:
74-
memory: "512Mi"
75-
cpu: "250m"
76-
limits:
7774
memory: "1Gi"
7875
cpu: "500m"
76+
limits:
77+
memory: "2Gi"
78+
cpu: "1000m"
7979
livenessProbe:
8080
httpGet:
8181
path: /api/v1/storage/status
8282
port: 7444
83-
initialDelaySeconds: 30
83+
initialDelaySeconds: 60
8484
periodSeconds: 30
85+
timeoutSeconds: 10
86+
failureThreshold: 3
87+
readinessProbe:
88+
httpGet:
89+
path: /api/v1/storage/status
90+
port: 7444
91+
initialDelaySeconds: 30
92+
periodSeconds: 15
93+
timeoutSeconds: 5
8594
volumes:
8695
- name: data
8796
persistentVolumeClaim:

0 commit comments

Comments
 (0)