Revert "Revert "[wip] K8s (#162)""

This reverts commit a7dd6a5160.
This commit is contained in:
Kevin van Zonneveld 2017-11-29 11:21:34 +01:00
parent a7dd6a5160
commit 66887c14e0
6 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,5 @@
apiVersion: v1
kind: Namespace
metadata:
name: tus

View File

@ -0,0 +1,19 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tusd
namespace: tus
spec:
replicas: 1
template:
metadata:
labels:
app: tusd
spec:
containers:
- image: docker.io/tusproject/tusd:latest
imagePullPolicy: Always
args: ["-port=8080","-behind-proxy","-max-size=1000000000"]
name: tusd
ports:
- containerPort: 8080

View File

@ -0,0 +1,22 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: tusd
namespace: tus
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
spec:
tls:
- hosts:
- thesocialcactus.com
secretName: tusd-tls
rules:
- host: thesocialcactus.com
http:
paths:
- path: /
backend:
serviceName: tusd
servicePort: 80

13
.infra/kube/service.yaml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: tusd
namespace: tus
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: tusd

47
.scripts/deploy_gcloud.sh Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace
# Set magic variables for current FILE & DIR
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
# Store the new image in docker hub
docker build --quiet -t tusproject/tusd:latest -t tusproject/tusd:$TRAVIS_COMMIT ${__root};
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push tusproject/tusd:$TRAVIS_COMMIT;
docker push tusproject/tusd:latest;
echo $GCLOUD_KEY | base64 --decode -i > ${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
gcloud --quiet config set project $PROJECT_NAME
gcloud --quiet config set container/cluster $CLUSTER_NAME
gcloud --quiet config set compute/zone ${COMPUTE_ZONE}
gcloud --quiet container clusters get-credentials $CLUSTER_NAME
kubectl config current-context
helm init --service-account tiller --upgrade
kubectl apply -f "${__root}/.infra/kube/00-namespace.yaml"
kubectl apply -f "${__root}/.infra/kube/deployment.yaml"
kubectl apply -f "${__root}/.infra/kube/service.yaml"
kubectl apply -f "${__root}/.infra/kube/ingress-tls.yaml"
kubectl set image deployment/tusd --namespace=tus tusd=docker.io/tusproject/tusd:$TRAVIS_COMMIT
kubectl get pods --namespace=tus
kubectl get service --namespace=tus
kubectl get deployment --namespace=tus
function cleanup {
printf "Cleaning up...\n"
rm -vf "${HOME}/gcloud-service-key.json"
printf "Cleaning done."
}
trap cleanup EXIT

View File

@ -11,6 +11,7 @@ cache:
directories:
- $HOME/.gimme
- $HOME/.frey
- "$HOME/google-cloud-sdk/"
env:
global:
- GO15VENDOREXPERIMENT=1
@ -25,6 +26,12 @@ script:
- ./.scripts/test_all.sh
before_deploy:
- if [[ "$TRAVIS_TAG" != "" ]]; then ./.scripts/build_all.sh; fi
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; curl https://sdk.cloud.google.com | bash; fi
- source /home/travis/google-cloud-sdk/path.bash.inc
- gcloud --quiet version
- gcloud --quiet components update
- gcloud --quiet components update kubectl
- curl https://raw.githubusercontent.com/kubernetes/helm/8478fb4fc723885b155c924d1c8c410b7a9444e6/scripts/get | bash
deploy:
- provider: releases
api_key:
@ -42,3 +49,9 @@ deploy:
branch: master
go: 1.8
repo: tus/tusd
- provider: script
script: .scripts/deploy_gcloud.sh
on:
branch: k8s
go: 1.8
repo: tus/tusd