14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Panamax をもっと簡単に Vagrant だけで使いたい

Posted at

Panamax のフロントエンドのスクリプトを読んでいたら、実はそんなに複雑なことをしていないようなので、理解しやすいように整理して cloud-config を使うように書き直してみました。
Vagrant で一括して管理できますし、見通しも良くなっていろいろ弄れるようになりました。
今はまだ対応してないようですが、クラスタを構築する際も簡単になるような気がします。

Panamax without Installer
https://gist.github.com/YungSang/0440f754c01a07d0f1ce
※) Panamax v0.1.2 に基いています。

Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
 
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "yungsang/coreos"
 
  config.vm.define "panamax" do |panamax|
    panamax.vm.hostname = "panamax"
 
    panamax.vm.network :forwarded_port, guest: 3000, host: 8888
    panamax.vm.network :forwarded_port, guest: 3001, host: 8889
 
    panamax.vm.provision :docker do |d|
      d.pull_images "centurylink/panamax-ui:latest"
      d.pull_images "centurylink/panamax-api:latest"
      d.pull_images "google/cadvisor:0.1.0"
    end
 
    panamax.vm.provision :file, source: "./panamax.yml", destination: "/tmp/vagrantfile-user-data"
 
    panamax.vm.provision :shell do |sh|
      sh.privileged = true
      sh.inline = <<-EOT
        export PANAMAX_ID=$(/usr/bin/uuidgen)
        sed -e "s/%PANAMAX_ID%/${PANAMAX_ID}/g" -i /tmp/vagrantfile-user-data
 
        mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/
      EOT
    end
  end
end
panamax.yml
#cloud-config
 
coreos:
  units:
    - name: etcd.service
      command: start
 
    - name: fleet.service
      command: start
 
    - name: panamax-metrics.service
      command: start
      runtime: no
      content: |
        [Unit]
        Description=Panamax Metrics
 
        [Service]
        ExecStartPre=-/usr/bin/docker rm -f PMX_CADVISOR
        ExecStart=/usr/bin/docker run --volume=/var/run:/var/run:rw --volume=/sys/fs/cgroup/:/sys/fs/cgroup:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=:8080 --name=PMX_CADVISOR google/cadvisor:0.1.0
        ExecStop=/usr/bin/docker stop PMX_CADVISOR
        Restart=always
 
        [Install]
        WantedBy=multi-user.target    
 
    - name: panamax-api.service
      command: start
      runtime: no
      content: |
        [Unit]
        Description=Panamax API
        After=docker.service
        Requires=docker.service
 
        [Service]
        ExecStartPre=-/usr/bin/docker rm -f PMX_API
        ExecStart=/usr/bin/docker run --name PMX_API -v /var/panamax-data:/usr/src/app/db/mnt -m=1g -c=10 -v /var/run/docker.sock:/run/docker.sock:rw -e PANAMAX_ID=%PANAMAX_ID% -e JOURNAL_ENDPOINT=http://172.17.42.1:19531 -e FLEETCTL_ENDPOINT=http://172.17.42.1:4001 -t -p 3001:3000 centurylink/panamax-api
        ExecStop=/usr/bin/docker stop PMX_API
        Restart=always
 
        [Install]
        WantedBy=multi-user.target      
 
    - name: panamax-ui.service
      command: start
      runtime: no
      content: |
        [Unit]
        Description=Panamax UI
        After=panamax-api.service panamax-metrics.service
        Requires=panamax-api.service panamax-metrics.service
 
        [Service]
        ExecStartPre=-/usr/bin/docker rm -f PMX_UI
        ExecStart=/usr/bin/docker run --name PMX_UI -m=1g -c=10 -v /var/run/docker.sock:/run/docker.sock:rw --link PMX_API:PMX_API --link PMX_CADVISOR:CADVISOR -p 3000:3000 centurylink/panamax-ui
        ExecStop=/usr/bin/docker stop PMX_UI
        Restart=always
 
        [Install]
        WantedBy=multi-user.target

for VirtualBox

$ vagrant up
$ open http://localhost:8888

for Parallels Desktop 9

$ vagrant up --provider parallels
$ open http://$(vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"):3000

for Parallels Desktop 10

$ vagrant up --provider parallels
$ open http://localhost:8888

※) PD 10 からは VirtualBox と同様に Vagrant の Port Forwarding に対応する。

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?