Skip to content

Commit f7e5e7b

Browse files
authored
Merge pull request #15 from gurekamsingh/LAP-31
Lap 31: Deployment Configuration and Documentation Updates
2 parents a3c1dcb + d9d5206 commit f7e5e7b

File tree

3 files changed

+127
-10
lines changed

3 files changed

+127
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@ env:
1111
EKS_CLUSTER_NAME: spreadsheet-app-cluster
1212

1313
jobs:
14+
build-and-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.8'
23+
24+
- name: Install UV
25+
run: |
26+
curl -LsSf https://astral.sh/uv/install.sh | sh
27+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
28+
29+
- name: Install dependencies
30+
run: |
31+
uv pip install -e .
32+
uv pip install pytest pytest-cov
33+
34+
- name: Run tests
35+
run: |
36+
pytest --cov=backend tests/
37+
38+
- name: Build Docker image
39+
run: |
40+
docker build -t spreadsheet-app:${{ github.sha }} .
41+
1442
deploy:
43+
needs: build-and-test
1544
runs-on: ubuntu-latest
1645
steps:
1746
- uses: actions/checkout@v3

README.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,115 @@ The Spreadsheet Application is a modern web-based solution for managing sales da
113113

114114
3. **Access Application**
115115
Open http://localhost:5000 in your browser
116+
117+
Note: Make sure Redis server is running and the application has started successfully. You should see the login page when accessing the URL.
116118

117119
#### EKS Deployment
118120

119121
1. **Configure AWS CLI**
120122
```bash
121123
aws configure
124+
# Enter your AWS Access Key ID
125+
# Enter your AWS Secret Access Key
126+
# Enter your default region (e.g., us-west-2)
127+
# Enter your preferred output format (json)
122128
```
123129

124130
2. **Create EKS Cluster**
125131
```bash
126-
eksctl create cluster --name spreadsheet-app --region your-region --nodegroup-name standard-workers --node-type t3.medium --nodes 3 --nodes-min 1 --nodes-max 4 --managed
132+
# Create cluster using the provided configuration
133+
eksctl create cluster -f kubernetes/eks-cluster.yaml
134+
135+
# Verify cluster creation
136+
eksctl get cluster --name spreadsheet-app-cluster --region us-west-2
127137
```
128138

129-
3. **Deploy Application**
139+
3. **Update kubeconfig**
130140
```bash
131-
kubectl apply -f kubernetes/
141+
# Update kubeconfig to connect to your cluster
142+
aws eks update-kubeconfig --name spreadsheet-app-cluster --region us-west-2
143+
144+
# Verify connection
145+
kubectl config current-context
132146
```
133147

134-
4. **Access Application**
148+
4. **Deploy Application**
135149
```bash
136-
kubectl get svc spreadsheet-app-service
150+
# Create namespace
151+
kubectl create namespace spreadsheet-app
152+
153+
# Deploy Redis
154+
kubectl apply -f kubernetes/redis.yaml
155+
156+
# Deploy main application
157+
kubectl apply -f kubernetes/deployment.yaml
158+
159+
# Deploy ingress (if needed)
160+
kubectl apply -f kubernetes/ingress.yaml
161+
```
162+
163+
5. **Monitor Deployment**
164+
```bash
165+
# Check pod status
166+
kubectl get pods -n spreadsheet-app
167+
168+
# Check service status
169+
kubectl get svc -n spreadsheet-app
170+
171+
# View application logs
172+
kubectl logs -n spreadsheet-app deployment/spreadsheet-app
173+
```
174+
175+
6. **Access Application**
176+
There are multiple ways to access your application in EKS:
177+
178+
a. **Using LoadBalancer (Recommended for Production)**
179+
```bash
180+
# Get the LoadBalancer URL
181+
kubectl get svc spreadsheet-app-service -n spreadsheet-app -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
182+
```
183+
The application will be available at: `http://<loadbalancer-url>`
184+
- This URL is publicly accessible
185+
- It may take a few minutes for the LoadBalancer to be fully provisioned
186+
- The URL remains stable unless you delete and recreate the service
187+
188+
b. **Using Port Forwarding (For Development/Testing)**
189+
```bash
190+
# Forward local port 8080 to service port 80
191+
kubectl port-forward -n spreadsheet-app svc/spreadsheet-app-service 8080:80
192+
```
193+
Then access the application at: `http://localhost:8080`
194+
- This method is useful for local testing
195+
- The connection will be terminated when you stop the port-forward command
196+
- Only accessible from your local machine
197+
198+
c. **Using Ingress (If configured)**
199+
```bash
200+
# Get the ingress host
201+
kubectl get ingress -n spreadsheet-app
202+
```
203+
Access the application using the hostname from the ingress
204+
- Requires proper DNS configuration
205+
- Supports custom domains and SSL
206+
- More suitable for production environments
207+
208+
Note:
209+
- The application might take a few minutes to be fully accessible after deployment
210+
- If you can't access the application, check the troubleshooting section
211+
- For security in production, consider setting up HTTPS and proper authentication
212+
213+
7. **Troubleshooting**
214+
- If pods are not starting, check logs: `kubectl logs -n spreadsheet-app <pod-name>`
215+
- If service is not accessible, verify LoadBalancer status: `kubectl describe svc spreadsheet-app-service -n spreadsheet-app`
216+
- For memory issues, check pod status: `kubectl describe pod -n spreadsheet-app -l app=spreadsheet-app`
217+
218+
8. **Scaling and Updates**
219+
```bash
220+
# Scale the application
221+
kubectl scale deployment spreadsheet-app -n spreadsheet-app --replicas=3
222+
223+
# Update the application
224+
kubectl set image deployment/spreadsheet-app spreadsheet-app=your-new-image:tag -n spreadsheet-app
137225
```
138226

139227
## Project Structure

kubernetes/deployment.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ spec:
2121
resources:
2222
requests:
2323
cpu: "25m"
24-
memory: "32Mi"
24+
memory: "128Mi"
2525
limits:
26-
cpu: "50m"
27-
memory: "64Mi"
26+
cpu: "100m"
27+
memory: "256Mi"
2828
env:
2929
- name: FLASK_ENV
3030
value: "production"
3131
- name: REDIS_HOST
32-
value: "localhost"
32+
value: "redis-service"
3333
- name: redis
3434
image: redis:latest
3535
ports:
@@ -53,4 +53,4 @@ spec:
5353
ports:
5454
- port: 80
5555
targetPort: 5000
56-
type: ClusterIP
56+
type: LoadBalancer

0 commit comments

Comments
 (0)