Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted all the services to work under k8s. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-server/app/config/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ DATABASE_URL = 'localhost'
DATABASE_USER = 'planespotter'
DATABASE_PWD = 'VMware1!'
DATABASE = 'planespotter'
REDIS_HOST = '10.114.209.218'
REDIS_HOST = 'redis-server.redis'
REDIS_PORT = '6379'
15 changes: 15 additions & 0 deletions db-install/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mysql
RUN mkdir -p /root/planespotter/db-install/
RUN apt-get update
RUN apt-get install -y wget unzip
RUN mkdir -p /opt/db-install && chmod 777 /opt/db-install
RUN cd /opt/db-install/ && wget http://registry.faa.gov/database/ReleasableAircraft.zip
RUN cd /opt/db-install/ && unzip ReleasableAircraft.zip
RUN cd /opt/db-install/ && rm DEALER.txt DEREG.txt DOCINDEX.txt ENGINE.txt RESERVED.txt
RUN echo 'copying script 1'
#COPY ./create-planespotter-db.sql /root/planespotter/db-install/create-planespotter-db.sql
COPY ./create-planespotter-db.sql /docker-entrypoint-initdb.d/create-planespotter-db.sql
#COPY ./create-planespotter-db.sh /root/planespotter/db-install/create-planespotter-db.sh
#RUN ls -l /root/planespotter/db-install/
#RUN chmod +x /root/planespotter/db-install/create-planespotter-db.sh
#RUN cd /root/planespotter/db-install/ && ./create-planespotter-db.sh
16 changes: 13 additions & 3 deletions db-install/create-planespotter-db.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#!/bin/bash
set -x

export MYSQL_ROOT_PASSWORD=planspotter-sql
cd /
pwd
#/usr/local/bin/docker-entrypoint.sh mysqld &
mysqld -uroot &
sleep 5
cd ~/planespotter/db-install/
wget http://registry.faa.gov/database/ReleasableAircraft.zip
#wget http://registry.faa.gov/database/ReleasableAircraft.zip
unzip ReleasableAircraft.zip
rm ReleasableAircraft.zip DEALER.txt DEREG.txt DOCINDEX.txt ENGINE.txt RESERVED.txt
mysql -u root -p < create-planespotter-db.sql
ps -eaf
#rm ReleasableAircraft.zip DEALER.txt DEREG.txt DOCINDEX.txt ENGINE.txt RESERVED.txt
rm DEALER.txt DEREG.txt DOCINDEX.txt ENGINE.txt RESERVED.txt
mysql --user=root --password=${MYSQL_ROOT_PASSWORD} < create-planespotter-db.sql
rm MASTER.txt ACFTREF.txt
#killall -9 mysqld
4 changes: 2 additions & 2 deletions db-install/create-planespotter-db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CREATE TABLE MASTER (
PRIMARY KEY (`N-NUMBER`)
);

LOAD DATA LOCAL INFILE '~/planespotter/db-install/MASTER.txt'
LOAD DATA LOCAL INFILE '/opt/db-install/MASTER.txt'
INTO TABLE MASTER
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
Expand All @@ -61,7 +61,7 @@ CREATE TABLE ACFTREF (
PRIMARY KEY (CODE)
);

LOAD DATA LOCAL INFILE '~/planespotter/db-install/ACFTREF.txt'
LOAD DATA LOCAL INFILE '/opt/db-install/ACFTREF.txt'
INTO TABLE ACFTREF
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
Expand Down
6 changes: 6 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM tiangolo/uwsgi-nginx-flask:flask
COPY ./app /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["main.py"]
6 changes: 4 additions & 2 deletions kubernetes/adsb-sync-oc-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apiVersion: v1
kind: Project
kind: Namespace
metadata:
name: adsb-sync
annotations:
ncp/no_snat: "true"
---
apiVersion: apps/v1beta1
kind: Deployment
Expand Down Expand Up @@ -41,7 +43,7 @@ metadata:
data:
config.ini: |
[main]
redis_server = 10.114.209.211
redis_server = redis-server.redis
adsb_server_poll_url = https://public-api.adsbexchange.com/VirtualRadar/AircraftList.json
adsb_poll_filter = ?fRegS=N
adsb_type = poll
9 changes: 6 additions & 3 deletions kubernetes/app-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Namespace
metadata:
name: planespotter
---
apiVersion: apps/v1beta2
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: planespotter-app
Expand All @@ -30,6 +30,9 @@ spec:
volumeMounts:
- name: config-volume
mountPath: /app/config
env:
- name: DEBUG_MODE
value: "True"
volumes:
- name: config-volume
configMap:
Expand All @@ -42,11 +45,11 @@ metadata:
namespace: planespotter
data:
config.cfg: |
DATABASE_URL = 'mysql.yves.local'
DATABASE_URL = 'mysql-svc.mysql'
DATABASE_USER = 'planespotter'
DATABASE_PWD = 'VMware1!'
DATABASE = 'planespotter'
REDIS_HOST = '10.114.209.211'
REDIS_HOST = 'redis-server.redis'
REDIS_PORT = '6379'
---
apiVersion: v1
Expand Down
45 changes: 45 additions & 0 deletions kubernetes/fe-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: v1
kind: Namespace
metadata:
name: fe
annotations:
ncp/no_snat: "true"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: fe-server
namespace: fe
spec:
replicas: 1
template:
metadata:
labels:
app: fe-server
tier: frontend
spec:
containers:
- name: fe-server
image: sushilk/planespotter-fe
ports:
- containerPort: 5000
env:
- name: PLANESPOTTER_API_ENDPOINT
value: "planespotter-svc.planespotter"
---
apiVersion: v1
kind: Service
metadata:
name: fe-server
namespace: fe
labels:
app: fe-server
tier: frontend
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 5000
selector:
app: fe-server
tier: frontend
52 changes: 52 additions & 0 deletions kubernetes/mysql-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
kind: Namespace
metadata:
name: mysql
annotations:
ncp/no_snat: "true"
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mysql
namespace: mysql
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- resources:
limits :
cpu: 0.5
image: sushilk/planespotter-sql
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
# change this
value: planspotter-sql
ports:
- containerPort: 3306
name: mysql
---
apiVersion: v1
kind: Service
metadata:
namespace: mysql
name: mysql-svc
namespace: mysql
labels:
app: mysql-svc
spec:
ports:
# the port that this service should serve on
- port: 3306
selector:
app: mysql