Commit 6368a289 authored by qhoangxuan's avatar qhoangxuan

remove deploy folder, update install.rst

parent 17e38865
apiVersion: v1
kind: ReplicationController
metadata:
name: zoe-api-fsdna
namespace: fsdna
labels:
app: zoe-api
task: test
spec:
replicas: 3
selector:
app: zoe-api
task: test
template:
metadata:
labels:
app: zoe-api
task: test
spec:
containers:
- name: zoe-api-fsdna
image: zoe-repo/zoe:devel
ports:
- containerPort: 5001
name: zoe-api
command: ["python3", "zoe-api.py", "--debug", "--backend", "Kubernetes", "--deployment-name", "prod", "--dbuser", "postgres", "--dbhost", "zoe-postgres-service", "--dbport", "5432", "--dbname", "postgres", "--dbpass", "postgres", "--overlay-network-name", "my-net", "--master-url", "tcp://zoe-master-service:4850", "--auth-type", "text", "--proxy-type", "apache", "--proxy-container", "apache2", "--proxy-config-file", "/etc/apache2/sites-available/all.conf", "--proxy-path", "fsdna.on.kpmg.de/zoe", "--proxy-docker-sock", "tcp://192.168.12.2:2375"]
volumeMounts:
- name: kube-config
mountPath: /opt/zoe/kube.conf
volumes:
- name: kube-config
hostPath:
path: /media/sdb/kubernetes/config
apiVersion: v1
kind: Service
metadata:
name: zoe-api-service
namespace: fsdna
labels:
app: zoe-api
task: test
spec:
type: LoadBalancer
ports:
- name: zoe-api
port: 5001
targetPort: zoe-api
selector:
app: zoe-api
task: test
apiVersion: v1
kind: ReplicationController
metadata:
name: zoe-master-fsdna
namespace: fsdna
labels:
app: zoe-master
task: test
spec:
replicas: 1
selector:
app: zoe-master
task: test
template:
metadata:
labels:
app: zoe-master
task: test
spec:
containers:
- name: zoe-master-fsdna
image: zoerepo/zoe:devel
ports:
- containerPort: 4850
name: zoe-master
command: ["python3", "zoe-master.py", "--debug", "--backend", "Kubernetes", "--deployment-name", "prod", "--dbuser", "postgres", "--dbhost", "zoe-postgres-service", "--dbport", "5432", "--dbname", "postgres", "--dbpass", "postgres", "--overlay-network-name", "my-net", "--auth-type", "text", "--proxy-type", "apache", "--proxy-container", "apache2", "--proxy-config-file", "/etc/apache2/sites-available/all.conf", "--proxy-path", "fsdna.on.kpmg.de/zoe", "--proxy-docker-sock", "tcp://192.168.12.2:2375"]
volumeMounts:
- name: kube-config
mountPath: /opt/zoe/kube.conf
volumes:
- name: kube-config
hostPath:
path: /media/sdb/kubernetes/config
apiVersion: v1
kind: Service
metadata:
name: zoe-master-service
namespace: fsdna
labels:
app: zoe-master
task: test
spec:
type: LoadBalancer
ports:
- name: zoe-master
port: 4850
targetPort: zoe-master
selector:
app: zoe-master
task: test
apiVersion: v1
kind: ReplicationController
metadata:
name: zoe-postgres-fsdna
namespace: fsdna
labels:
app: zoe-postgres
task: test
spec:
replicas: 1
selector:
app: zoe-postgres
task: test
template:
metadata:
labels:
app: zoe-postgres
task: test
spec:
containers:
- name: zoe-postgres-fsdna
image: postgres
ports:
- containerPort: 5432
name: postgresql
env:
- name: "POSTGRES_USER"
value: "postgres"
- name: "POSTGRES_PASSWORD"
value: "postgres"
- name: "POSTGRES_DB"
value: "postgres"
apiVersion: v1
kind: Service
metadata:
name: zoe-postgres-service
namespace: fsdna
labels:
app: zoe-postgres
task: test
spec:
type: LoadBalancer
ports:
- name: postgresql
port: 5432
targetPort: 5432
selector:
app: zoe-postgres
task: test
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
description: A Helm chart to deploy Zoe on Kubernetes
name: zoe
version: 0.1.0
maintainers:
- name: Quang-Nhat Hoang-Xuan
email: qhoangxuan@kpmg.com
apiVersion: v1
kind: Service
metadata:
name: {{ template "postgres-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Postgres.Component}}"
spec:
ports:
- port: {{.Values.Postgres.ServicePort}}
targetPort: {{.Values.Postgres.ContainerPort}}
selector:
component: "{{.Release.Name}}-{{.Values.Postgres.Component}}"
type: "LoadBalancer"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "postgres-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Postgres.Component}}"
spec:
replicas: {{default 1 .Values.Postgres.Replicas}}
strategy:
type: RollingUpdate
selector:
matchLabels:
component: "{{.Release.Name}}-{{.Values.Postgres.Component}}"
template:
metadata:
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Postgres.Component}}"
spec:
containers:
- name: {{ template "postgres-fullname" . }}
image: "{{.Values.Postgres.Image}}:{{.Values.Postgres.ImageTag}}"
ports:
- containerPort: {{.Values.Postgres.ContainerPort}}
resources:
requests:
cpu: "{{.Values.Postgres.Cpu}}"
memory: "{{.Values.Postgres.Memory}}"
env:
- name: POSTGRES_USER
value: {{ default "postgres" .Values.Postgres.User | quote }}
- name: POSTGRES_PASSWORD
value: {{ default "postgres" .Values.Postgres.Password | quote }}
- name: POSTGRES_DB
value: {{ default "postgres" .Values.Postgres.Database | quote }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "api-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.API.Component}}"
spec:
ports:
- port: {{.Values.API.ServicePort}}
targetPort: {{.Values.API.ContainerPort}}
selector:
component: "{{.Release.Name}}-{{.Values.API.Component}}"
type: "LoadBalancer"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "api-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.API.Component}}"
spec:
replicas: {{default 1 .Values.API.Replicas}}
strategy:
type: RollingUpdate
selector:
matchLabels:
component: "{{.Release.Name}}-{{.Values.API.Component}}"
template:
metadata:
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.API.Component}}"
spec:
containers:
- name: {{ template "api-fullname" . }}
image: "{{.Values.API.Image}}:{{.Values.API.ImageTag}}"
command: ["python3", "zoe-api.py", "--debug", "--swarm", "consul://{{.Values.Configuration.Swarm}}", "--deployment-name", "{{.Values.Configuration.DeploymentName}}", "--dbuser", "{{.Values.Postgres.Database}}", "--dbhost", "{{ template "postgres-fullname" . }}", "--dbport", "{{.Values.Postgres.ServicePort}}", "--dbname", "{{.Values.Postgres.Database}}", "--dbpass", "{{.Values.Postgres.Password}}", "--overlay-network-name", "{{.Values.Configuration.OverlayNetwork}}", "--master-url", "tcp://{{ template "master-fullname" . }}:{{.Values.Master.ServicePort}}", "--auth-type", "{{.Values.Configuration.AuthenticationType}}", "--proxy-type", "{{.Values.Configuration.ProxyType}}", "--proxy-container", "{{.Values.Configuration.ProxyContainerName}}", "--proxy-config-file", "{{.Values.Configuration.ProxyConfigFile}}", "--proxy-path", "{{.Values.Configuration.ProxyPath}}", "--proxy-docker-sock", "{{.Values.Configuration.ProxyDockerSock}}"]
ports:
- containerPort: {{.Values.API.ContainerPort}}
resources:
requests:
cpu: "{{.Values.API.Cpu}}"
memory: "{{.Values.API.Memory}}"
apiVersion: v1
kind: Service
metadata:
name: {{ template "master-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Master.Component}}"
spec:
ports:
- port: {{.Values.Master.ServicePort}}
targetPort: {{.Values.Master.ContainerPort}}
selector:
component: "{{.Release.Name}}-{{.Values.Master.Component}}"
type: "LoadBalancer"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "master-fullname" . }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Master.Component}}"
spec:
replicas: {{default 1 .Values.Master.Replicas}}
strategy:
type: RollingUpdate
selector:
matchLabels:
component: "{{.Release.Name}}-{{.Values.Master.Component}}"
template:
metadata:
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}-{{.Values.Master.Component}}"
spec:
containers:
- name: {{ template "master-fullname" . }}
image: "{{.Values.Master.Image}}:{{.Values.Master.ImageTag}}"
command: ["python3", "zoe-master.py", "--debug", "--swarm", "consul://{{.Values.Configuration.Swarm}}", "--deployment-name", "{{.Values.Configuration.DeploymentName}}", "--dbuser", "{{.Values.Postgres.Database}}", "--dbhost", "{{ template "postgres-fullname" . }}", "--dbport", "{{.Values.Postgres.ServicePort}}", "--dbname", "{{.Values.Postgres.Database}}", "--dbpass", "{{.Values.Postgres.Password}}", "--overlay-network-name", "{{.Values.Configuration.OverlayNetwork}}", "--auth-type", "{{.Values.Configuration.AuthenticationType}}", "--proxy-type", "{{.Values.Configuration.ProxyType}}", "--proxy-container", "{{.Values.Configuration.ProxyContainerName}}", "--proxy-config-file", "{{.Values.Configuration.ProxyConfigFile}}", "--proxy-path", "{{.Values.Configuration.ProxyPath}}", "--proxy-docker-sock", "{{.Values.Configuration.ProxyDockerSock}}"]
ports:
- containerPort: {{.Values.Master.ContainerPort}}
resources:
requests:
cpu: "{{.Values.Master.Cpu}}"
memory: "{{.Values.Master.Memory}}"
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
{{- end -}}
{{/*
Create fully qualified names.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "master-fullname" -}}
{{- $name := default .Chart.Name .Values.Master.Name -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
{{- end -}}
{{- define "api-fullname" -}}
{{- $name := default .Chart.Name .Values.API.Name -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
{{- end -}}
{{- define "postgres-fullname" -}}
{{- $name := default .Chart.Name .Values.Postgres.Name -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
{{- end -}}
# Default values for zoe.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
Master:
Name: zoe-master
Image: "zoerepo/zoe"
ImageTag: "devel"
Replicas: 3
Component: "zoe-master"
Cpu: "100m"
Memory: "512Mi"
ServicePort: 4850
ContainerPort: 4850
API:
Name: zoe-api
Image: "zoerepo/zoe"
ImageTag: "devel"
Replicas: 3
Component: "zoe-api"
Cpu: "100m"
Memory: "512Mi"
ServicePort: 5001
ContainerPort: 5001
Postgres:
Name: zoe-postgres
Image: postgres
ImageTag: "latest"
Replicas: 1
Component: "zoe-postgres"
Cpu: "100m"
Memory: "512Mi"
ServicePort: 5432
ContainerPort: 5432
User: "postgres"
Password: "postgres"
Database: "postgres"
Configuration:
Swarm: "<Swarm-IP-Address"
DeploymentName: "prod"
OverlayNetwork: "<Overlay-network-name>"
AuthenticationType: "text"
ProxyType: "apache"
ProxyContainerName: "apache2"
ProxyConfigFile: "/etc/apache2/sites-available/all.conf"
ProxyPath: "127.0.0.1"
ProxyDockerSock: "/var/run/docker.sock"
zoe ansible_ssh_host='127.0.0.1' ansible_ssh_port=22 ansible_ssh_user='zoe' ansible_ssh_private_key_file='~/.ssh/id_rsa'
---
#Deploy a minimal Zoe on a fresh Linux machine
- hosts: zoe
become: True
roles:
- role: docker
- hosts: zoe
become: True
roles:
- role: swarm
- hosts: zoe
become: True
roles:
- role: zoe
---
# Install docker-engine
- name: Install apt-transport-https
apt:
name: apt-transport-https
update_cache: yes
- name: Install ca-certificates
apt:
name: ca-certificates
update_cache: yes
- name: Add repository key
apt_key:
keyserver: hkp://p80.pool.sks-keyservers.net:80
id: 58118E89F3A912897C070ADBF76221572C52609D
state: present
- name: Register apt sources
shell: echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
- name: Update repository
apt:
update_cache: yes
- name: Install docker-engine
apt:
name: docker-engine
update_cache: yes
- name: Query linux kernel architecture
shell: echo "$(uname -s)-$(uname -p)"
register: kernel_arch
- name: Download docker-compose
command: "{{ item }}"
with_items:
- "curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-{{ kernel_arch.stdout }} -o /usr/local/bin/docker-compose"
- "chmod +x /usr/local/bin/docker-compose"
---
# Setting up Docker Swarm
- name: Get default NIC
shell: echo `ip -o -4 route show to default | awk '{print $5}'`
register: default_nic
- name: Get host IP
shell: echo `ifconfig {{ default_nic.stdout }} 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`
register: host_ip
- name: Remove docker.pid
file:
state: absent
path: "/var/run/docker*"
- name: Stop docker service
service:
name: docker
state: stopped
- name: Start dockerd with new options
shell: nohup dockerd --cluster-store=consul://{{ host_ip.stdout }}:8500 --cluster-advertise={{ default_nic.stdout }}:2375 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
- name: Start consul container
shell: docker run -itd -p 8500:8500 progrium/consul -server -bootstrap
- name: Start swarm manager container
shell: docker run -itd -p 4000:4000 swarm manage -H :4000 --advertise {{ host_ip.stdout }}:4000 consul://{{ host_ip.stdout }}:8500
- name: Start swarm worker container
shell: docker run -itd swarm join --addr={{ host_ip.stdout }}:2375 consul://{{ host_ip.stdout }}:8500
version: '2'
services:
postgres:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
zoe-api:
image: zoerepo/zoe:devel
command: python3 zoe-api.py --debug --swarm --deployment-name compose --master-url tcp://zoe-master:4850 --dbuser postgres --dbhost postgres --dbname postgres --dbpass postgres --overlay-network-name my-net
ports:
- "8080:5001"
depends_on:
- postgres
zoe-master:
image: zoerepo/zoe:devel
ports:
- "4850:4850"
volumes:
- /etc/zoe:/etc/zoe
- /opt/zoe-workspaces:/mnt/zoe-workspaces
command: python3 zoe-master.py --debug --swarm --deployment-name compose --dbuser postgres --dbhost postgres --dbname postgres --dbpass postgres --overlay-network-name my-net
depends_on:
- zoe-api
---
# Deploy Zoe
- name: Get default NIC
shell: echo `ip -o -4 route show to default | awk '{print $5}'`
register: default_nic
- name: Get host IP
shell: echo `ifconfig {{ default_nic.stdout }} 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`
register: host_ip
- name: Create Swarm overlay network
shell: docker -H :4000 network create --driver overlay my-net
- name: Get Swarm URL
shell: echo ' {{ host_ip.stdout }}:4000 '
register: swarm_url
- name: Place swarm_url to docker-compose.yml
replace:
dest: '{{role_path}}/files/docker-compose.yml'
regexp: '--swarm '
replace: '--swarm {{swarm_url.stdout }}'
- name: Get Zoe up
shell: docker-compose -f {{role_path}}/files/docker-compose.yml up -d
#!/bin/bash
#Zoe deploy script for ubuntu 16.04
echo "Installing docker engine..."
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install -y docker-engine
echo "Installing docker-compose..."
sudo chown -R $(whoami) /usr/local/bin
curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo "Setting up docker swarm..."
echo "Exporting default NIC..."
export DEFAULT_NIC=$(echo `ip -o -4 route show to default | awk '{print $5}'`)
echo "Exporting Ip address variable..."
export HOST_IP=$(echo `ifconfig $DEFAULT_NIC 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`)
echo "Appending new entry in hosts file..."
echo $HOST_IP zoe | sudo tee --append /etc/hosts > /dev/null
echo "Removing docker.pid/socks..."
sudo rm /var/run/docker.*
sudo rm -r /var/run/docker
echo "Restarting dockerd daemon with new arguments..."
sudo dockerd --cluster-store=consul://zoe:8500 --cluster-advertise=$DEFAULT_NIC:2375 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
sleep 5
echo "Starting consul..."
sudo docker run -itd -p 8500:8500 progrium/consul -server -bootstrap
sleep 5
echo "Starting swarm manager..."
sudo docker run -itd -p 4000:4000 swarm manage -H :4000 --advertise $HOST_IP:4000 consul://$HOST_IP:8500
sleep 5
echo "Starting swarm worker..."
sudo docker run -itd swarm join --addr=$HOST_IP:2375 consul://$HOST_IP:8500
echo "Installing zoe..."
sleep 5
echo "Creating overlay network..."
sudo docker -H :4000 network create --driver overlay my-net
echo "Starting zoe docker-compose..."
export SWARM_URL=$HOST_IP:4000
echo $SWARM_URL
sed -i -e 's/${SWARM_URL}/'$SWARM_URL'/g' docker-compose.yml
sudo docker-compose up -d
version: '2'
services:
postgres:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
gateway-socks:
image: zoerepo/gateway-socks
networks:
- zoe
zoe-api:
image: zoerepo/zoe:devel
command: python3 zoe-api.py --debug --swarm ${SWARM_URL} --deployment-name compose --master-url tcp://zoe-master:4850 --dbuser postgres --dbhost postgres --dbname postgres --dbpass postgres --overlay-network-name my-net
ports:
- "8080:5001"
depends_on:
- postgres
zoe-master:
image: zoerepo/zoe:devel
ports:
- "4850:4850"
volumes:
- /etc/zoe:/etc/zoe
- /opt/zoe-workspaces:/mnt/zoe-workspaces
command: python3 zoe-master.py --debug --swarm ${SWARM_URL} --deployment-name compose --dbuser postgres --dbhost postgres --dbname postgres --dbpass postgres --overlay-network-name my-net
depends_on:
- zoe-api
networks:
zoe:
driver: bridge
#!/bin/bash
#Zoe deploy script for Windows
#Require to have Docker Toolbox
echo "SCP new profile for boot2docker"
docker-machine scp profile default:/home/docker/profile
docker-machine ssh default "sudo cp /home/docker/profile /var/lib/boot2docker/"
echo "Restart docker daemon with new profile"
docker-machine ssh default "sudo /etc/init.d/docker restart"
echo "Create and start consul container"
docker-machine ssh default "docker run -itd -p 8500:8500 progrium/consul -server -bootstrap"
echo "Create and start swarm manager container"
docker-machine ssh default "docker run -itd -p 4000:4000 swarm manage -H :4000 --advertise 192.168.99.100:4000 consul://192.168.99.100:8500"
echo "Create and start swarm worker container"
docker-machine ssh default "docker run -itd swarm join --addr=192.168.99.100:2376 consul://192.168.99.100:8500"
echo "Create overlay network for Swarm"
docker-machine ssh default "docker -H :4000 network create --driver overlay my-net"
echo "SCP docker-compose.yml for zoe"
docker-machine scp docker-compose.yml default:/home/docker
echo "Download docker-compose and deploy zoe"
docker-machine ssh default "curl -L https://github.com/docker/compose/releases/download/1.10.1/docker-compose-Linux-x86_64 > docker-compose; chmod +x docker-compose; ./docker-compose up -d"
version: '2'
services:
postgres:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
zoe-api:
restart: always
image: zoerepo/zoe:devel
command: python3 zoe-api.py --debug --swarm 192.168.99.100:4000 --deployment-name compose --master-url tcp://zoe-master:4850 --dbuser postgres --dbhost postgres --dbname postgres --dbpass postgres --overlay-network-name my-net
ports:
- "8080:5001"
depends_on:
- postgres
zoe-master