Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Chapter 5

5.1 Couchbase cluster using services

Slides

  1. Show how Docker image was created: https://github.com/arun-gupta/docker-images/tree/master/couchbase

  2. Initialize swarm mode: docker swarm init

  3. Create overlay network:

    docker network create \
      -d overlay \
      couchbase
  4. Show the list of networks: docker network ls

  5. Create master service:

    docker service create \
      --name couchbase-master \
      --replicas 1 \
      -p 8091:8091 \
      --network couchbase \
      -e TYPE=MASTER \
      arungupta/couchbase
  6. List the services: docker service ls

  7. Show logs: docker service couchbase-master logs -f

  8. Show Couchbase Web Console at http://localhost:8091, show Server Nodes tab

  9. Create worker service:

    docker service create \
      --name couchbase-worker \
      --replicas 1 \
      --network couchbase \
      -e TYPE=WORKER \
      -e COUCHBASE_MASTER=couchbase-master.couchbase \
      -e AUTO_REBALANCE=false \
      arungupta/couchbase
  10. Show services: docker service ls

    1. Talk about experimental release

  11. Show logs: docker service logs couchbase-worker -f

  12. Show Couchbase Web Console again and highlight Pending Rabalance tab

  13. Click on Rebalance to rebalance the cluster

  14. Scale the cluster: docker service scale couchbase-worker=2

  15. Show services: docker service ls

  16. Show Couchbase Web Console again and highlight Pending Rabalance tab

  17. Remove the services: docker service rm couchbase-master couchbase-worker

  18. Remove the network: docker network rm couchbase

5.2 Persistent Containers Overview

Slides only

5.3 Persistent Containers

Implicit per-container storage

  1. Terminal1: Run Couchbase container: docker container run -d --name db arungupta/couchbase

  2. Check volume mounts: docker container inspect --format '{{json .Mounts }}' db | jq

    1. Show /opt/couchbase/var is mapped to the implicit storage

  3. Check the mounted volume: docker container inspect --format='{{range .Mounts}}{{.Source}}{{end}}' db

  4. Terminal2: Log into Docker for Mac VM:

    docker container run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh
    1. debian image has nsenter

    2. --pid=host means enter the process space of the VM running Docker For Mac

    3. sh says to run a shell there

  5. Show ls <volume-dir>

  6. Terminal1: Stop container: docker container stop db

  7. Remove container, including the volume: docker container rm -v db

  8. Terminal2: Show that the volume does not exist any more

Explicit per-container storage

  1. Create a new volume: docker volume create my_couchbase

  2. Check the list of volumes: docker volume ls

  3. Get more details about the volume: docker volume inspect my_couchbase

  4. Create a Couchbase container using this volume:

    docker container run \
      -d \
      --name db \
      -p 8091-8093:8091-8093 \
      -v my_couchbase:/opt/couchbase/var \
      arungupta/couchbase
  5. Check the volume mount again: docker container inspect --format '{{json .Mounts }}' db | jq

    1. Show how the newly created volume is used here

  6. Terminate the container: docker container rm -f db

  7. Delete the volume explicitly: docker volume rm my_couchbase

Per-host storage

  1. Run Couchbase container

    docker container run \
      -d \
      --name db \
      -p 8091-8093:8091-8093 \
      -v ~/couchbase:/opt/couchbase/var \
      arungupta/couchbase
  2. Check volume mounts: docker container inspect --format '{{json .Mounts }}' db | jq

    1. Show /opt/couchbase/var is mapped to the explicit directory

  3. Show data in ~/couchbase

  4. Login to Couchbase Web Console at http://localhost:8091

  5. Create a new bucket

  6. Kill the container: docker container rm -f db

  7. Restart the container using previous command

  8. Access Couchbase Web Console and show that the bucket still exists

5.4 Docker Volume Plugin

Slides only

5.5 Docker Volume Plugin in practice

Pre setup

EC2 instance

  1. Ubuntu 14.04, m3.large

    1. Add 8091 to inbound rules

  2. Login to EC2 instance: ssh -i ~/.ssh/arun-cb-west1.pem ubuntu@<public-ip>

  3. Update: sudo apt-get update

  4. Install Docker: curl -sSL https://get.docker.com/ | sh

  5. Enable non-root access: sudo usermod -aG docker ubuntu

  6. Logout and log back in

AWS EBS Volume

  1. Create 10GB EBS volume

  2. Attach the volume to EC2 instance using instance id

Px-dev

In EC2 instance:

  1. Create etcd:

    docker container run -v \
      /data/varlib/etcd \
      -p 4001:4001 \
      -d \
      portworx/etcd:latest
  2. Make root mounted volumes shareable: sudo mount --make-shared /

  3. Use lsblk to check that the volume is attached to EC2 instance

  4. Start px-dev container:

    docker container run \
      --restart=always \
      --name px \
      -d \
      --net=host \
      --privileged=true                             \
      -v /run/docker/plugins:/run/docker/plugins    \
      -v /var/lib/osd:/var/lib/osd:shared           \
      -v /dev:/dev                                  \
      -v /etc/pwx:/etc/pwx                          \
      -v /opt/pwx/bin:/export_bin:shared            \
      -v /var/run/docker.sock:/var/run/docker.sock  \
      -v /var/cores:/var/cores                      \
      -v /usr/src:/usr/src                           \
      --ipc=host                                    \
      portworx/px-dev \
      -daemon \
      -k \
      etcd://localhost:4001 \
      -c cluster1 \
      -s /dev/xvdf
  5. Check the logs: docker container logs -f px

Show

  1. Talk:

    1. EBS volume attached to EC2 instance

    2. etcd container

    3. px-dev container

  2. List the volumes: docker volume ls

  3. Check the status of attached volumes that are available to Portworx using sudo /opt/pwx/bin/pxctl status

  4. Create a Docker volume:

    docker volume create -d pxd -o size=10G -o fs=ext4 --name cbvol
  5. List the volumes: docker volume ls and show newly created volume

  6. Create a Couchbase container with Portworx volume:

    docker container run \
      -d \
      --name db \
      -v cbvol:/opt/couchbase/var \
      -p 8091-8094:8091-8094 \
      -p 11210:11210 \
      arungupta/couchbase
  7. Login to Couchbase Web Console: http://<public-ip>:8091

    1. Login: Administrator, password: password

  8. Create a new data bucket

  9. See the list of containers

  10. Kill the db container: docker container rm -f db

  11. Restart the database container:

    docker container run \
      -d \
      --name db \
      -v cbvol:/opt/couchbase/var \
      -p 8091-8094:8091-8094 \
      -p 11210:11210 \
      arungupta/couchbase
  12. Login to Couchbase Web Console and show that the bucket still exists

Cleanup

  1. Detach volume

  2. Delete volume

  3. Terminate EC2 instance