misc: Change cloud provider for master.tus.io (#300)

* Change branch and change deployment method

* Fix DA DOCKER FIIIIILE

* Fix docker

* Maybe just update deployment ?

* Switch back to base64

* Remove useless lines and replace it by stable installation

* Don't use /home/kiloreux

* Added kubeconfig again

* Replicate stuff

* Final fixes

* Avoid contacting server

* remove quotes

* Try again

* Trigger

* Use master
This commit is contained in:
kiloreux 2019-08-13 09:50:18 +01:00 committed by Marius
parent 31d31ba3b9
commit 102715e2d1
4 changed files with 17 additions and 62 deletions

View File

@ -24,27 +24,15 @@ spec:
name: tusd
resources:
limits:
memory: "2Gi"
# requests:
# memory: "1Gi"
memory: "1Gi"
requests:
memory: "1Gi"
ports:
- name: tusd-web
containerPort: 8080
envFrom:
- configMapRef:
name: tusd-env
- secretRef:
name: tusd-s3
securityContext:
runAsUser: 0
fsGroup: 0
volumeMounts:
- name: tusd-account
mountPath: /gcs
volumes:
- name: tusd-account
secret:
secretName: gcs-account
name: tusd-env
---
apiVersion: v1
kind: Service
@ -99,25 +87,3 @@ spec:
backend:
serviceName: tusd
servicePort: 80
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: tusd
namespace: tus
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: tusd
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
- type: Resource
resource:
name: memory
targetAverageValue: 1800Mi

View File

@ -8,30 +8,25 @@ set -o nounset
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
echo "Storing ca.crt inside HOME"
echo $CA_CRT | base64 --decode -i > ${HOME}/ca.crt
echo "ca.crt is saved"
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
#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 login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker push tusproject/tusd:$TRAVIS_COMMIT;
docker push tusproject/tusd:latest;
gcloud config set container/use_client_certificate True
export CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True
kubectl config set-cluster transloadit-gke-cluster --embed-certs=true --server=${CLUSTER_ENDPOINT} --certificate-authority=${HOME}/ca.crt
kubectl config set-credentials travis --token=$SA_TOKEN
kubectl config set-context travis --cluster=$CLUSTER_NAME --user=travis --namespace=tus
kubectl config use-context travis
echo "Create directory..."
mkdir ${HOME}/.kube
echo "Writing KUBECONFIG to file..."
echo $KUBECONFIGVAR | python -m base64 -d > ${HOME}/.kube/config
echo "KUBECONFIG file written"
sleep 10s # This cost me some precious debugging time.
kubectl apply --validate=false -f "${__root}/.infra/kube/tusd-kube.yaml"
kubectl apply -f "${__root}/.infra/kube/tusd-kube.yaml"
kubectl set image deployment/tusd --namespace=tus tusd=docker.io/tusproject/tusd:$TRAVIS_COMMIT
@ -43,7 +38,7 @@ kubectl get deployment --namespace=tus
function cleanup {
printf "Cleaning up...\n"
rm -f ${HOME}/ca.crt
rm -f ${HOME}/.kube/config
printf "Cleaning done."
}

View File

@ -27,12 +27,6 @@ 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/d87ce93e1e287ece84d940dbfe09b0de493d9953/scripts/get | bash
deploy:
- provider: releases
api_key:
@ -45,7 +39,7 @@ deploy:
go: 1.12
repo: tus/tusd
- provider: script
script: .scripts/deploy_gcloud.sh
script: .scripts/deploy_kube.sh
on:
branch: master
go: 1.12

View File

@ -22,7 +22,7 @@ FROM alpine:3.9
COPY --from=builder /go/bin/tusd /usr/local/bin/tusd
RUN apk add --no-cache ca-certificates jq \
RUN apk add --no-cache ca-certificates jq gcc \
&& addgroup -g 1000 tusd \
&& adduser -u 1000 -G tusd -s /bin/sh -D tusd \
&& mkdir -p /srv/tusd-hooks \