diff --git a/components/entitiy_ident/entity_ident_service/entity_ident.py b/components/entitiy_ident/entity_ident_service/entity_ident.py index d013366..3f244e0 100644 --- a/components/entitiy_ident/entity_ident_service/entity_ident.py +++ b/components/entitiy_ident/entity_ident_service/entity_ident.py @@ -5,31 +5,24 @@ from flask_pymongo import PyMongo # make sure mongoDB (container) is running and accessible # see https://flask-pymongo.readthedocs.io/en/latest/ +from pymongo import MongoClient app = Flask(__name__) -#app.config["MONGO_URI"] = "mongodb://localhost:27017/myDatabase" -#mongo = PyMongo(app) - -#mongo.db.test.insert_one({'_id': 0, 'foo': {'test': 'this'}}) -#mongo.db.test.insert_one({'_id': 1, 'suu': 'sar'}) - - -#@app.route("/") -#def home_page(): - # test_results = mongo.db.test.find() - # results = [] - # try: - # while True: - # result = test_results.next() - # results.append(result) - # except StopIteration: - # pass - - #return str(results) +app.config["MONGO_URI"] = "mongodb://mongo:27017/entities" +mongo = PyMongo(app) @app.route("/") def index(): - return str("Test!") + test_results = mongo.db.cars.find() + results = [] + try: + while True: + result = test_results.next() + results.append(result) + except StopIteration: + pass + + return str(results) #if __name__ == '__main__': # app.run() diff --git a/deploy-local.sh b/deploy-local.sh index a4b297f..c38454d 100644 --- a/deploy-local.sh +++ b/deploy-local.sh @@ -5,8 +5,11 @@ eval $(minikube -p minikube docker-env) echo "Building images..." docker build -t entity-ident components/entitiy_ident/entity_ident_service +docker build -t mongo components/entitiy_ident/mongo echo "Creating deployments and services..." +kubectl create -f kubernetes/mongo-deployment.yaml +kubectl create -f kubernetes/mongo-service.yaml kubectl create -f kubernetes/entity-ident-deployment.yaml kubectl create -f kubernetes/entity-ident-service.yaml diff --git a/kubernetes/entity-ident-deployment.yaml b/kubernetes/entity-ident-deployment.yaml index 7980520..36868fe 100644 --- a/kubernetes/entity-ident-deployment.yaml +++ b/kubernetes/entity-ident-deployment.yaml @@ -3,16 +3,18 @@ kind: Deployment metadata: name: entity-ident labels: - app: entity-ident + app: dse + tier: entity-ident spec: replicas: 1 selector: matchLabels: - app: entity-ident + app: dse template: metadata: labels: - app: entity-ident + app: dse + tier: entity-ident spec: containers: - name: entity-ident diff --git a/kubernetes/entity-ident-service.yaml b/kubernetes/entity-ident-service.yaml index bb8fed6..0283224 100644 --- a/kubernetes/entity-ident-service.yaml +++ b/kubernetes/entity-ident-service.yaml @@ -6,7 +6,8 @@ metadata: service: entity-ident spec: selector: - app: entity-ident + app: dse + tier: entity-ident ports: - port: 5000 targetPort: 5000 \ No newline at end of file diff --git a/kubernetes/mongo-deployment.yaml b/kubernetes/mongo-deployment.yaml new file mode 100644 index 0000000..89a454b --- /dev/null +++ b/kubernetes/mongo-deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongo + labels: + app: dse +spec: + replicas: 1 + selector: + matchLabels: + app: dse + tier: mongo + template: + metadata: + labels: + app: dse + tier: mongo + spec: + containers: + - name: mongo + image: mongo + ports: + - containerPort: 27017 + imagePullPolicy: Never diff --git a/kubernetes/mongo-service.yaml b/kubernetes/mongo-service.yaml new file mode 100644 index 0000000..d70286a --- /dev/null +++ b/kubernetes/mongo-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: mongo + labels: + service: mongo +spec: + type: ClusterIP + selector: + app: dse + ports: + - port: 27017 + targetPort: 27017 \ No newline at end of file diff --git a/remove-local.sh b/remove-local.sh index 0b9a478..6b0e2ae 100644 --- a/remove-local.sh +++ b/remove-local.sh @@ -1,6 +1,8 @@ #!/bin/bash echo "Removing deployments and services..." +kubectl delete -f kubernetes/mongo-deployment.yaml +kubectl delete -f kubernetes/mongo-service.yaml kubectl delete -f kubernetes/entity-ident-deployment.yaml kubectl delete -f kubernetes/entity-ident-service.yaml -kubectl delete -f kubernetes/minikube-ingress.yaml \ No newline at end of file +kubectl delete -f kubernetes/minikube-ingress.yaml