[wip] K8s (#162)
* Initial kube * Added testing docker image * Added docker building * Deploy the branch * Deploy to production * hiddent maybe * Faster build please * One charachter * We need to use yaml in standard way * Bring test back again * Added command arguments * Move to tus project * Domain expired
This commit is contained in:
parent
6f9b66f3ad
commit
88d5475691
|
@ -0,0 +1,5 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: tus
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: tusd
|
||||||
|
namespace: tus
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: tusd
|
||||||
|
|
|
@ -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
|
13
.travis.yml
13
.travis.yml
|
@ -11,6 +11,7 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.gimme
|
- $HOME/.gimme
|
||||||
- $HOME/.frey
|
- $HOME/.frey
|
||||||
|
- "$HOME/google-cloud-sdk/"
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- GO15VENDOREXPERIMENT=1
|
- GO15VENDOREXPERIMENT=1
|
||||||
|
@ -25,6 +26,12 @@ script:
|
||||||
- ./.scripts/test_all.sh
|
- ./.scripts/test_all.sh
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- if [[ "$TRAVIS_TAG" != "" ]]; then ./.scripts/build_all.sh; fi
|
- 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:
|
deploy:
|
||||||
- provider: releases
|
- provider: releases
|
||||||
api_key:
|
api_key:
|
||||||
|
@ -42,3 +49,9 @@ deploy:
|
||||||
branch: master
|
branch: master
|
||||||
go: 1.8
|
go: 1.8
|
||||||
repo: tus/tusd
|
repo: tus/tusd
|
||||||
|
- provider: script
|
||||||
|
script: .scripts/deploy_gcloud.sh
|
||||||
|
on:
|
||||||
|
branch: k8s
|
||||||
|
go: 1.8
|
||||||
|
repo: tus/tusd
|
||||||
|
|
Loading…
Reference in New Issue