Skip to content

Commit b9b3660

Browse files
authored
Fix Kubernetes: fix ingress issues for deployment on minikube (#49)
1 parent 17ff029 commit b9b3660

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed

entrypoint.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/bin/sh
22

3-
echo "Waiting for postgres..."
4-
5-
while ! nc -z $DB_HOST $DB_PORT; do
6-
sleep 0.1
7-
done
8-
9-
echo "PostgreSQL started"
3+
#echo "Waiting for postgres..."
4+
#
5+
# while ! nc -z $DB_HOST $DB_PORT; do
6+
# sleep 0.1
7+
# done
8+
#
9+
#echo "PostgreSQL started"
1010

1111
#python manage.py flush --no-input
1212
python manage.py makemigrations
1313
python manage.py migrate
1414
python manage.py loaddata fixture_2
15+
python manage.py runserver 0.0.0.0:8000
1516

1617
exec "$@"

kubernetes-deployment/Minikube_Setup.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ kubectl version --client
3737
```
3838
# Make sure you are in root directory 'ToDoFehrist'
3939
docker build -t todofehrist:v1 .
40-
docker --login # Login for dockerhub.io
40+
docker login # Login for dockerhub.io
4141
docker push todofehrist:v1
4242
```
4343

@@ -85,16 +85,30 @@ PGDATABASE=$(kubectl get secrets -n postgres-operator "${PG_CLUSTER_USER_SECRET_
8585
8686
psql -h localhost -p 5432 -U hippo
8787
# use PGPASSWORD for authentication
88+
#Show Databases
89+
\l
90+
# Connect to Database
91+
\c hippo
92+
# Show Tables
93+
\dt
8894
8995
kubectl get pods -n postgres-operator
9096
```
9197

98+
## Create Env ConfigMap
99+
```
100+
kubectl -n postgres-operator create configmap todofehristapi-dev-env-cm --from-env-file=dev.env
101+
kubectl -n postgres-operator get configmap todofehristapi-dev-env-cm -o yaml
102+
# OR update the existing
103+
kubectl -n postgres-operator apply -f todofehristapi-dev-env-cm.yaml
104+
```
105+
92106
## ToDoFehristAPI Deployment - Service - Ingress
93107
```
94108
# Create APIs Deployment - Service and Ingress
95-
kubectl apply -f todofehristapi-deployment.yaml
96-
kubectl apply -f todofehristapi-service.yaml
97-
kubectl apply -f todofehrist-ingress.yaml
109+
kubectl -n postgres-operator apply -f todofehristapi-deployment.yaml
110+
kubectl -n postgres-operator apply -f todofehristapi-service.yaml
111+
kubectl -n postgres-operator apply -f todofehrist-ingress.yaml
98112
99113
# Get Minikube Cluster IP
100114
minikube ip
@@ -116,11 +130,13 @@ minikube tunnel
116130
# to test a service locally in minikube
117131
minikube service todofehristapi-service --url
118132
119-
kubectl get namespaces
120-
kubectl get pods # to get deployments
121-
kubectl get services
122-
kubectl get ingress
133+
kubectl -n postgres-operator get namespaces
134+
kubectl -n postgres-operator get pods # to get deployments
135+
kubectl -n postgres-operator get services
136+
kubectl -n postgres-operator get ingress
123137
124138
# forward port from a pod
125139
kubectl -n default port-forward "<POD_NAME>" 8000:8000
140+
# Restart a deployment
141+
kubectl -n postgres-operator rollout restart deployment todofehristapi-deployment
126142
```

kubernetes-deployment/todofehrist-ingress.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: networking.k8s.io/v1
22
kind: Ingress
33
metadata:
4-
name: emumba-ingress
4+
name: todofehrist-ingress
55
annotations:
66
kubernetes.io/ingress.class: nginx
77
spec:

kubernetes-deployment/todofehristapi-deployment.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: apps/v1
2-
kind: deployment
2+
kind: Deployment
33
metadata:
44
name: todofehristapi-deployment
55
spec:
@@ -14,4 +14,20 @@ spec:
1414
spec:
1515
containers:
1616
- name: todofehristapi
17-
image: z4id/todofehrist:v1
17+
image: z4id/todofehrist:v2
18+
env:
19+
- name: DB_VENDOR
20+
value: "postgres"
21+
- name: DB_HOST
22+
valueFrom: { secretKeyRef: { name: hippo-pguser-hippo, key: host } }
23+
- name: DB_PORT
24+
valueFrom: { secretKeyRef: { name: hippo-pguser-hippo, key: port } }
25+
- name: DB_NAME
26+
valueFrom: { secretKeyRef: { name: hippo-pguser-hippo, key: dbname } }
27+
- name: DB_USER
28+
valueFrom: { secretKeyRef: { name: hippo-pguser-hippo, key: user } }
29+
- name: DB_PASSWORD
30+
valueFrom: { secretKeyRef: { name: hippo-pguser-hippo, key: password } }
31+
envFrom:
32+
- configMapRef:
33+
name: todofehristapi-dev-env-cm

0 commit comments

Comments
 (0)