1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00
commons/scripts/deploy_on_k8s.sh
Javier Cortejoso feaf58ae3f
Fix typo
2019-04-15 16:35:42 +02:00

45 lines
1.4 KiB
Bash

#!/bin/bash
if [ -z "${TRAVIS_TAG}" ]; then
echo "Variable \$TRAVIS_TAG not set or empty. Skiping deploying new version on k8s"
exit 0
fi
if ! [[ "${TRAVIS_TAG}" =~ ^v[0-9]\.[0-9]\.[0-9]$ ]]; then
echo "Variable \$TRAVIS_TAG does not match with vx.y.z format. Skiping deploying new version on k8s"
exit 0
fi
curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /tmp/kubectl
chmod +x /tmp/kubectl
mkdir -p ~/.kube
cat<<EOF > ~/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${KUBE_CERTIFICATE_AUTHORITY_DATA}
server: ${KUBE_SERVER}
name: cluster
contexts:
- context:
cluster: cluster
namespace: ${KUBE_NAMESPACE}
user: ${KUBE_USER}
name: cluster
current-context: cluster
kind: Config
preferences: {}
users:
- name: ${KUBE_USER}
user:
client-key-data: ${KUBE_CLIENT_KEY_DATA}
token: ${KUBE_TOKEN}
EOF
# Patch deployed versions in k8s cluster
/tmp/kubectl patch deployment marketplace-client-commons -p\
"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"marketplace-commons\",\"image\":\"oceanprotocol/commons_client:${TRAVIS_TAG}\"}]}}}}"
/tmp/kubectl patch deployment marketplace-server-commons -p\
"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"marketplace-server-commons\",\"image\":\"oceanprotocol/commons_server:${TRAVIS_TAG}\"}]}}}}"