mirror of
https://github.com/yldio/copilot.git
synced 2024-12-01 07:30:07 +02:00
build: extended support for containerpilot v3
with sensors and local-compose
This commit is contained in:
parent
ffb66639d7
commit
6cd39b2d8c
@ -6,17 +6,18 @@
|
|||||||
# turn this into an HA Consul raft.
|
# turn this into an HA Consul raft.
|
||||||
#############################################################################
|
#############################################################################
|
||||||
consul:
|
consul:
|
||||||
image: autopilotpattern/consul:latest
|
image: autopilotpattern/consul:0.7.2-r0.8
|
||||||
command: >
|
command: >
|
||||||
/usr/local/bin/containerpilot
|
/usr/local/bin/containerpilot
|
||||||
/bin/consul agent -server
|
/bin/consul agent -server
|
||||||
-bootstrap-expect 1
|
-config-dir=/etc/consul
|
||||||
-config-dir=/etc/consul
|
-log-level=err
|
||||||
-ui-dir /ui
|
-bootstrap-expect 1
|
||||||
|
-ui-dir /ui
|
||||||
restart: always
|
restart: always
|
||||||
mem_limit: 128m
|
mem_limit: 128m
|
||||||
ports:
|
ports:
|
||||||
- 8500
|
- 8500:8500
|
||||||
dns:
|
dns:
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
|
|
||||||
@ -27,47 +28,62 @@ consul:
|
|||||||
# it is included here for demo purposes and is not required
|
# it is included here for demo purposes and is not required
|
||||||
#############################################################################
|
#############################################################################
|
||||||
prometheus:
|
prometheus:
|
||||||
image: autopilotpattern/prometheus:latest
|
image: autopilotpattern/prometheus:1.7.1-r20
|
||||||
restart: always
|
restart: always
|
||||||
mem_limit: 1g
|
mem_limit: 1g
|
||||||
ports:
|
ports:
|
||||||
- 9090
|
- 9090:9090
|
||||||
links:
|
links:
|
||||||
- consul:consul
|
- consul:consul
|
||||||
environment:
|
environment:
|
||||||
- CONSUL=consul
|
- CONSUL=consul
|
||||||
- CONSUL_AGENT=1
|
- CONSUL_AGENT=1
|
||||||
|
dns:
|
||||||
|
- 127.0.0.1
|
||||||
|
|
||||||
|
traefik:
|
||||||
|
image: d0cker/traefik
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "8080:8080"
|
||||||
|
links:
|
||||||
|
- consul:consul
|
||||||
|
environment:
|
||||||
|
- CONSUL=consul
|
||||||
|
restart: always
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# FRONTEND
|
# FRONTEND
|
||||||
#############################################################################
|
#############################################################################
|
||||||
frontend:
|
frontend:
|
||||||
build: packages/cp-frontend
|
build: ./
|
||||||
|
dockerfile: packages/cp-frontend/Dockerfile
|
||||||
mem_limit: 512m
|
mem_limit: 512m
|
||||||
links:
|
links:
|
||||||
- consul:consul
|
- consul:consul
|
||||||
environment:
|
environment:
|
||||||
- CONSUL=consul
|
- CONSUL=consul
|
||||||
- CONSUL_AGENT=1
|
|
||||||
- PORT=5000
|
- PORT=5000
|
||||||
ports:
|
- REACT_APP_GQL_HOSTNAME=localhost
|
||||||
|
- REACT_APP_GQL_PORT=80
|
||||||
|
expose:
|
||||||
- 5000
|
- 5000
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# BACKEND
|
# BACKEND
|
||||||
#############################################################################
|
#############################################################################
|
||||||
api:
|
api:
|
||||||
build: packages/portal-api
|
build: ./
|
||||||
|
dockerfile: packages/portal-api/Dockerfile
|
||||||
mem_limit: 512m
|
mem_limit: 512m
|
||||||
links:
|
links:
|
||||||
- consul:consul
|
- consul:consul
|
||||||
- rethinkdb:rethinkdb
|
- rethinkdb:rethinkdb
|
||||||
environment:
|
environment:
|
||||||
- CONSUL=consul
|
- CONSUL=consul
|
||||||
- CONSUL_AGENT=1
|
|
||||||
- PORT=3000
|
- PORT=3000
|
||||||
- RETHINK_HOST=rethinkdb
|
- RETHINK_HOST=rethinkdb
|
||||||
ports:
|
expose:
|
||||||
- 3000
|
- 3000
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
||||||
|
|
||||||
|
ENV CONTAINERPILOT /etc/containerpilot.json5
|
||||||
|
|
||||||
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
||||||
&& ./node_modules/.bin/lerna clean --yes --scope joyent-cp-frontend --include-filtered-dependencies \
|
&& ./node_modules/.bin/lerna clean --yes --scope joyent-cp-frontend --include-filtered-dependencies \
|
||||||
&& ./node_modules/.bin/lerna bootstrap --scope joyent-cp-frontend --include-filtered-dependencies
|
&& ./node_modules/.bin/lerna bootstrap --scope joyent-cp-frontend --include-filtered-dependencies
|
||||||
|
|
||||||
WORKDIR /opt/app/packages/cp-frontend
|
WORKDIR /opt/app/packages/cp-frontend
|
||||||
COPY packages/cp-frontend/etc/containerpilot.json /etc/
|
COPY packages/cp-frontend/etc/containerpilot.json5 ${CONTAINERPILOT}
|
||||||
|
|
||||||
|
RUN yarn run build
|
||||||
|
|
||||||
ARG CIRCLE_BRANCH
|
ARG CIRCLE_BRANCH
|
||||||
ENV REACT_APP_GQL_HOSTNAME gql-mock-server-$CIRCLE_BRANCH.svc.f4b20699-b323-4452-9091-977895896da6.eu-ams-1.triton.zone
|
ENV REACT_APP_GQL_HOSTNAME gql-mock-server-$CIRCLE_BRANCH.svc.f4b20699-b323-4452-9091-977895896da6.eu-ams-1.triton.zone
|
||||||
|
|
||||||
RUN yarn run build
|
|
||||||
|
|
||||||
EXPOSE 3069
|
EXPOSE 3069
|
||||||
CMD ["/bin/containerpilot"]
|
CMD ["/bin/containerpilot"]
|
||||||
|
44
packages/cp-frontend/bin/sensors.sh
Executable file
44
packages/cp-frontend/bin/sensors.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
help() {
|
||||||
|
echo 'Uses cli tools free and top to determine current CPU and memory usage'
|
||||||
|
echo 'for the telemetry service.'
|
||||||
|
}
|
||||||
|
|
||||||
|
# memory usage in percent
|
||||||
|
memory() {
|
||||||
|
# awk oneliner to get memory usage
|
||||||
|
# free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
|
||||||
|
# output:
|
||||||
|
# Memory Usage: 15804/15959MB (99.03%)
|
||||||
|
local memory=$(free -m | awk 'NR==2{printf "%.2f", $3*100/$2 }')
|
||||||
|
/bin/containerpilot -putmetric "frontend_memory_percent=$memory"
|
||||||
|
}
|
||||||
|
|
||||||
|
# cpu load
|
||||||
|
cpu() {
|
||||||
|
# oneliner to display cpu load
|
||||||
|
# top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}'
|
||||||
|
local cpuload=$(uptime | awk '{printf "%.2f", $6}')
|
||||||
|
/bin/containerpilot -putmetric "frontend_cpu_load=$cpuload"
|
||||||
|
}
|
||||||
|
|
||||||
|
diskusage() {
|
||||||
|
local usage=$(df -P | grep '/$' | awk 'NR=2{print $3}' | sed 's/[^0-9\.]*//g')
|
||||||
|
/bin/containerpilot -putmetric "frontend_disk_usage=$usage"
|
||||||
|
}
|
||||||
|
|
||||||
|
diskcapacity() {
|
||||||
|
local capacity=$(df -P | grep '/$' | awk 'NR=2{print $2}' | sed 's/[^0-9\.]*//g')
|
||||||
|
/bin/containerpilot -putmetric "frontend_disk_capacity=$capacity"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd=$1
|
||||||
|
if [ ! -z "$cmd" ]; then
|
||||||
|
shift 1
|
||||||
|
$cmd "$@"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
help
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"consul": "0.0.0.0:8500",
|
|
||||||
"jobs": [
|
|
||||||
{
|
|
||||||
"name": "cp-frontend",
|
|
||||||
"port": 3069,
|
|
||||||
"exec": "../../node_modules/.bin/serve --single build --port 3069",
|
|
||||||
"health": {
|
|
||||||
"exec": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:3069/",
|
|
||||||
"interval": 3,
|
|
||||||
"ttl": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
102
packages/cp-frontend/etc/containerpilot.json5
Normal file
102
packages/cp-frontend/etc/containerpilot.json5
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
consul: 'localhost:8500',
|
||||||
|
jobs: [
|
||||||
|
{
|
||||||
|
name: 'cp-frontend',
|
||||||
|
port: {{.PORT}},
|
||||||
|
exec: '../../node_modules/.bin/serve --single build --port {{.PORT}}',
|
||||||
|
health: {
|
||||||
|
exec: '/usr/bin/curl -o /dev/null --fail -s http://localhost:{{.PORT}}',
|
||||||
|
interval: 2,
|
||||||
|
ttl: 5
|
||||||
|
},
|
||||||
|
tags: [
|
||||||
|
'traefik.backend=cp-frontend',
|
||||||
|
'traefik.frontend.rule=PathPrefix:/',
|
||||||
|
'traefik.frontend.entryPoints=http'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'consul-agent',
|
||||||
|
exec: ['/usr/local/bin/consul', 'agent',
|
||||||
|
'-data-dir=/data',
|
||||||
|
'-config-dir=/config',
|
||||||
|
'-log-level=err',
|
||||||
|
'-rejoin',
|
||||||
|
'-retry-join', '{{ .CONSUL | default "consul" }}',
|
||||||
|
'-retry-max', '10',
|
||||||
|
'-retry-interval', '10s'],
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_memory_usage',
|
||||||
|
exec: '/bin/sensors.sh memory',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_cpu_load',
|
||||||
|
exec: '/bin/sensors.sh cpu',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_capacity',
|
||||||
|
exec: '/bin/sensors.sh diskcapacity',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_usage',
|
||||||
|
exec: '/bin/sensors.sh diskusage',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
telemetry: {
|
||||||
|
port: 9090,
|
||||||
|
tags: ['op'],
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
namespace: 'cp_frontend',
|
||||||
|
subsystem: 'memory',
|
||||||
|
name: 'percent',
|
||||||
|
help: 'Percentage of memory used',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_frontend',
|
||||||
|
subsystem: 'cpu',
|
||||||
|
name: 'load',
|
||||||
|
help: 'CPU load',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_frontend',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'capacity',
|
||||||
|
help: 'Disk capacity',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_frontend',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'usage',
|
||||||
|
help: 'Disk usage',
|
||||||
|
type: 'gauge'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ const GLOBAL = typeof window === 'object'
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const GQL_PORT = process.env.REACT_APP_GQL_PORT || 3000;
|
||||||
const GQL_HOSTNAME =
|
const GQL_HOSTNAME =
|
||||||
process.env.REACT_APP_GQL_HOSTNAME || GLOBAL.location.hostname;
|
process.env.REACT_APP_GQL_HOSTNAME || GLOBAL.location.hostname;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ export const client = new ApolloClient({
|
|||||||
return `${o.__typename}:${id}`;
|
return `${o.__typename}:${id}`;
|
||||||
},
|
},
|
||||||
networkInterface: createNetworkInterface({
|
networkInterface: createNetworkInterface({
|
||||||
uri: `http://${GQL_HOSTNAME}:3000/graphql`
|
uri: `http://${GQL_HOSTNAME}:${GQL_PORT}/graphql`
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
||||||
|
|
||||||
|
ENV CONTAINERPILOT /etc/containerpilot.json5
|
||||||
|
|
||||||
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
||||||
&& ./node_modules/.bin/lerna clean --yes --scope joyent-cp-gql-mock-server --include-filtered-dependencies \
|
&& ./node_modules/.bin/lerna clean --yes --scope joyent-cp-gql-mock-server --include-filtered-dependencies \
|
||||||
&& ./node_modules/.bin/lerna bootstrap --scope joyent-cp-gql-mock-server --include-filtered-dependencies
|
&& ./node_modules/.bin/lerna bootstrap --scope joyent-cp-gql-mock-server --include-filtered-dependencies
|
||||||
|
|
||||||
WORKDIR /opt/app/packages/cp-gql-mock-server
|
WORKDIR /opt/app/packages/cp-gql-mock-server
|
||||||
COPY packages/cp-gql-mock-server/etc/containerpilot.json /etc/
|
|
||||||
|
COPY packages/cp-gql-mock-server/etc/containerpilot.json5 ${CONTAINERPILOT}
|
||||||
|
COPY packages/cp-gql-mock-server/bin /bin
|
||||||
|
|
||||||
ARG CIRCLE_BRANCH
|
ARG CIRCLE_BRANCH
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"consul": "0.0.0.0:8500",
|
|
||||||
"jobs": [
|
|
||||||
{
|
|
||||||
"name": "cp-gql-mock-server",
|
|
||||||
"port": 3000,
|
|
||||||
"exec": "yarn run start",
|
|
||||||
"health": {
|
|
||||||
"exec": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:3000/",
|
|
||||||
"interval": 3,
|
|
||||||
"ttl": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
102
packages/cp-gql-mock-server/etc/containerpilot.json5
Normal file
102
packages/cp-gql-mock-server/etc/containerpilot.json5
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
consul: 'localhost:8500',
|
||||||
|
jobs: [
|
||||||
|
{
|
||||||
|
name: 'cp-gql-mock-server',
|
||||||
|
port: {{.PORT}},
|
||||||
|
exec: 'node .',
|
||||||
|
health: {
|
||||||
|
exec: '/usr/bin/curl -o /dev/null --fail -s http://localhost:{{.PORT}}/graphiql',
|
||||||
|
interval: 2,
|
||||||
|
ttl: 5
|
||||||
|
},
|
||||||
|
tags: [
|
||||||
|
'traefik.backend=cp-gql-mock-server',
|
||||||
|
'traefik.frontend.rule=PathPrefix:/',
|
||||||
|
'traefik.frontend.entryPoints=http'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'consul-agent',
|
||||||
|
exec: ['/usr/local/bin/consul', 'agent',
|
||||||
|
'-data-dir=/data',
|
||||||
|
'-config-dir=/config',
|
||||||
|
'-log-level=err',
|
||||||
|
'-rejoin',
|
||||||
|
'-retry-join', '{{ .CONSUL | default "consul" }}',
|
||||||
|
'-retry-max', '10',
|
||||||
|
'-retry-interval', '10s'],
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_memory_usage',
|
||||||
|
exec: '/bin/sensors.sh memory',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_cpu_load',
|
||||||
|
exec: '/bin/sensors.sh cpu',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_capacity',
|
||||||
|
exec: '/bin/sensors.sh diskcapacity',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_usage',
|
||||||
|
exec: '/bin/sensors.sh diskusage',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
telemetry: {
|
||||||
|
port: 9090,
|
||||||
|
tags: ['op'],
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
namespace: 'cp_gql_mock_server',
|
||||||
|
subsystem: 'memory',
|
||||||
|
name: 'percent',
|
||||||
|
help: 'Percentage of memory used',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_gql_mock_server',
|
||||||
|
subsystem: 'cpu',
|
||||||
|
name: 'load',
|
||||||
|
help: 'CPU load',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_gql_mock_server',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'capacity',
|
||||||
|
help: 'Disk capacity',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'cp_gql_mock_server',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'usage',
|
||||||
|
help: 'Disk usage',
|
||||||
|
type: 'gauge'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,20 @@
|
|||||||
# todo change to 7
|
|
||||||
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
||||||
|
|
||||||
|
ENV CONTAINERPILOT /etc/containerpilot.json5
|
||||||
|
|
||||||
|
RUN set -x \
|
||||||
|
&& apk update \
|
||||||
|
&& apk add curl bash build-base python zeromq-dev \
|
||||||
|
&& rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
RUN yarn add lerna@^2.0.0-rc.5 \
|
RUN yarn add lerna@^2.0.0-rc.5 \
|
||||||
&& ./node_modules/.bin/lerna clean --yes --scope portal-api --include-filtered-dependencies \
|
&& ./node_modules/.bin/lerna clean --yes --scope portal-api --include-filtered-dependencies \
|
||||||
&& ./node_modules/.bin/lerna bootstrap --scope portal-api --include-filtered-dependencies
|
&& ./node_modules/.bin/lerna bootstrap --scope portal-api --include-filtered-dependencies
|
||||||
|
|
||||||
WORKDIR /home/node/app/packages/portal-api
|
WORKDIR /opt/app/packages/portal-api
|
||||||
COPY packages/portal-api/etc/containerpilot.json /etc/
|
|
||||||
|
COPY packages/portal-api/etc/containerpilot.json5 ${CONTAINERPILOT}
|
||||||
|
|
||||||
ARG CIRCLE_BRANCH
|
ARG CIRCLE_BRANCH
|
||||||
|
|
||||||
EXPOSE 3000
|
CMD ["/bin/containerpilot"]
|
||||||
CMD ["/bin/containerpilot", "yarn", "start"]
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"consul": "0.0.0.0:8500",
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "cp-gql-mock-server",
|
|
||||||
"port": 3000,
|
|
||||||
"health": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:3000/",
|
|
||||||
"poll": 3,
|
|
||||||
"ttl": 10
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backends": [],
|
|
||||||
"telemetry": {
|
|
||||||
"port": 9090,
|
|
||||||
"sensors": [
|
|
||||||
{
|
|
||||||
"name": "frontend_memory_percent",
|
|
||||||
"help": "percentage of memory used",
|
|
||||||
"type": "gauge",
|
|
||||||
"poll": 5,
|
|
||||||
"check": ["/bin/sensors", "memory"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "frontend_cpu_load",
|
|
||||||
"help": "cpu load",
|
|
||||||
"type": "gauge",
|
|
||||||
"poll": 5,
|
|
||||||
"check": ["/bin/sensors", "cpu"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "frontend_disk_capacity",
|
|
||||||
"help": "disk capacity",
|
|
||||||
"type": "gauge",
|
|
||||||
"poll": 60,
|
|
||||||
"check": ["/bin/sensors", "diskcapacity"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "frontend_disk_usage",
|
|
||||||
"help": "disk usage",
|
|
||||||
"type": "gauge",
|
|
||||||
"poll": 60,
|
|
||||||
"check": ["/bin/sensors", "diskusage"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
102
packages/portal-api/etc/containerpilot.json5
Normal file
102
packages/portal-api/etc/containerpilot.json5
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
consul: 'localhost:8500',
|
||||||
|
jobs: [
|
||||||
|
{
|
||||||
|
name: 'api',
|
||||||
|
port: {{.PORT}},
|
||||||
|
exec: 'node server.js',
|
||||||
|
health: {
|
||||||
|
exec: '/usr/bin/curl -o /dev/null --fail -s http://localhost:{{.PORT}}/check-it-out',
|
||||||
|
interval: 2,
|
||||||
|
ttl: 5
|
||||||
|
},
|
||||||
|
tags: [
|
||||||
|
'traefik.backend=api',
|
||||||
|
'traefik.frontend.rule=PathPrefix:/graphql,/graphiql',
|
||||||
|
'traefik.frontend.entryPoints=http'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'consul-agent',
|
||||||
|
exec: ['/usr/local/bin/consul', 'agent',
|
||||||
|
'-data-dir=/data',
|
||||||
|
'-config-dir=/config',
|
||||||
|
'-log-level=err',
|
||||||
|
'-rejoin',
|
||||||
|
'-retry-join', '{{ .CONSUL | default "consul" }}',
|
||||||
|
'-retry-max', '10',
|
||||||
|
'-retry-interval', '10s'],
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_memory_usage',
|
||||||
|
exec: '/bin/sensors.sh memory',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_cpu_load',
|
||||||
|
exec: '/bin/sensors.sh cpu',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_capacity',
|
||||||
|
exec: '/bin/sensors.sh diskcapacity',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_usage',
|
||||||
|
exec: '/bin/sensors.sh diskusage',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
telemetry: {
|
||||||
|
port: 9090,
|
||||||
|
tags: ['op'],
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
namespace: 'api',
|
||||||
|
subsystem: 'memory',
|
||||||
|
name: 'percent',
|
||||||
|
help: 'Percentage of memory used',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'api',
|
||||||
|
subsystem: 'cpu',
|
||||||
|
name: 'load',
|
||||||
|
help: 'CPU load',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'api',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'capacity',
|
||||||
|
help: 'Disk capacity',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'api',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'usage',
|
||||||
|
help: 'Disk usage',
|
||||||
|
type: 'gauge'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"boom": "^5.1.0",
|
"boom": "^5.1.0",
|
||||||
|
"brule": "^2.0.0",
|
||||||
"graphi": "^2.2.1",
|
"graphi": "^2.2.1",
|
||||||
"hoek": "^4.1.1",
|
"hoek": "^4.1.1",
|
||||||
"joi": "^10.6.0",
|
"joi": "^10.6.0",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const Brule = require('brule');
|
||||||
const Hapi = require('hapi');
|
const Hapi = require('hapi');
|
||||||
const Inert = require('inert');
|
const Inert = require('inert');
|
||||||
const Vision = require('vision');
|
const Vision = require('vision');
|
||||||
@ -31,6 +32,7 @@ const portalOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
server.register([
|
server.register([
|
||||||
|
Brule,
|
||||||
Inert,
|
Inert,
|
||||||
Vision,
|
Vision,
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
FROM quay.io/yldio/alpine-node-containerpilot:latest
|
||||||
|
|
||||||
|
ENV CONTAINERPILOT /etc/containerpilot.json5
|
||||||
|
|
||||||
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
RUN yarn add lerna@^2.0.0-rc.5 serve \
|
||||||
&& ./node_modules/.bin/lerna clean --yes --scope joyent-ui-toolkit --include-filtered-dependencies \
|
&& ./node_modules/.bin/lerna clean --yes --scope joyent-ui-toolkit --include-filtered-dependencies \
|
||||||
&& ./node_modules/.bin/lerna bootstrap --scope joyent-ui-toolkit --include-filtered-dependencies
|
&& ./node_modules/.bin/lerna bootstrap --scope joyent-ui-toolkit --include-filtered-dependencies
|
||||||
|
|
||||||
WORKDIR /opt/app/packages/ui-toolkit
|
WORKDIR /opt/app/packages/ui-toolkit
|
||||||
|
COPY packages/ui-toolkit/etc/containerpilot.json5 ${CONTAINERPILOT}
|
||||||
|
|
||||||
|
RUN yarn run styleguide:build
|
||||||
|
|
||||||
ARG CIRCLE_BRANCH
|
ARG CIRCLE_BRANCH
|
||||||
|
|
||||||
RUN yarn run styleguide:build
|
|
||||||
COPY packages/ui-toolkit/etc/containerpilot.json /etc/
|
|
||||||
|
|
||||||
EXPOSE 6060
|
EXPOSE 6060
|
||||||
CMD ["/bin/containerpilot"]
|
CMD ["/bin/containerpilot"]
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"consul": "0.0.0.0:8500",
|
|
||||||
"jobs": [
|
|
||||||
{
|
|
||||||
"name": "ui-toolkit",
|
|
||||||
"port": 6060,
|
|
||||||
"exec": "../../node_modules/.bin/serve --single styleguide --port 6060",
|
|
||||||
"health": {
|
|
||||||
"exec": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:6060/",
|
|
||||||
"interval": 3,
|
|
||||||
"ttl": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
102
packages/ui-toolkit/etc/containerpilot.json5
Normal file
102
packages/ui-toolkit/etc/containerpilot.json5
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
consul: 'localhost:8500',
|
||||||
|
jobs: [
|
||||||
|
{
|
||||||
|
name: 'ui-toolkit',
|
||||||
|
port: {{.PORT}},
|
||||||
|
exec: '../../node_modules/.bin/serve --single styleguide --port {{.PORT}}',
|
||||||
|
health: {
|
||||||
|
exec: '/usr/bin/curl -o /dev/null --fail -s http://localhost:{{.PORT}}',
|
||||||
|
interval: 2,
|
||||||
|
ttl: 5
|
||||||
|
},
|
||||||
|
tags: [
|
||||||
|
'traefik.backend=ui-toolkit',
|
||||||
|
'traefik.frontend.rule=PathPrefix:/',
|
||||||
|
'traefik.frontend.entryPoints=http'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'consul-agent',
|
||||||
|
exec: ['/usr/local/bin/consul', 'agent',
|
||||||
|
'-data-dir=/data',
|
||||||
|
'-config-dir=/config',
|
||||||
|
'-log-level=err',
|
||||||
|
'-rejoin',
|
||||||
|
'-retry-join', '{{ .CONSUL | default "consul" }}',
|
||||||
|
'-retry-max', '10',
|
||||||
|
'-retry-interval', '10s'],
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_memory_usage',
|
||||||
|
exec: '/bin/sensors.sh memory',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_cpu_load',
|
||||||
|
exec: '/bin/sensors.sh cpu',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '5s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_capacity',
|
||||||
|
exec: '/bin/sensors.sh diskcapacity',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sensor_disk_usage',
|
||||||
|
exec: '/bin/sensors.sh diskusage',
|
||||||
|
timeout: '5s',
|
||||||
|
when: {
|
||||||
|
interval: '60s'
|
||||||
|
},
|
||||||
|
restarts: 'unlimited'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
telemetry: {
|
||||||
|
port: 9090,
|
||||||
|
tags: ['op'],
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
namespace: 'ui_toolkit',
|
||||||
|
subsystem: 'memory',
|
||||||
|
name: 'percent',
|
||||||
|
help: 'Percentage of memory used',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'ui_toolkit',
|
||||||
|
subsystem: 'cpu',
|
||||||
|
name: 'load',
|
||||||
|
help: 'CPU load',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'ui_toolkit',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'capacity',
|
||||||
|
help: 'Disk capacity',
|
||||||
|
type: 'gauge'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: 'ui_toolkit',
|
||||||
|
subsystem: 'disk',
|
||||||
|
name: 'usage',
|
||||||
|
help: 'Disk usage',
|
||||||
|
type: 'gauge'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
32
yarn.lock
32
yarn.lock
@ -3708,11 +3708,11 @@ extsprintf@1.0.2:
|
|||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
|
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
|
||||||
|
|
||||||
extsprintf@1.2.0, extsprintf@^1.2.0:
|
extsprintf@1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.2.0.tgz#5ad946c22f5b32ba7f8cd7426711c6e8a3fc2529"
|
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.2.0.tgz#5ad946c22f5b32ba7f8cd7426711c6e8a3fc2529"
|
||||||
|
|
||||||
extsprintf@1.3.0:
|
extsprintf@1.3.0, extsprintf@^1.2.0:
|
||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
|
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
|
||||||
|
|
||||||
@ -4591,7 +4591,7 @@ inflight@^1.0.4:
|
|||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
wrappy "1"
|
wrappy "1"
|
||||||
|
|
||||||
inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1:
|
inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3:
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||||
|
|
||||||
@ -6021,10 +6021,10 @@ merge-descriptors@1.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
||||||
|
|
||||||
merge-source-map@^1.0.2:
|
merge-source-map@^1.0.2:
|
||||||
version "1.0.3"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.0.3.tgz#da1415f2722a5119db07b14c4f973410863a2abf"
|
resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.0.4.tgz#a5de46538dae84d4114cc5ea02b4772a6346701f"
|
||||||
dependencies:
|
dependencies:
|
||||||
source-map "^0.5.3"
|
source-map "^0.5.6"
|
||||||
|
|
||||||
methods@~1.1.2:
|
methods@~1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
@ -7330,8 +7330,8 @@ react-router@^4.1.1:
|
|||||||
warning "^3.0.0"
|
warning "^3.0.0"
|
||||||
|
|
||||||
react-styled-flexboxgrid@^2.0.1:
|
react-styled-flexboxgrid@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/react-styled-flexboxgrid/-/react-styled-flexboxgrid-2.0.1.tgz#be5e188c6c1db8ae619806ecf18a2901541c0ee7"
|
resolved "https://registry.yarnpkg.com/react-styled-flexboxgrid/-/react-styled-flexboxgrid-2.0.2.tgz#c1991bd6b249ee4b7cf0abbc35869a0d28e65620"
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash.isinteger "^4.0.4"
|
lodash.isinteger "^4.0.4"
|
||||||
|
|
||||||
@ -7435,14 +7435,14 @@ read@1.0.7:
|
|||||||
mute-stream "~0.0.4"
|
mute-stream "~0.0.4"
|
||||||
|
|
||||||
"readable-stream@>= 1.0.2", readable-stream@^2, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
|
"readable-stream@>= 1.0.2", readable-stream@^2, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
|
||||||
version "2.2.11"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72"
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.0.tgz#640f5dcda88c91a8dc60787145629170813a1ed2"
|
||||||
dependencies:
|
dependencies:
|
||||||
core-util-is "~1.0.0"
|
core-util-is "~1.0.0"
|
||||||
inherits "~2.0.1"
|
inherits "~2.0.3"
|
||||||
isarray "~1.0.0"
|
isarray "~1.0.0"
|
||||||
process-nextick-args "~1.0.6"
|
process-nextick-args "~1.0.6"
|
||||||
safe-buffer "~5.0.1"
|
safe-buffer "~5.1.0"
|
||||||
string_decoder "~1.0.0"
|
string_decoder "~1.0.0"
|
||||||
util-deprecate "~1.0.1"
|
util-deprecate "~1.0.1"
|
||||||
|
|
||||||
@ -8062,7 +8062,7 @@ rx-lite@^3.1.2:
|
|||||||
version "3.1.2"
|
version "3.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102"
|
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102"
|
||||||
|
|
||||||
safe-buffer@^5.0.1, safe-buffer@^5.1.0:
|
safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.1.0:
|
||||||
version "5.1.0"
|
version "5.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223"
|
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223"
|
||||||
|
|
||||||
@ -9615,7 +9615,7 @@ window-size@0.1.0:
|
|||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
|
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
|
||||||
|
|
||||||
wordwrap@0.0.2:
|
wordwrap@0.0.2, wordwrap@~0.0.2:
|
||||||
version "0.0.2"
|
version "0.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
|
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
|
||||||
|
|
||||||
@ -9623,10 +9623,6 @@ wordwrap@1.0.0, wordwrap@~1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
|
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
|
||||||
|
|
||||||
wordwrap@~0.0.2:
|
|
||||||
version "0.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
|
|
||||||
|
|
||||||
wrap-ansi@^2.0.0:
|
wrap-ansi@^2.0.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
|
||||||
|
Loading…
Reference in New Issue
Block a user