-
Notifications
You must be signed in to change notification settings - Fork 126
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
Fixes #300 Kubernetes config added for autodeployment #381
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,26 @@ | ||
#!/bin/bash | ||
export DIR=${BASH_SOURCE%/*} | ||
|
||
if [ "$1" = "delete" ]; then | ||
echo "Clearing the cluster." | ||
if [ "$2" = "all" ]; then | ||
kubectl delete -f ${DIR}/yamls/nginx/00-namespace.yml | ||
fi | ||
kubectl delete -f ${DIR}/yamls/web/00-namespace.yml | ||
kubectl delete -f ${DIR}/yamls/mongo/00-namespace.yml | ||
echo "Done. The project was removed from the cluster." | ||
elif [ "$1" = "create" ]; then | ||
echo "Deploying the project to kubernetes cluster" | ||
if [ "$2" = "all" ]; then | ||
# Start nginx deployment, ingress & service | ||
kubectl create -R -f ${DIR}/yamls/nginx | ||
fi | ||
kubectl create -R -f ${DIR}/yamls/mongo | ||
# Create web namespace | ||
kubectl create -R -f ${DIR}/yamls/web | ||
# Create API server deployment and service | ||
kubectl create -R -f ${DIR}/yamls/yaydoc | ||
echo "Waiting for server to start up. ~30s." | ||
sleep 30 | ||
echo "Done. The project was deployed to kubernetes. :)" | ||
fi |
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,33 @@ | ||
FROM node:boron | ||
MAINTAINER Ujjwal Bhardwaj <[email protected]> | ||
|
||
ARG COMMIT_HASH | ||
ARG BRANCH | ||
ARG REPOSITORY | ||
|
||
ENV COMMIT_HASH ${COMMIT_HASH:-null} | ||
ENV BRANCH ${BRANCH:-master} | ||
ENV REPOSITORY ${REPOSITORY:-https://github.com/fossasia/yaydoc.git} | ||
|
||
ENV INSTALL_PATH /yaydoc | ||
|
||
RUN mkdir -p $INSTALL_PATH | ||
|
||
WORKDIR $INSTALL_PATH | ||
|
||
COPY . . | ||
|
||
RUN echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y -t jessie-backports python python-dev python-pip python-virtualenv zip rsync openjdk-8-jdk && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ | ||
ENV PATH="$JAVA_HOME/bin:$PATH" | ||
|
||
RUN bash setup.sh | ||
|
||
WORKDIR $INSTALL_PATH/yaydoc | ||
|
||
CMD [ "npm", "start" ] |
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,14 @@ | ||
#!/bin/bash | ||
git clone ${REPOSITORY} yaydoc | ||
cd yaydoc | ||
git checkout ${BRANCH} | ||
|
||
if [ -v COMMIT_HASH ]; then | ||
git reset --hard ${COMMIT_HASH} | ||
fi | ||
|
||
npm install --no-shrinkwrap | ||
|
||
pip install -r requirements.txt | ||
|
||
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh |
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,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
export DEPLOY_BRANCH=${DEPLOY_BRANCH:-master} | ||
|
||
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/yaydoc" -o "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then | ||
echo "Skip production deployment for a very good reason." | ||
exit 0 | ||
fi | ||
|
||
export REPOSITORY="https://github.com/${TRAVIS_REPO_SLUG}.git" | ||
|
||
sudo rm -f /usr/bin/git-credential-gcloud.sh | ||
sudo rm -f /usr/bin/bq | ||
sudo rm -f /usr/bin/gsutil | ||
sudo rm -f /usr/bin/gcloud | ||
rm -rf node_modules | ||
|
||
curl https://sdk.cloud.google.com | bash; | ||
source ~/.bashrc | ||
gcloud components install kubectl | ||
|
||
gcloud config set compute/zone us-central1-c | ||
# Decrypt the credentials we added to the repo using the key we added with the Travis command line tool | ||
openssl aes-256-cbc -K $encrypted_512fe31a4705_key -iv $encrypted_512fe31a4705_iv -in ./kubernetes/travis/yaydoc-ujjwal-7b7e19a433b1.json.enc -out yaydoc-ujjwal-7b7e19a433b1.json -d | ||
gcloud auth activate-service-account --key-file yaydoc-ujjwal-7b7e19a433b1.json | ||
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/yaydoc-ujjwal-7b7e19a433b1.json | ||
|
||
gcloud config set project yaydoc-702 | ||
gcloud container clusters get-credentials yaydoc-cluster | ||
cd kubernetes/images/yaydoc | ||
docker build --build-arg COMMIT_HASH=$TRAVIS_COMMIT --build-arg BRANCH=$DEPLOY_BRANCH --build-arg REPOSITORY=$REPOSITORY --no-cache -t ujjwalbhardwaj/yaydoc:$TRAVIS_COMMIT . | ||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | ||
docker tag ujjwalbhardwaj/yaydoc:$TRAVIS_COMMIT ujjwalbhardwaj/yaydoc:latest | ||
docker push ujjwalbhardwaj/yaydoc | ||
kubectl set image deployment/yaydoc --namespace=web yaydoc=ujjwalbhardwaj/yaydoc:$TRAVIS_COMMIT | ||
rm -rf $GOOGLE_APPLICATION_CREDENTIALS |
Binary file not shown.
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: mongo |
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,24 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: mongo | ||
namespace: mongo | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
run: mongo | ||
spec: | ||
containers: | ||
- name: mongo | ||
image: mongo | ||
ports: | ||
- containerPort: 27017 | ||
volumeMounts: | ||
- name: mongo-persistent-storage | ||
mountPath: /data/db | ||
volumes: | ||
- name: mongo-persistent-storage | ||
gcePersistentDisk: | ||
pdName: mongo-disk | ||
fsType: ext4 |
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,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
run: mongo | ||
name: mongo | ||
namespace: mongo | ||
spec: | ||
ports: | ||
- port: 27017 | ||
targetPort: 27017 | ||
protocol: TCP | ||
selector: | ||
run: mongo |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: nginx-ingress |
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 @@ | ||
# | ||
# nginx ingress controller config | ||
# @ref https://github.com/kubernetes/ingress/blob/master/controllers/nginx/configuration.md | ||
# | ||
apiVersion: v1 | ||
data: | ||
proxy-connect-timeout: "15" | ||
proxy-read-timeout: "600" | ||
proxy-send-imeout: "600" | ||
hsts-include-subdomains: "false" | ||
body-size: "64m" | ||
server-name-hash-bucket-size: "256" | ||
server-tokens: "false" | ||
kind: ConfigMap | ||
metadata: | ||
namespace: nginx-ingress | ||
name: nginx |
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,31 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: default-http-backend | ||
namespace: nginx-ingress | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: default-http-backend | ||
spec: | ||
containers: | ||
- name: default-http-backend | ||
image: gcr.io/google_containers/defaultbackend:1.0 | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 5 | ||
ports: | ||
- containerPort: 8080 | ||
resources: | ||
limits: | ||
cpu: 10m | ||
memory: 20Mi | ||
requests: | ||
cpu: 10m | ||
memory: 20Mi |
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,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: default-http-backend | ||
namespace: nginx-ingress | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
selector: | ||
app: default-http-backend |
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,39 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx | ||
namespace: nginx-ingress | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- image: gcr.io/google_containers/nginx-ingress-controller:0.8.3 | ||
name: nginx | ||
imagePullPolicy: Always | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 10254 | ||
scheme: HTTP | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 5 | ||
ports: | ||
- containerPort: 80 | ||
- containerPort: 443 | ||
args: | ||
- /nginx-ingress-controller | ||
- --default-backend-service=nginx-ingress/default-http-backend | ||
- --nginx-configmap=nginx-ingress/nginx |
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: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx | ||
namespace: nginx-ingress | ||
annotations: | ||
service.beta.kubernetes.io/external-traffic: "OnlyLocal" | ||
spec: | ||
type: LoadBalancer | ||
loadBalancerIP: '35.197.18.246' | ||
ports: | ||
- port: 80 | ||
name: http | ||
- port: 443 | ||
name: https | ||
selector: | ||
app: nginx |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: web |
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,16 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: yaydoc-notls | ||
namespace: web | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" | ||
spec: | ||
rules: | ||
- host: yaydoc.org | ||
http: | ||
paths: | ||
- path: / | ||
backend: | ||
serviceName: yaydoc | ||
servicePort: 3001 |
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,21 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: yaydoc | ||
namespace: web | ||
annotations: | ||
kubernetes.io/tls-acme: "true" | ||
kubernetes.io/ingress.class: "nginx" | ||
spec: | ||
tls: | ||
- hosts: | ||
- yaydoc.org | ||
secretName: yaydoc-tls | ||
rules: | ||
- host: yaydoc.org | ||
http: | ||
paths: | ||
- path: / | ||
backend: | ||
serviceName: yaydoc | ||
servicePort: 3001 |
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,19 @@ | ||
apiVersion: v1 | ||
metadata: | ||
name: yaydoc | ||
namespace: web | ||
data: | ||
DEPLOYMENT: "true" | ||
ENCRYPTION_KEY: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
GITHUB_CLIENT_ID: "XXXXXXXXXXXXXXXXXXXXXXXX" | ||
GITHUB_CLIENT_SECRET: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
GITHUB_CALLBACK_URL: "http://yaydoc.org/auth/github/callback" | ||
HEROKU_CLIENT_ID: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
HEROKU_CLIENT_SECRET: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
HEROKU_CALLBACK_URL: "http://yaydoc.org/auth/heroku/callback" | ||
HOSTNAME: "yaydoc.org" | ||
MONGODB_URI: "mongodb://mongo.mongo:27017/yaydoc" | ||
SECRET: "anabsolutescrettokenforyaydoc" | ||
SENDGRID_USERNAME: "XXXXXXXXXXXX" | ||
SENDGRID_PASSWORD: "XXXXXXXXXXXX" | ||
kind: ConfigMap |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need docker service too