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

test #54

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

test #54

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
FROM alpine
COPY helloworld.sh /
CMD ["/helloworld.sh"]
FROM python:3.7-slim
RUN pip install flask
WORKDIR /app
COPY app.py /app/app.py
ENTRYPOINT ["python"]
CMD ["/app/app.py"]
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import Flask
app = Flask('hello-cloudbuild')

@app.route('/')
def hello():
return "Hello World!!\n"

if __name__ == '__main__':
app.run(host = '0.0.0.0', port = 8080)
Create a container image with Cloud B
13 changes: 13 additions & 0 deletions cloudbuild-delivery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
# This step deploys the new version of our container image
# in the hello-cloudbuild Kubernetes Engine cluster.
- name: 'gcr.io/cloud-builders/kubectl'
id: Deploy
args:
- 'apply'
- '-f'
- 'kubernetes.yaml'
env:
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-b'
- 'CLOUDSDK_CONTAINER_CLUSTER=hello-cloudbuild'
- 'CLOUDSDK_CORE_PROJECT=o-epm-gcp-by-meetup1-ml-t1iylu'
18 changes: 18 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
steps:
# This step builds the container image.
- name: 'gcr.io/cloud-builders/docker'
id: Build
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/hello-cloudbuild:$SHORT_SHA'
- '.'

# This step pushes the image to Container Registry
# The PROJECT_ID and SHORT_SHA variables are automatically
# replaced by Cloud Build.
- name: 'gcr.io/cloud-builders/docker'
id: Push
args:
- 'push'
- 'gcr.io/$PROJECT_ID/hello-cloudbuild:$SHORT_SHA'
2 changes: 0 additions & 2 deletions helloworld.sh

This file was deleted.

48 changes: 48 additions & 0 deletions kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-cloudbuild
labels:
app: hello-cloudbuild
spec:
replicas: 1
selector:
matchLabels:
app: hello-cloudbuild
template:
metadata:
labels:
app: hello-cloudbuild
spec:
containers:
- name: hello-cloudbuild
image: gcr.io/GOOGLE_CLOUD_PROJECT/hello-cloudbuild:COMMIT_SHA
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: hello-cloudbuild
spec:
selector:
app: hello-cloudbuild
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
24 changes: 24 additions & 0 deletions test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest
from app import hello

class TestHelloApp(unittest.TestCase):

def test_hello(self):
self.assertEqual(hello(), "Hello World!!\n")

if __name__ == '__main__':
unittest.main()