-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1502 from amaltaro/fix-couchdb-vm
Correct user info for CouchDB image; remove unneded cert/proxy hooks
- Loading branch information
Showing
5 changed files
with
99 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
|
||
|
||
### build image | ||
docker build -t cmssw/couchdb . | ||
|
||
### list images | ||
docker images | ||
|
||
### list of running containers | ||
docker ps --no-trunc -aq | ||
|
||
### remove all running containers | ||
docker rm -f `docker ps --no-trunc -aq` | ||
|
||
### run given image | ||
docker run --rm -h `hostname -f` -v /tmp/vk:/etc/secrets -i -t cmssw/couchdb /bin/bash | ||
|
||
### remove existing image | ||
docker rmi cmssw/couchdb | ||
|
||
### inspect running container | ||
docker ps # find docker id | ||
docker inspect <docker_id> | grep IPAddress | ||
|
||
### push image to docker.com | ||
docker push cmssw/couchdb | ||
|
||
### references | ||
https://stackoverflow.com/questions/18497688/run-a-docker-image-as-a-container#18498313 | ||
https://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers#17237701 | ||
http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/ | ||
### CouchDB image construction | ||
Image is built with the expected `_couchdb` user, also used to run the service. | ||
* latest version has been tagged as `3.2.2-stable`. | ||
* **configuration**: available under `/data/srv/auth/couchdb/`, | ||
* **database**: both database and views are available under `/data/srv/state/couchdb/database/`. | ||
* **couchapps**: couchapps libraries and code is available under `/data/srv/state/couchdb/stagingarea/`. | ||
* **logs**: finally, service logs can be found at `/data/srv/logs/couchdb/`. | ||
|
||
### Run CouchDB container | ||
Connect to the cmsweb backend VM with the cmsweb account and: | ||
``` | ||
cd /data/srv | ||
curl https://raw.githubusercontent.com/dmwm/CMSKubernetes/ffb19657b8a768b5a03557bb97021006270fb28b/docker/couchdb/docker-run.sh > docker-run.sh | ||
chmod +x docker-run.sh | ||
./docker-run.sh | ||
``` | ||
|
||
### Stop CouchDB container | ||
Connect to the cmsweb backend VM with the cmsweb account and: | ||
``` | ||
docker stop couchdb | ||
docker rm couchdb | ||
``` | ||
|
||
### Checking status of CouchDB service | ||
``` | ||
docker exec -it couchdb sh -c "/data/srv/current/config/couchdb/manage status" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Script to list all databases in CouchDB and print a basic summary for each of them. | ||
""" | ||
import os | ||
import sys | ||
import socket | ||
import requests | ||
from itertools import chain | ||
|
||
# Fetch a list of databases | ||
resp = requests.get(f'http://localhost:5984/_all_dbs') | ||
if resp.status_code >= 400: | ||
print(f"Failed to list databases: {resp.status_code}") | ||
else: | ||
all_dbs = resp.json() | ||
print(f"Node contains the following databases: {all_dbs}") | ||
|
||
|
||
print(f"\n***** Summary of databases ****") | ||
for db_name in all_dbs: | ||
resp = requests.get(f'http://localhost:5984/{db_name}') | ||
if resp.status_code >= 400: | ||
print(f"Request failed for db {db_name} with status code: {resp.status_code}") | ||
else: | ||
data = {} | ||
for kname, kdata in resp.json().items(): | ||
if kname in ["db_name", "doc_count", "doc_del_count", "sizes"]: | ||
data[kname] = kdata | ||
print(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
COUCH_LOGS_DIR=/data/srv/logs/couchdb/ | ||
COUCH_DB_DIR=/data/srv/state/couchdb/database/ | ||
COUCH_STAGING_DIR=/data/srv/state/couchdb/stagingarea/ | ||
COUCH_USR=_couchdb | ||
|
||
echo "Creating necessary directories on the host to persist logs and data" | ||
mkdir -p $COUCH_LOGS_DIR | ||
mkdir -p $COUCH_DB_DIR | ||
mkdir -p $COUCH_STAGING_DIR | ||
sudo chown $COUCH_USR:zh $COUCH_LOGS_DIR | ||
sudo chown -R $COUCH_USR:zh $COUCH_DB_DIR/.. | ||
|
||
# Define directory to store credentials and standard configuration | ||
COUCH_SECR_DIR=/data/srv/auth/couchdb/ | ||
echo "Creating directory to store credentials and local.ini under: $COUCH_SECR_DIR" | ||
mkdir -p $COUCH_SECR_DIR | ||
sudo chown -R $COUCH_USR:zh $COUCH_SECR_DIR | ||
|
||
# Define command line arguments for docker run | ||
dockerOpts=" \ | ||
--detach \ | ||
--network=host \ | ||
--hostname=$(hostname -f) \ | ||
--name=couchdb \ | ||
--mount type=bind,source=$COUCH_SECR_DIR,target=/etc/secrets \ | ||
--mount type=bind,source=$COUCH_DB_DIR,target=$COUCH_DB_DIR \ | ||
--mount type=bind,source=$COUCH_STAGING_DIR,target=$COUCH_STAGING_DIR \ | ||
--mount type=bind,source=$COUCH_LOGS_DIR,target=$COUCH_LOGS_DIR \ | ||
" | ||
|
||
couch_tag=3.2.2-stable | ||
echo "Executing docker run for CouchDB tag: $couch_tag" | ||
docker run $dockerOpts registry.cern.ch/cmsweb/couchdb:$couch_tag && docker logs -f couchdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters