Skip to content

Commit 249e40a

Browse files
committed
Update configuration issues.
- Add deployment for postgresSQL instance deployed on kubernetes for testing. - Use dotenv to manage env variables. - #TODO Create a script to create news users on init.
1 parent 2180841 commit 249e40a

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

backend/user_service/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
- Install VS Code or PyCharm
3030
- Install Python extension
3131

32+
4. **PostgreSQL**
33+
- Install PostgreSQL from official site
34+
- Create user and set the password
35+
```bash
36+
# Use postgres user to create new user, depending on your setup.
37+
psql -U postgres -h localhost
38+
```
39+
```sql
40+
CREATE USER user_dev_local WITH PASSWORD 'your_password';
41+
ALTER ROLE user_dev_local CREATEDB; -- Optional: Use can create databases.
42+
CREATE DATABASE user_dev_local;
43+
GRANT ALL PRIVILEGES ON DATABASE user_dev_local TO user_dev_local;
44+
psql -U user_dev_local -d your_password -h localhost
45+
```
46+
3247
### Local Development
3348

3449
1. Clone Repository
@@ -96,7 +111,21 @@
96111
```bash
97112
kubectl rollout restart
98113
```
99-
114+
5. Connect to PostGreSQL inside the Pod
115+
```bash
116+
kubectl exec -it postgres-c8c4f79bf-jkgbz -- /bin/bash
117+
root@postgres-c8c4f79bf-jkgbz:/# # No you are inside postgresql.
118+
psql -U user_dev_local -d user_service_db
119+
psql (14.15 (Debian 14.15-1.pgdg120+1)) # This means the instance is working.
120+
...
121+
```
122+
6. Other ways to check for services.
123+
```bash
124+
apt update && apt install -y iputils-ping
125+
ping postgres
126+
telnet postgres 5432
127+
nc -vz postgres 5432
128+
```
100129
## Architecture
101130
- Event-Driven Architecture
102131
- Microservices Architecture
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: postgres
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: postgres
10+
template:
11+
metadata:
12+
labels:
13+
app: postgres
14+
spec:
15+
containers:
16+
- name: postgres
17+
image: postgres:14 # Use a stable PostgreSQL version
18+
ports:
19+
- containerPort: 5432
20+
env:
21+
- name: POSTGRES_USER
22+
value: "user_dev_local"
23+
- name: POSTGRES_PASSWORD
24+
value: "@changeMe1234"
25+
- name: POSTGRES_DB
26+
value: "user_service_db"
27+
volumeMounts:
28+
- mountPath: "/var/lib/postgresql/data"
29+
name: postgres-storage
30+
volumes:
31+
- name: postgres-storage
32+
emptyDir: {} # Replace with PersistentVolumeClaim for production
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: postgres
5+
spec:
6+
ports:
7+
- port: 5432
8+
selector:
9+
app: postgres
10+
type: ClusterIP

0 commit comments

Comments
 (0)