diff --git a/Chapter_Two/Lecture_7_Lab/myapp/Dockerfile b/Chapter_Two/Lecture_7_Lab/myapp/Dockerfile new file mode 100644 index 0000000..3ded536 --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.5 + +COPY . /app +WORKDIR /app + +RUN pip install -r requirements.txt + +CMD ["python", "-u", "server.py"] diff --git a/Chapter_Two/Lecture_7_Lab/myapp/myapp-deployment.html b/Chapter_Two/Lecture_7_Lab/myapp/myapp-deployment.html new file mode 100644 index 0000000..5dc1cdd --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/myapp-deployment.html @@ -0,0 +1,22 @@ +piVersion: apps/v1 +kind: Deployment +metadata: + name: myapp-deployment + labels: + app: myapp +spec: + replicas: 3 + selector: + matchLabels: + app: myapp + template: + metadata: + labels: + app: myapp + spec: + containers: + - name: myapp + image: gcr.io/tim-acloud-guru/myapp:blue + ports: + - containerPort: 8888 + diff --git a/Chapter_Two/Lecture_7_Lab/myapp/myapp-service.html b/Chapter_Two/Lecture_7_Lab/myapp/myapp-service.html new file mode 100644 index 0000000..91df01e --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/myapp-service.html @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: myapp-service +spec: + selector: + app: myapp + ports: + - protocol: TCP + port: 80 + targetPort: 8888 + type: LoadBalancer + diff --git a/Chapter_Two/Lecture_7_Lab/myapp/requirements.txt b/Chapter_Two/Lecture_7_Lab/myapp/requirements.txt new file mode 100644 index 0000000..26ccf69 --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/requirements.txt @@ -0,0 +1,2 @@ +tornado + diff --git a/Chapter_Two/Lecture_7_Lab/myapp/server.py b/Chapter_Two/Lecture_7_Lab/myapp/server.py new file mode 100644 index 0000000..73a86b4 --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/server.py @@ -0,0 +1,23 @@ +import tornado.ioloop +import tornado.web + + +class MainHandler(tornado.web.RequestHandler): + def get(self): + title = "Hello, World!" + bgcolor = "dodgerblue" + self.render("template.html", title=title, bgcolor=bgcolor) + print(self.request) + + +def make_app(): + return tornado.web.Application([ + (r"/", MainHandler), + ]) + + +if __name__ == "__main__": + app = make_app() + app.listen(8888) + tornado.ioloop.IOLoop.current().start() + diff --git a/Chapter_Two/Lecture_7_Lab/myapp/template.html b/Chapter_Two/Lecture_7_Lab/myapp/template.html new file mode 100644 index 0000000..4e8b2d4 --- /dev/null +++ b/Chapter_Two/Lecture_7_Lab/myapp/template.html @@ -0,0 +1,13 @@ + + + + {{ title }} + + +

+ + {{ title }} + +

+ +