Skip to content

Commit

Permalink
Change cloud in gcloud-deploy (transloadit#1729)
Browse files Browse the repository at this point in the history
* Change roles

* Disable tests for faster iterations

* Remove condiiton

* Test python base64 decode

* Test a different file

* Decode that shit

* Use normal file also

* Print the file

* Remove waste of time

* Remove more waste

* Fix it

* Change space name

* Turn everything back
  • Loading branch information
kiloreux authored and kvz committed Jul 14, 2019
1 parent 53e550f commit 1f473c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 47 deletions.
40 changes: 11 additions & 29 deletions infra/kube/companion/companion-kube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: companion
namespace: uppy
namespace: companion
labels:
app: companion
spec:
Expand All @@ -17,41 +17,25 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: companion
namespace: uppy
namespace: companion
spec:
selector:
matchLabels:
app: companion
replicas: 2
replicas: 1
serviceName: "companion"
template:
metadata:
labels:
app: companion
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: cloud.google.com/gke-preemptible
operator: Exists
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- companion
topologyKey: kubernetes.io/hostname
containers:
- image: docker.io/transloadit/companion:latest
imagePullPolicy: Always
name: companion
envFrom:
- secretRef:
name: uppy-companion-env
name: companion-env
ports:
- containerPort: 3020
volumeMounts:
Expand All @@ -62,7 +46,6 @@ spec:
name: companion-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "standard"
resources:
requests:
storage: 10Gi
Expand All @@ -71,30 +54,29 @@ apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: companion
namespace: uppy
namespace: companion
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
certmanager.k8s.io/cluster-issuer: "letsencrypt-prod"
certmanager.k8s.io/acme-http01-edit-in-place: "true"
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "route"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
tls:
- secretName: server-tls
hosts:
- companion.uppy.io
- server.uppy.io
- secretName: uppy-tls
hosts:
- server.uppy.io
rules:
- host: server.uppy.io
- host: companion.uppy.io
http:
paths:
- path: /
backend:
serviceName: companion
servicePort: 80
- host: companion.uppy.io
- host: server.uppy.io
http:
paths:
- path: /
Expand All @@ -106,7 +88,7 @@ apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: companion
namespace: uppy
namespace: companion
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
17 changes: 4 additions & 13 deletions infra/kube/companion/companion-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: uppy-redis
namespace: uppy
namespace: companion
spec:
accessModes:
- ReadWriteOnce
storageClassName: "standard"
resources:
requests:
storage: 20Gi
Expand All @@ -18,7 +17,7 @@ metadata:
app: uppy-redis
release: uppy
name: uppy-redis
namespace: uppy
namespace: companion
spec:
replicas: 1
selector:
Expand All @@ -34,13 +33,6 @@ spec:
labels:
app: uppy-redis
spec:
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: cloud.google.com/gke-preemptible
# operator: DoesNotExist
containers:
- env:
- name: REDIS_PASSWORD
Expand Down Expand Up @@ -101,7 +93,7 @@ metadata:
labels:
app: uppy-redis
name: uppy-redis
namespace: uppy
namespace: companion
spec:
ports:
- name: redis
Expand All @@ -111,5 +103,4 @@ spec:
selector:
app: uppy-redis
sessionAffinity: None
type: ClusterIP

type: ClusterIP
10 changes: 5 additions & 5 deletions infra/kube/gcloud-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ docker push transloadit/companion:latest;
echo "Create directory..."
mkdir ${HOME}/.kube
echo "Writing KUBECONFIG to file..."
echo $KUBECONFIGVAR | base64 --decode -i > ${HOME}/.kube/config
echo $KUBECONFIGVAR | python -m base64 -d > ${HOME}/.kube/config
echo "KUBECONFIG file written"

sleep 10s # This cost me some precious debugging time.
kubectl apply -f "${__kube}/companion/companion-kube.yaml"
kubectl apply -f "${__kube}/companion/companion-redis.yaml"
kubectl set image statefulset companion --namespace=uppy companion=docker.io/transloadit/companion:$TRAVIS_COMMIT
kubectl set image statefulset companion --namespace=companion companion=docker.io/transloadit/companion:$TRAVIS_COMMIT
sleep 10s

kubectl get pods --namespace=uppy
kubectl get service --namespace=uppy
kubectl get deployment --namespace=uppy
kubectl get pods --namespace=companion
kubectl get service --namespace=companion
kubectl get deployment --namespace=companion

function cleanup {
printf "Cleaning up...\n"
Expand Down

0 comments on commit 1f473c4

Please sign in to comment.