Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vagrant
.vscode
.DS_Store
images/*
offline/*
docker_subscription.lic
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This demo Installs Commercially Supported Docker in a [High Availability](https:

# I'm in the fast lane
```
wget https://packages.docker.com/caas/ucp-1.1.2_dtr-2.0.2.tar.gz

git clone git@github.com:drewkhoury/docker-datacenter.git
cd docker-datacenter
touch docker_subscription.lic # add a valid `docker_subscription.lic` file https://hub.docker.com/enterprise/trial/
Expand All @@ -19,7 +21,7 @@ vagrant up
- UCP=[https://docker1:8443/](https://docker1:8443/) (login details `admin/orca`).
- DTR=[https://docker1:1337/](https://docker1:1337/) (login details `admin/adminadmin`).

# Requirments
# Requirements

- A valid `docker_subscription.lic` file for the demo
- VirtualBox
Expand All @@ -42,7 +44,7 @@ vagrant plugin install vagrant-hostmanager
vagrant up
```

All Guest VMs obtain thier IPs dynamically, and have hostname entries in `/etc/hosts` files. Your Host Machine will also have it's host file set due to the Vagrantfile config `config.hostmanager.manage_host = true` and you may be prompted to allow access to your hosts file.
All Guest VMs obtain their IPs dynamically, and have hostname entries in `/etc/hosts` files. Your Host Machine will also have it's host file set due to the Vagrantfile config `config.hostmanager.manage_host = true` and you may be prompted to allow access to your hosts file.

**Example Output:**
```
Expand Down
5 changes: 5 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ Vagrant.configure(2) do |config|
docker3.vm.provision "shell", path: "scripts/docker3.sh"
end

config.vm.define "ddc_docker_dev" do |ddc_docker_dev|
#docker3.vm.network "forwarded_port", guest: 8443, host: 4433
ddc_docker_dev.vm.provision "shell", path: "scripts/ddc-docker-dev.sh"
end

end
160 changes: 160 additions & 0 deletions presentation/demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Demo
https://docs.docker.com/ucp/configuration/dtr-integration/

### Contents
- Demo outline
- Pre-setup for Demo
- Start Demo
----

## Demo outline
[Role] - [System] - [Action]
1. Show Website v2 is boring
1. Admin - UCP - Show User/Team/Resource Labels
1. Admin - DTR - Show tags v1 and v2, but v3 does not exist
1. Logout as Admin
1. Dev - Dev - Push to Registry
1. Dev - DTR - View new Image and Tag
1. Dev - UCP - Deploy via Compose
- a. Fail - access denied
8. Release - UCP - Deploy via Compose
- a. success - App created
9. 1 week later - website is slow
10. Dev - UCP - View container (see logs, stats)
11. Dev - UCP - has found fix
- a. Fail - access denied to console

#### Roles
- Admin - admin
- Dev - drew
- Release - pablo

---
## Pre-setup for Demo

### 1. Start Vagrant
```
vagrant up docker1

# IP address of docker1
# cat /etc/hosts | grep docker1
```

### 2. UCP
See https://docs.docker.com/ucp/user-management/permission-levels/

#### Create Users
- [dev-username], FullName=Dev_VO
- Default Permission: View Only
- [release-username], FullName=Release_RC
- Default Permission: Restricted Control

#### Create Teams
- dev-vo
- Add user: [dev-username]
- Permissions - add resource label
- ProjectXYZ - View Only
- release-fc
- Add user: [release-username]
- Permission - add resource label
- ProjectXYZ - Full Control
- NOTE: Console requires FC

### 3. DTR and Push Images
- run script to create dtr accounts/teams

```
vagrant up ddc_docker_dev
vagrant ssh ddc_docker_dev -c '/home/vagrant/sync/presentation/demo/scripts/dtr-setup.sh'
vagrant ssh ddc_docker_dev -c '/home/vagrant/sync/presentation/demo/scripts/dev-push.sh v1v2'
```

### 4. Release v2
- run script to release v2 of website

```
vagrant ssh docker1 -c '/home/vagrant/sync/presentation/demo/scripts/release-v2.sh'
```

----

## Start Demo

1. ### Show ProjectXYZ website v2 is boring - http://docker1:8080

1. ### Admin - UCP - Show User/Team/Resource Labels

1. ### Admin - DTR - Show tags v1 and v2, v3 does not exist

1. ### Logout as Admin user

1. ### Dev - Dev - Push to Registry
- Run script
```
vagrant ssh ddc_docker_dev -c '/home/vagrant/sync/presentation/demo/scripts/dev-push.sh v3'
```

6. ### Dev - DTR - View new Image and Tag
- Login as Dev - show uploaded image and tags

7. ### Dev - UCP - Deploy via Compose
- Login as [dev-username]
- Create Application - ProjectXYZ
- /presentation/webB/release/docker-compose.yml
- NOTE: update IP address
- Failure - access denied

8. ### Release - UCP - Deploy via Compose
- Login as [release-username]
- Create Application - ProjectXYZ
- /presentation/webB/release/docker-compose.yml
- NOTE: update IP address
- Success
- http://docker1:8081

9. ### 1 week later - website is slow

10. ### Dev - UCP - View container (see logs, stats)
- Login as [dev-username]
- Show Containers list - show column Label
- View Container - show logs, stats pages

11. ### Dev - UCP - has found fix.
- Open console to make changes
- Failure - access denied

## End Demo
---

## Debugging Tips

### Login into DTR is failing
- Ensure you are using IP address in URL for both UCP and DTR website

### DTR website is not running
```
# log in to UCP - check 5 containers are started for DTR
# if not run following do following:
#
# Find --existing-replica-id at UCP web site Applications page
# eg "Docker Trusted Registry 2.0.3 - (Replica afb7d048d0ba)"
#
# REPLACE BELOW - "?" with valid id eg. "existing_replica_id=afb7d048d0ba"
# vagrant ssh docker1 -c 'export existing_replica_id=?; /home/vagrant/sync/scripts/supporting/dtr-re-install.sh'

```

## Sample Images

### Login as [dev-user]
EXPECT ERROR: Restart ProjectXYZ container
- [dev-user] only has 'View Only'.
- NOTE: buttons are still displayed but action results in error.

![dummy](images/userA_projectXYZ_restart_error.png)

### Login as Admin

EXPECT SUCCESS: ProjectXYZ connect console

![dummy](images/userB_projectXYZ_console_success.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions presentation/demo/release-v2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '2'

services:
nginxProjectXYZ:
# NOTE: replace hardcode IP for your machine
image: ${DOCKER1_IP}:1337/devops/project-xyz:2.0.0
# UCP access labels are case sensitive - match UCP GUI
labels:
- "com.docker.ucp.access.label=ProjectXYZ"
ports:
- "8080:80"
11 changes: 11 additions & 0 deletions presentation/demo/release-v3/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '2'

services:
nginxProjectXYZ:
# NOTE: replace hardcode IP for your machine
image: 172.28.128.11:1337/devops/project-xyz:3.0.0
# UCP access labels are case sensitive - match UCP GUI
labels:
- "com.docker.ucp.access.label=ProjectXYZ"
ports:
- "8081:80"
48 changes: 48 additions & 0 deletions presentation/demo/scripts/dev-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# set -x

function main()
{
version=$1

DTR_ORG=devops
DTR_REPO=project-xyz
DTR_USER=drew
DTR_PASSWORD=drew
DTR_TEAM=dev

export SCRIPT_PATH=/home/vagrant/sync
export PRES_PATH=/home/vagrant/sync/presentation
export IMAGE_TAG=${version}

source ${SCRIPT_PATH}/scripts/supporting/common-environment.sh

# DOCKER1_IP variable defined in docker-compose.yml
# retrieved via source command above
if [ "$version" == "3.0.0" ] ; then
docker-compose -f ${PRES_PATH}/webB/docker-compose.yml build nginxProjectXYZ
else
docker-compose -f ${PRES_PATH}/webA/docker-compose.yml build nginxProjectXYZ
fi

docker login -u ${DTR_USER} -p ${DTR_PASSWORD} ${DTR_URL}
}

start_command=$1
if [ -n "$start_command" ]; then
if [ "$start_command" == "v1v2" ]; then

main "1.0.0"
docker push ${DOCKER1_IP}:1337/${DTR_ORG}/${DTR_REPO}:${IMAGE_TAG}

main "2.0.0"
docker push ${DOCKER1_IP}:1337/${DTR_ORG}/${DTR_REPO}:${IMAGE_TAG}
fi
if [ "$start_command" == "v3" ]; then
main "3.0.0"
docker push ${DOCKER1_IP}:1337/${DTR_ORG}/${DTR_REPO}:${IMAGE_TAG}
fi
fi


90 changes: 90 additions & 0 deletions presentation/demo/scripts/dtr-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#! /bin/bash

# https://docs.docker.com/apidocs/v2.0.1/

export SCRIPT_PATH=/home/vagrant/sync

source ${SCRIPT_PATH}/scripts/supporting/common-environment.sh

DTR_ORG=devops
DTR_REPO=project-xyz
DTR_USER=drew
DTR_PASSWORD=drew
DTR_TEAM=dev

#######
## DTR
#######

function action_dtr()
{
type=$1
url=$2

curl -u admin:orca -k -H "Content-Type: application/json" \
-X ${type} https://${DTR_URL}${url}
}

function action_dtr_data()
{
type=$1
url=$2
data=$3

curl -u admin:orca -k -H "Content-Type: application/json" \
-X ${type} https://${DTR_URL}${url} --data ${data}
}

# Create DTR Org - Devops
# POST /enzi/v0/accounts
action_dtr_data "POST" "/enzi/v0/accounts" @<(cat <<EOF
{
"name": "${DTR_ORG}",
"fullName": "${DTR_ORG}",
"isOrg": true,
"isActive": true
}
EOF
)

# Create Team - TeamB
# POST /enzi/v0/accounts/{orgNameOrID}/teams
action_dtr_data "POST" "/enzi/v0/accounts/${DTR_ORG}/teams" @<(cat <<EOF
{
"name": "${DTR_TEAM}",
"description": "${DTR_TEAM}"
}
EOF
)

# add a member to a team
# PUT /enzi/v0/accounts/{orgNameOrID}/teams/{teamNameOrID}/members/{memberNameOrID}
action_dtr_data "PUT" "/enzi/v0/accounts/${DTR_ORG}/teams/${DTR_TEAM}/members/${DTR_USER}" @<(cat <<EOF
{
"isAdmin": false,
"isPublic": true
}
EOF
)

# create repo
# POST /api/v0/repositories/{namespace}

action_dtr_data "POST" "/api/v0/repositories/${DTR_ORG}" @<(cat <<EOF
{
"name": "${DTR_REPO}",
"shortDescription": "short",
"longDescription": "long",
"visibility": "public"
}
EOF
)

# grant write access to repo and team
# PUT /api/v0/repositories/{namespace}/{reponame}/teamAccess/{teamname}
action_dtr_data "PUT" "/api/v0/repositories/${DTR_ORG}/${DTR_REPO}/teamAccess/${DTR_TEAM}" @<(cat <<EOF
{
"accessLevel": "read-write"
}
EOF
)
14 changes: 14 additions & 0 deletions presentation/demo/scripts/release-v2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -x

export SCRIPT_PATH=/home/vagrant/sync
source ${SCRIPT_PATH}/scripts/supporting/common-environment.sh

mkdir -p /home/vagrant/xyz2

cp ${SCRIPT_PATH}/presentation/demo/release-v2/docker-compose.yml /home/vagrant/xyz2

cd /home/vagrant/xyz2
docker-compose config
docker-compose up -d
2 changes: 2 additions & 0 deletions presentation/webA/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx
COPY /static_html_dir /usr/share/nginx/html
Loading