Skip to content

Commit

Permalink
Change deployment script to create ES first
Browse files Browse the repository at this point in the history
  • Loading branch information
singhpratyush committed Jul 27, 2017
1 parent 4b6a158 commit fbfa6b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
15 changes: 15 additions & 0 deletions .utility/push-docker.sh
Expand Up @@ -32,3 +32,18 @@ docker tag $TAG_COMMIT $TAG_BRANCH
docker push $TAG_BRANCH

docker tag $TAG_BRANCH loklak_server

# Build and push Kubernetes Docker image


KUBERNETES_BRANCH=loklak/loklak_server:latest-kubernetes-$TRAVIS_BRANCH

if [ "$TRAVIS_BRANCH" == "development" ]; then
docker build -t loklak_server_kubernetes kubernetes/images/development
docker tag loklak_server_kubernetes $KUBERNETES_BRANCH
docker push $KUBERNETES_BRANCH
elif [ "$TRAVIS_BRANCH" == "master" ]; then
# Build and push master
else
echo "Skipping Kubenetes image push for branch $TRAVIS_BRANCH"
fi
22 changes: 1 addition & 21 deletions docs/installation/deploying-development-kubernetes.md
Expand Up @@ -39,34 +39,14 @@ gcloud compute disks create --size=100GB --zone=<same as cluster zone> data-inde
./kubernetes/bin/deploy-development.sh create
```

### 2.5. Label the Node

The persistent disk is attached to the node running `api-server`. But in case of rolling update, new container may get created on a different node.

This would result in issues as the new instance would now try to mount a HDD which is already in use by another (older) instance.

To avoid this, we enforce the new containers get created on same instance by labeling them. A selector for this is already present in the `api-server` deployment configuration.

You can get the node name by running

```bash
kubectl get nodes --namespace=web
```

Choose one of the nodes and label it as `server=primary`.

```bash
kubectl label nodes <node-name> server=primary
```

## 3. Modifying deployment

### 3.1. Setting a new Docker image

To update deployment image, we can use the following command -

```bash
./kubernetes/bin/update-development-image.sh <image name> # Defaults to loklak/loklak_server:development
./kubernetes/bin/update-development-image.sh <image name> # Defaults to loklak/loklak_server:latest-kubernetes-development
```

### 3.2. Updating configurations
Expand Down
17 changes: 13 additions & 4 deletions kubernetes/bin/deploy-development.sh
@@ -1,17 +1,26 @@
#!/bin/bash
export DIR=kubernetes

USAGE="USAGE: ./kubernetes/bin/deploy-development.sh create|delete"

if [ "$1" = "create" ]; then
echo "Creating objects from configurations."
echo "Make sure that persistent disk is already created."
kubectl create -R -f ${DIR}/yamls/development/
echo "Waiting for server to start up. ~1m."
sleep 60
echo ""
echo "Creating Elasticsearch Replication Controller"
kubectl create -R -f ${DIR}/yamls/development/elasticsearch/
echo "Waiting for server to start up. ~40s."
sleep 40
echo "Creating loklak deployment"
kubectl create -R -f ${DIR}/yamls/development/api-server/
echo "Trying to fetch public IP"
kubectl get services --namespace=web
echo "Deployed loklak on Kubernetes"
elif [ "$1" = "delete" ]; then
echo "Deleting objects created from configurations"
kubectl delete -R -f ${DIR}/yamls/development/
kubectl delete -R -f ${DIR}/yamls/development/ || true
echo "Deleted loklak project from Kubernetes"
elif [ -z "$1" ]; then
echo "No arguments provided"
echo $USAGE
fi
2 changes: 1 addition & 1 deletion kubernetes/bin/update-development-image.sh
@@ -1,6 +1,6 @@
IMAGE=$1
if [ -z $1 ]; then
IMAGE=loklak/loklak_server:development
IMAGE=loklak/loklak_server:latest-kubernetes-development
fi

echo "Setting image $IMAGE"
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/yamls/development/api-server/api-deployment.yml
Expand Up @@ -15,7 +15,7 @@ spec:
server: primary
containers:
- name: server
image: singhpratyush/loklak_server:latest-ext-es-kubernetes-dev
image: loklak/loklak_server:latest-kubernetes-development
livenessProbe:
httpGet:
path: /api/status.json
Expand Down

0 comments on commit fbfa6b6

Please sign in to comment.