Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
| Següent revisió | Revisió prèvia | ||
| info:cursos:pue:devops:sesion3 [15/02/2019 08:27] – creat mate | info:cursos:pue:devops:sesion3 [04/03/2019 06:05] (actual) – [influx+grafana+telegraf] mate | ||
|---|---|---|---|
| Línia 1: | Línia 1: | ||
| - | = Sesión 3 | + | = Sesión 3 : swarm |
| == varios | == varios | ||
| * spreed brain?: | * spreed brain?: | ||
| * 3 nodos develop | * 3 nodos develop | ||
| * 5 nodos producción | * 5 nodos producción | ||
| + | * '' | ||
| + | * docker mysql: importar los fichero SQL de la carpeta **/ | ||
| + | * visto en el Dockerfile (https:// | ||
| + | * directiva **constrains** para deployar en máquinas concretas | ||
| + | * nodo, os | ||
| + | * daryl : plantillas + variables = yaml personalizados (imagino que cualquier otra cosa) | ||
| + | * portainer : App templates | ||
| == swarm | == swarm | ||
| + | === conceptos | ||
| + | * swarm: '' | ||
| + | * node: '' | ||
| + | * stack: '' | ||
| + | * service '' | ||
| + | * tasks '' | ||
| + | |||
| + | === inicialización + gestión nodos | ||
| * '' | * '' | ||
| * para crear un swarm con varios nodos, solo 1 ha de iniciarlo | * para crear un swarm con varios nodos, solo 1 ha de iniciarlo | ||
| * '' | * '' | ||
| * podemos añadirnos como manager o como workers al swarm creado | * podemos añadirnos como manager o como workers al swarm creado | ||
| - | * '' | + | |
| - | * '' | + | * '' |
| - | * '' | + | |
| - | * '' | + | === stacks & servicios |
| + | | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | === logs & inspección | ||
| + | * '' | ||
| + | * si no puedes ver logs del contenedor, mirar en logs de docker: | ||
| + | * / | ||
| + | * / | ||
| + | * o en algún concentrador (ELK) | ||
| + | * inspeccionar en el nodo que se está ejecutando: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | |||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | === portainer | ||
| + | requiere tener una red llamada proxy creada: '' | ||
| + | <code yaml; swarm-portainer.yml> | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | portainer: | ||
| + | image: portainer/ | ||
| + | ports: | ||
| + | - 9000:9000 | ||
| + | networks: | ||
| + | - proxy | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | deploy: | ||
| + | mode: replicated | ||
| + | replicas: 1 | ||
| + | labels: | ||
| + | traefik.port: | ||
| + | traefik.frontend.rule: | ||
| + | traefik.docker.network: | ||
| + | placement: | ||
| + | constraints: | ||
| + | networks: | ||
| + | proxy: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | === wordpress | ||
| + | <code yaml; swarm-wp+mysq.yml> | ||
| + | version: ' | ||
| + | services: | ||
| + | db: | ||
| + | | ||
| + | | ||
| + | - / | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | - " | ||
| + | | ||
| + | - / | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | === influx+grafana+telegraf | ||
| + | <code yaml; stack-triolalala.yml> | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | influxdb: | ||
| + | image: influxdb: | ||
| + | command: | ||
| + | -config / | ||
| + | environment: | ||
| + | INFLUXDB_ADMIN_USER: | ||
| + | INFLUXDB_ADMIN_PASSWORD: | ||
| + | networks: | ||
| + | - agents | ||
| + | - grafana | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | deploy: | ||
| + | replicas: 1 | ||
| + | |||
| + | telegraf: | ||
| + | image: telegraf: | ||
| + | environment: | ||
| + | HOST_PROC: '/ | ||
| + | HOST_SYS: '/ | ||
| + | HOST_ETC: '/ | ||
| + | networks: | ||
| + | - agents | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | deploy: | ||
| + | mode: global | ||
| + | restart_policy: | ||
| + | condition: on-failure | ||
| + | delay: 5s | ||
| + | |||
| + | grafana: | ||
| + | image: grafana/ | ||
| + | environment: | ||
| + | GF_INSTALL_PLUGINS: | ||
| + | volumes: | ||
| + | - / | ||
| + | networks: | ||
| + | - grafana | ||
| + | - proxy | ||
| + | depends_on: | ||
| + | - influxdb | ||
| + | deploy: | ||
| + | replicas: 1 | ||
| + | ports: | ||
| + | - 9002:3000 | ||
| + | |||
| + | networks: | ||
| + | agents: | ||
| + | external: true | ||
| + | grafana: | ||
| + | external: true | ||
| + | proxy: | ||
| + | external: true | ||
| + | </ | ||
| + | <code yaml; stack-kpeiruza.yml> | ||
| + | # Author: Kenneth Peiruza | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | influxdb: | ||
| + | image: library/ | ||
| + | command: -config / | ||
| + | environment: | ||
| + | INFLUXDB_ADMIN_USER: | ||
| + | INFLUXDB_ADMIN_PASSWORD: | ||
| + | networks: | ||
| + | - agents | ||
| + | - grafana | ||
| + | volumes: | ||
| + | - ${REMOTE_MOUNT}/ | ||
| + | - ${REMOTE_MOUNT}/ | ||
| + | deploy: | ||
| + | replicas: 1 | ||
| + | |||
| + | grafana: | ||
| + | image: grafana/ | ||
| + | environment: | ||
| + | GF_INSTALL_PLUGINS: | ||
| + | volumes: | ||
| + | - ${REMOTE_MOUNT}/ | ||
| + | networks: | ||
| + | - grafana | ||
| + | - proxy | ||
| + | depends_on: | ||
| + | - influxdb | ||
| + | deploy: | ||
| + | replicas: 1 | ||
| + | labels: | ||
| + | traefik.port: | ||
| + | traefik.frontend.rule: | ||
| + | traefik.docker.network: | ||
| + | |||
| + | # Fancy replacing placement on a static node. Add Net-storage and drop this out | ||
| + | |||
| + | telegraf: | ||
| + | image: telegraf/ | ||
| + | environment: | ||
| + | HOST_PROC: '/ | ||
| + | HOST_SYS: '/ | ||
| + | HOST_ETC: '/ | ||
| + | networks: | ||
| + | - agents | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | - / | ||
| + | deploy: | ||
| + | mode: global | ||
| + | restart_policy: | ||
| + | condition: on-failure | ||
| + | delay: 5s | ||
| + | |||
| + | networks: | ||
| + | agents: | ||
| + | driver: ' | ||
| + | grafana: | ||
| + | driver: ' | ||
| + | proxy: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | * **telegraf.conf**: | ||
| + | * escupe fichero de config base: '' | ||
| + | * modificado el **inputs.docker**: | ||
| + | * descomentado endopoint, gather_services | ||
| + | * y el **outputs.influxdb** | ||
| + | * descomentado urls, | ||
| + | |||
| + | <code; influxdb.conf> | ||
| + | reporting-disabled = false | ||
| + | bind-address = " | ||
| + | |||
| + | [meta] | ||
| + | dir = "/ | ||
| + | retention-autocreate = true | ||
| + | logging-enabled = true | ||
| + | |||
| + | [data] | ||
| + | dir = "/ | ||
| + | index-version = " | ||
| + | wal-dir = "/ | ||
| + | wal-fsync-delay = " | ||
| + | query-log-enabled = true | ||
| + | cache-max-memory-size = 1073741824 | ||
| + | cache-snapshot-memory-size = 26214400 | ||
| + | cache-snapshot-write-cold-duration = " | ||
| + | compact-full-write-cold-duration = " | ||
| + | max-series-per-database = 1000000 | ||
| + | max-values-per-tag = 100000 | ||
| + | max-concurrent-compactions = 0 | ||
| + | trace-logging-enabled = false | ||
| + | |||
| + | [coordinator] | ||
| + | write-timeout = " | ||
| + | max-concurrent-queries = 0 | ||
| + | query-timeout = " | ||
| + | log-queries-after = " | ||
| + | max-select-point = 0 | ||
| + | max-select-series = 0 | ||
| + | max-select-buckets = 0 | ||
| + | |||
| + | [retention] | ||
| + | enabled = true | ||
| + | check-interval = " | ||
| + | |||
| + | [shard-precreation] | ||
| + | enabled = true | ||
| + | check-interval = " | ||
| + | advance-period = " | ||
| + | |||
| + | [monitor] | ||
| + | store-enabled = true | ||
| + | store-database = " | ||
| + | store-interval = " | ||
| + | |||
| + | [subscriber] | ||
| + | enabled = true | ||
| + | http-timeout = " | ||
| + | insecure-skip-verify = false | ||
| + | ca-certs = "" | ||
| + | write-concurrency = 40 | ||
| + | write-buffer-size = 1000 | ||
| + | |||
| + | [http] | ||
| + | enabled = true | ||
| + | bind-address = ": | ||
| + | auth-enabled = false | ||
| + | log-enabled = true | ||
| + | write-tracing = false | ||
| + | pprof-enabled = true | ||
| + | https-enabled = false | ||
| + | https-certificate = "/ | ||
| + | https-private-key = "" | ||
| + | max-row-limit = 0 | ||
| + | max-connection-limit = 0 | ||
| + | shared-secret = "" | ||
| + | realm = " | ||
| + | unix-socket-enabled = false | ||
| + | bind-socket = "/ | ||
| + | |||
| + | [[graphite]] | ||
| + | enabled = false | ||
| + | bind-address = ": | ||
| + | database = " | ||
| + | retention-policy = "" | ||
| + | protocol = " | ||
| + | batch-size = 5000 | ||
| + | batch-pending = 10 | ||
| + | batch-timeout = " | ||
| + | consistency-level = " | ||
| + | separator = " | ||
| + | udp-read-buffer = 0 | ||
| + | |||
| + | [[collectd]] | ||
| + | enabled = false | ||
| + | bind-address = ": | ||
| + | database = " | ||
| + | retention-policy = "" | ||
| + | batch-size = 5000 | ||
| + | batch-pending = 10 | ||
| + | batch-timeout = " | ||
| + | read-buffer = 0 | ||
| + | typesdb = "/ | ||
| + | security-level = " | ||
| + | auth-file = "/ | ||
| + | |||
| + | [[opentsdb]] | ||
| + | enabled = false | ||
| + | bind-address = ": | ||
| + | database = " | ||
| + | retention-policy = "" | ||
| + | consistency-level = " | ||
| + | tls-enabled = false | ||
| + | certificate = "/ | ||
| + | batch-size = 1000 | ||
| + | batch-pending = 5 | ||
| + | batch-timeout = " | ||
| + | log-point-errors = true | ||
| + | |||
| + | [[udp]] | ||
| + | enabled = false | ||
| + | bind-address = ": | ||
| + | database = " | ||
| + | retention-policy = "" | ||
| + | batch-size = 5000 | ||
| + | batch-pending = 10 | ||
| + | read-buffer = 0 | ||
| + | batch-timeout = " | ||
| + | precision = "" | ||
| + | |||
| + | [continuous_queries] | ||
| + | log-enabled = true | ||
| + | enabled = true | ||
| + | run-interval = " | ||
| + | </ | ||
| + | |||
| + | relevante: | ||
| + | * constrains | ||
| + | * tasks.< | ||
| + | * si apuntas un loadbalancer (traefik) a los master... | ||
| + | * en el caso de este portainer, no desplegamos en al red de docker, si no sobre la máquina loca (pila tcp-ip local) | ||
| + | |||
| + | <code yaml; kpeiruza-portainer.yml> | ||
| + | version: | ||
| + | |||
| + | services: | ||
| + | portainer: | ||
| + | image: portainer/ | ||
| + | command: '-H " | ||
| + | ports: | ||
| + | - ${PUBLIC_PORT}: | ||
| + | networks: | ||
| + | - proxy | ||
| + | - portainer_agent | ||
| + | volumes: | ||
| + | - / | ||
| + | - ${REMOTE_MOUNT}/ | ||
| + | deploy: | ||
| + | mode: replicated | ||
| + | replicas: 1 | ||
| + | labels: | ||
| + | traefik.port: | ||
| + | traefik.frontend.rule: | ||
| + | traefik.docker.network: | ||
| + | placement: | ||
| + | constraints: | ||
| + | |||
| + | agent: | ||
| + | image: portainer/ | ||
| + | environment: | ||
| + | AGENT_CLUSTER_ADDR: | ||
| + | volumes: | ||
| + | - / | ||
| + | ports: | ||
| + | - target: 9001 | ||
| + | published: 9001 | ||
| + | protocol: tcp | ||
| + | mode: host | ||
| + | networks: | ||
| + | - portainer_agent | ||
| + | deploy: | ||
| + | mode: global | ||
| + | placement: | ||
| + | constraints: | ||
| + | |||
| + | |||
| + | |||
| + | networks: | ||
| + | portainer_agent: | ||
| + | external: true | ||
| + | proxy: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | === traefik (con https y let's encrypt) | ||
| + | <code yaml; traefik-proxy.yaml> | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | traefik: | ||
| + | image: library/ | ||
| + | command: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | networks: | ||
| + | - frontal | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | ports: | ||
| + | - 80:80 | ||
| + | - 443:443 | ||
| + | - 8080:8080 | ||
| + | deploy: | ||
| + | restart_policy: | ||
| + | condition: on-failure | ||
| + | |||
| + | networks: | ||
| + | frontal: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | === traefik (simple) | ||
| + | <code swarm-traefik.yml> | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | traefik: | ||
| + | image: library/ | ||
| + | command: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | # - " | ||
| + | networks: | ||
| + | - frontal | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | ports: | ||
| + | - 80:80 | ||
| + | - 443:443 | ||
| + | - 8080:8080 | ||
| + | deploy: | ||
| + | restart_policy: | ||
| + | condition: on-failure | ||
| + | networks: | ||
| + | frontal: | ||
| + | external: true | ||
| + | </ | ||