-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Administrator
committed
Feb 3, 2017
1 parent
8666dd9
commit baab4a7
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
image: docker:latest | ||
|
||
services: | ||
- docker:dind | ||
|
||
stages: | ||
- build_test_release | ||
- deploy_staging | ||
- deploy_prod | ||
|
||
variables: | ||
CONTAINER_TEST_IMAGE: gregbkr/flask_test | ||
CONTAINER_RELEASE_IMAGE: gregbkr/flask | ||
|
||
before_script: | ||
- docker login -u gregbkr -p Geneva2017$ | ||
|
||
build_test_release: | ||
stage: build_test_release | ||
script: | ||
- docker build --pull -t $CONTAINER_TEST_IMAGE flask/src | ||
- docker push $CONTAINER_TEST_IMAGE | ||
- docker run --name=flask -d -p 5000:5000 $CONTAINER_TEST_IMAGE | ||
- docker run -i --rm --link=flask:flask pstauffer/curl sh < flask/src/test.sh | ||
- docker rm -f -v flask | ||
- docker pull $CONTAINER_TEST_IMAGE | ||
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE | ||
- docker push $CONTAINER_RELEASE_IMAGE | ||
|
||
deploy_staging: | ||
stage: deploy_staging | ||
script: | ||
- cd /usr/local/bin | ||
- curl -O https://storage.googleapis.com/kubernetes-release/release/v1.5.1/bin/linux/amd64/kubectl | ||
- chmod +x kubectl | ||
- cd /builds/root/k8-ci | ||
- kubectl config set-cluster kargo --server=https://159.100.252.54:8443 --certificate-authority=kubectl/ca.pem | ||
- kubectl config set-credentials kadmin --certificate-authority=kubectl/ca.pem --client-key=kubectl/admin-node1-key.pem --client-certificate=kubectl/admin-node1.pem | ||
- kubectl config set-context kargo --cluster=kargo --user=kadmin | ||
- kubectl config use-context kargo | ||
- kubectl delete -f flask/flask-deployment.yaml | ||
- kubectl apply -f flask/flask-deployment.yaml | ||
|
||
deploy_prod: | ||
stage: deploy_prod | ||
when: manual | ||
script: | ||
- cd /usr/local/bin | ||
- curl -O https://storage.googleapis.com/kubernetes-release/release/v1.5.1/bin/linux/amd64/kubectl | ||
- chmod +x kubectl | ||
- cd /builds/root/k8-ci | ||
- kubectl config set-cluster kargo --server=https://159.100.252.54:8443 --certificate-authority=kubectl/ca.pem | ||
- kubectl config set-credentials kadmin --certificate-authority=kubectl/ca.pem --client-key=kubectl/admin-node1-key.pem --client-certificate=kubectl/admin-node1.pem | ||
- kubectl config set-context kargo --cluster=kargo --user=kadmin | ||
- kubectl config use-context kargo | ||
- kubectl delete -f flask/flask-deployment.yaml | ||
- kubectl apply -f flask/flask-deployment.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: flask | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: flask | ||
spec: | ||
containers: | ||
- name: flask | ||
image: gregbkr/flask | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: flask | ||
#namespace: default | ||
labels: | ||
app: flask | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 5000 | ||
nodePort: 30555 | ||
selector: | ||
app: flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM python:2.7 | ||
ADD . /code | ||
WORKDIR /code | ||
RUN pip install -r requirements.txt | ||
ENTRYPOINT ["python"] | ||
CMD ["app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/") | ||
def hello_world(): | ||
return "Hello World 1!" | ||
|
||
if __name__ == "__main__": | ||
app.run(debug=True,host='0.0.0.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
flask | ||
redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sleep 5 | ||
if curl flask:5000 | grep 'Hello World'; then | ||
echo "Tests passed!" | ||
exit 0 | ||
else | ||
echo "Tests failed!" | ||
exit 1 | ||
fi |