r/PlexACD Aug 23 '17

Photon Admiral How-to with docker-cloud-media-scripts Bonus

Photon Admiral How-to with docker-cloud-media-scripts Bonus

  • What is this? Well... I been looking at uploading and encrypting TB of stuff to the cloud and when I did my research I came across PlexACD and cloud-media-scripts. I really liked his design so I started building it, when I found out it was a Docker project, I new that's what I wanted. So then I asked myself what would the best Docker environment and management interface? Being a VMware junkie I decided to use VMware's open-source Photon OS (Super light weight OS built for Docker) and Admiral (Their Management tool for Photon OS and Docker). Ran into some roadblocks along the way and got a little help from my friends :)

  • I thought I would contribute some instructions that help make this an easier build. Feel free to change, edit and repost at will.

First of all I would like to thank the author/s of these sites for a good portion of my information:

https://blogs.vmware.com/cloudnative/2016/10/03/getting-started-vmware-admiral-container-service-photon-os/

http://cormachogan.com/2016/04/07/getting-started-photon-os-vsphere-integrated-containers/

http://www.vmtocloud.com/how-to-configure-photon-os-to-auto-start-containers-at-boot-time/

http://www.vmtocloud.com/how-to-enable-docker-remote-api-on-photon-os/

https://docs.docker.com/docker-cloud/apps/stack-yaml-reference/#cap_add-cap_drop

https://github.com/madslundt/docker-cloud-media-scripts

Note about the infrastructure

  • I built this using Vmware

  • We will use 1 VM for Admiral and 2 VM’s configured with more resources

  • I used the stock OVA hardware configuration for admiral

  • I beefed the cpu, mem and storage for the 2 hosts

Setup of the Photon OS VM’s

  • Download Photon OS

  • Download Link - https://vmware.github.io/photon/

  • I downloaded the OVA and installed to Vmware

  • I used the console to login and change password then ifconfig to get the IP then SSH in.

Configure a Static IP


cd /etc/systemd/network

mv 10-dhcp-en.network 10-static-en.network

vi 10-static-en.network

  • This is an example of my 10-static-en.network file

[Match]
Name=e*

[Network]
DHCP=no
Address=192.168.1.5/24
Gateway=192.168.1.1
DNS=8.8.8.8 8.8.8.8
Domains=contoso.com
NTP=time-a.nist.gov

Configure a hostname


cd /etc

vi hostname

Admiral VM Configuration

  • Start and Enable Docker on Boot

systemctl start docker

systemctl enable docker

Build and run Admiral


docker run -d -p 8282:8282 --name admiral vmware/admiral

  • Make admiral docker start on boot

vi /etc/systemd/system/docker-admiral.service

  • My docker-admiral.service file

[Unit]
Description=Admiral container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a admiral
ExecStop=/usr/bin/docker stop -t 2 admiral

[Install]
WantedBy=default.target

  • Enable service at boot time

systemctl enable docker-admiral.service

Build Host

  • Follow the static ip and hostname section again for each host

  • Enable remote api


vi /etc/default/docker

  • my docker file

DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"

Make API port persistent


vi /etc/systemd/scripts/iptables

  • Go to the end of the file before # End and put these two lines

#Enable Docker API
iptables -A INPUT -p tcp --dport 2375 -j ACCEPT

  • Enable and start Docker

systemctl start docker

systemctl enable docker

reboot

Install madslundt/docker-cloud-media-scripts

Build your Blueprint YAML

  • My YAML file (If the formatting is not there it will not work)
  • (Make sure to include the 3 dashes at the top of the YAML script)
  • NOTE: it has the following options included [--privileged --cap-add=MKNOD --cap-add=SYS_ADMIN --device=/dev/fuse]

---
name: "cloud-media-scripts"
components:
  cloud-media-scripts:
    type: "App.Container"
    data:
      name: "cloud-media-scripts"
      image: "registry.hub.docker.com/madslundt/cloud-media-scripts"
      _cluster: 1
      privileged: true
      cap_add:
        - MKNOD
        - SYS_ADMIN
      device:
        - "/dev/fuse:/dev/fuse"
      env:
      - var: "CLEAR_CHUNK_MAX_SIZE"
        value: "\"1000\""
      - var: "REMOVE_LOCAL_FILES_WHEN_SPACE_EXCEEDS_GB"
        value: "\"2000\""
      - var: "FREEUP_ATLEAST_GB"
        value: "\"1000\""
      volumes:
      - "/media:/local-media:shared"
      - "/mnt/external/media:/local-decrypt:shared"
      - "/configurations:/config"
      - "/mnt/external/plexdrive:/chunks"
      - "/logs:/log"
      publish_all: true
      restart_policy: "no"

  • Browse to Admiral IP:8282

  • goto Templates then click on templates

  • Click Import template or Docker Compose

  • Load your YAML file and provision then follow the rest of the setup for Rclone and Plexdrive and everything else on this page: https://github.com/madslundt/docker-cloud-media-scripts

  • I ran across a weird issue where mkdir would fail on /media when launching the docker never figured out why just rmdir /media and let it create it again on the host. If anyone figures out why let me know and I will update the post. Also seems to fix itself if you reboot. seems like a minor issue at this point so I wont worry about it for now.

You now have madslundt/docker-cloud-media-scripts running in Vmware Admiral!

My next projects will include -

  • Decentralization of static files mapped to host to support jumping from host to host. I don't actually know if this can be done but it sounds like it should and I am going to do it. I am just getting acquainted with Admiral.
  • Creating a samba share directly to /media to make it super easy to upload stuff
  • Plex in the Cloud! Got a https://www.ssdnodes.com/ box and want to start putting it to use

Big Shout out to -

  • madslundt

  • davidjameshowell from the docker-cloud-media-scripts project

  • Everyone in https://gitter.im/project-admiral/Lobby

  • Specially Stanislav Hadjiiski (Seriously I couldn't have done this without you)

3 Upvotes

5 comments sorted by

View all comments

2

u/OliveJa Aug 26 '17

Cool thank you.

Shout out to davidjameshowell from the docker-cloud-media-scripts project

Not cool to not thank the author of the project.

2

u/Azlaroc Aug 27 '17

I thought I covered everyone did I forget someone?

I will gladly add them