Skip to content

Commit 8947c80

Browse files
committed
Update README with local Kubernetes instructions
1 parent a833314 commit 8947c80

File tree

5 files changed

+146
-70
lines changed

5 files changed

+146
-70
lines changed

.github/workflows/build_docker.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Docker Images
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
test:
8+
name: Run Java Tests
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- uses: actions/setup-java@v4
15+
with:
16+
java-version: '21'
17+
distribution: 'temurin'
18+
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
22+
- name: Build with Gradle
23+
run: cd server && ./gradlew build
24+
25+
build:
26+
name: Build Docker Images
27+
needs: test
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
service: [client, server]
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Log in to the Container registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v3
47+
with:
48+
platforms: all
49+
50+
- name: Install Docker Buildx
51+
id: buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Extract metadata (tags, labels) for Docker
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ghcr.io/${{ github.repository }}/${{ matrix.service }}
59+
tags: |
60+
type=raw,value=latest,enable={{is_default_branch}}
61+
type=ref,event=branch
62+
type=ref,event=pr
63+
64+
- name: Build and push Docker Image
65+
uses: docker/build-push-action@v5
66+
with:
67+
platforms: linux/amd64,linux/arm64
68+
context: ./${{ matrix.service }}
69+
file: ./${{ matrix.service }}/Dockerfile
70+
push: true
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,86 @@ The project includes Docker configurations for containerized deployment.
106106

107107
1. Build and start the services:
108108
```bash
109-
docker-compose up --build
109+
docker compose up --build
110110
```
111111
2. Access the application:
112112
- Client: [http://localhost:3000](http://localhost:3000)
113113
- Server: [http://localhost:8080](http://localhost:8080)
114114

115-
### Production Deployment
115+
## Kubernetes Deployment
116116

117-
Use the `docker-compose.prod.yml` file for production deployment. Ensure environment variables are set correctly.
117+
This project can be deployed to a Kubernetes cluster. The Kubernetes configuration files are located in the `k8s` directory.
118+
119+
### Ensure Docker Desktop Kubernetes is Active
120+
121+
Before deploying, make sure you're using Docker Desktop's Kubernetes:
122+
123+
1. Verify that Kubernetes is enabled in Docker Desktop:
124+
- Open Docker Desktop
125+
- Go to Settings/Preferences
126+
- Select "Kubernetes" from the left menu
127+
- Check "Enable Kubernetes"
128+
- Click "Apply & Restart" if needed
129+
130+
2. Confirm Docker Desktop is your current kubectl context:
131+
```bash
132+
kubectl config current-context
133+
```
134+
This should return `docker-desktop` or similar.
135+
136+
3. If needed, switch to Docker Desktop context:
137+
```bash
138+
kubectl config use-context docker-desktop
139+
```
140+
141+
### Deploy to Local Kubernetes
142+
143+
Follow these steps to deploy the application correctly:
144+
145+
1. Create the namespace and deploy all resources at once:
146+
```bash
147+
kubectl apply -f k8s/namespace.yaml
148+
kubectl apply -f k8s
149+
```
150+
151+
2. Check the status of all deployed resources:
152+
```bash
153+
kubectl -n canteen-app get all
154+
```
155+
156+
3. Get the server service port details:
157+
```bash
158+
kubectl -n canteen-app get service
159+
```
160+
161+
4. Update the configmap with the correct server port from the previous step:
162+
```bash
163+
# Edit the configmap with the allocated server port
164+
kubectl edit configmap app-config -n canteen-app
165+
```
166+
167+
In the editor that opens, update the SERVER_PORT value to match the port from step 3.
168+
169+
5. Restart the client deployment to pick up the new configmap values:
170+
```bash
171+
kubectl rollout restart deployment client -n canteen-app
172+
```
173+
174+
6. Verify all components are running correctly:
175+
```bash
176+
kubectl -n canteen-app get all
177+
```
178+
179+
### Accessing the Application
180+
181+
After deployment, you can access the application through the client service. Get the client service port:
118182

119183
```bash
120-
docker-compose -f docker-compose.prod.yml up -d
184+
kubectl -n canteen-app get service
121185
```
122186

187+
The application will be available at `http://localhost:<CLIENT_PORT>` where `<CLIENT_PORT>` is the port mapped to port 3000 in the client service.
188+
123189
## CI/CD Pipeline
124190

125191
The project includes GitHub Actions workflows for:
@@ -139,8 +205,7 @@ The project includes GitHub Actions workflows for:
139205
│ ├── build.gradle # Gradle build file
140206
│ └── Dockerfile # Server Dockerfile
141207
142-
├── docker-compose.yml # Docker Compose for local development
143-
├── docker-compose.prod.yml # Docker Compose for production
208+
├── compose.yml # Docker Compose for local development
144209
└── .github/workflows/ # CI/CD workflows
145210
```
146211

client/src/routes/+page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { PageLoad } from './$types';
22
import { env } from '$env/dynamic/public';
33

4+
export const ssr = false;
45

56
let baseUrl = env.PUBLIC_API_URL || "http://localhost:8080";
67

docker-compose.yml renamed to compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.8'
22

33
services:
44
server:
5-
image: ghcr.io/aet-devops25/w04-solution/server:latest
5+
image: ghcr.io/aet-devops25/w04-template/server:latest
66
build:
77
context: ./server
88
dockerfile: Dockerfile
@@ -19,7 +19,7 @@ services:
1919
restart: unless-stopped
2020

2121
client:
22-
image: ghcr.io/aet-devops25/w04-solution/client:latest
22+
image: ghcr.io/aet-devops25/w04-template/client:latest
2323
build:
2424
context: ./client
2525
dockerfile: Dockerfile

docker-compose.prod.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)