EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

[OK!!]Docker, cron, mail and logs

https://forums.docker.com/t/running-cronjob-in-debian-jessie-container/17527/7

dkoval Mar '17

=====

docker-compose.yml


version: '3.3'

services:
  gethpeers:
    build:
      context: gethpeers/
    volumes:
      - cronlog:/app/cronapplog:rw
    networks:
      - fastdev

  fakelog:
    build:
      context: fakelog/
    volumes:
      - cronlog:/app/cronapplog:rw
      - filebeat:/usr/share/filebeat/data:rw
    networks:
      - fastdev

volumes:  
  cronlog: 
  filebeat:
  
networks:
  fastdev:
    driver: bridge

gethpeers Dockerfile Fixed


FROM debian:stretch-slim
RUN apt-get -y update && apt-get install -y cron curl jq nano && \
    rm -r /var/lib/apt/lists/*
ADD . /app
ADD crontab /var/spool/cron/crontabs/root
RUN chmod 0600 /var/spool/cron/crontabs/root
RUN chmod +x /app/run-cronjob.sh
RUN chmod +x /app/start.sh
CMD cron -f

gethpeers crontab Fixed


* * * * * /app/run-cronjob.sh /app/start.sh > /proc/1/fd/1 2>/proc/1/fd/2
* * * * * echo hello > /proc/1/fd/1 2>/proc/1/fd/2

gethpeers run-cronjob Fixed


#!/bin/bash

if [ -z "$1" ] ; then
  echo "need name of cron job as first argument" > /proc/1/fd/1 2>/proc/1/fd/2
  exit 1
fi
 
if [ ! -x "$1" ] ; then
  echo "cron job file $1 not executable, exiting" > /proc/1/fd/1 2>/proc/1/fd/2
  exit 1
fi
 
if "$1"
then
  echo "cron job $1 Run!" > /proc/1/fd/1 2>/proc/1/fd/2
  exit 0
else
  echo "cron job $1 failed!" > /proc/1/fd/1 2>/proc/1/fd/2
  exit 1
fi

gethpeers start.sh


#!/bin/bash

IP_PORT=xxx.xxx.xxx.xxx:8545
ETH_METHOD=admin_peers
PEERS=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"'$ETH_METHOD'","params":[],"id":1}' $IP_PORT |  jq '.result[].network + {"project":"cronapp"}')

printf "\n===== Now Geth Peers =====\n"
printf "Peers: %s\n" $PEERS
echo $PEERS >> /app/cronapplog/gethpeers.log


fakelog Dockerfile


FROM docker.elastic.co/beats/filebeat:6.5.4
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chown root:filebeat /usr/share/filebeat/filebeat.yml
USER filebeat


fakelog filebeat.yml


filebeat.prospectors:

- type: log
  paths:
    - /app/cronapplog/gethpeers.log
  exclude_files: ['.gz$']
  fields:
    srcname: "geth"
    srctype: "cron"
    filebeatserverip: "xxx.xxx.xxx.xxx"
  fields_under_root: true
  symlinks: true

output.logstash:
  hosts: ["logstash:5044"]

[Faile!!]Docker, cron, mail and logs

F............................................................................................

https://www.preining.info/blog/2018/05/docker-cron-mail-and-logs/



from debian:stretch-slim
RUN apt-get -y update
RUN apt-get install -y cron #ssmtp
ADD . /app
ADD crontab /etc/cron.d/mypackage
RUN chmod 0644 /etc/cron.d/mypackage
#ADD ssmtp.conf /etc/ssmtp/ssmtp.conf
#RUN chown root.mail /etc/ssmtp/ssmtp.conf
#RUN chmod 0640 /etc/ssmtp/ssmtp.conf
CMD cron -f

=====

docker-compose.yml


version: '3.3'

services:
  gethpeers:
    build:
      context: gethpeers/
    volumes:
      - cronlog:/app/cronapplog:rw
    networks:
      - fastdev

  fakelog:
    build:
      context: fakelog/
    volumes:
      - cronlog:/app/cronapplog:rw
      - filebeat:/usr/share/filebeat/data:rw
    networks:
      - fastdev

volumes:  
  cronlog: 
  filebeat:
  
networks:
  fastdev:
    driver: bridge

gethpeers Dockerfile


from debian:stretch-slim
RUN apt-get -y update
RUN apt-get install -y cron 
#ssmtp
ADD . /app
ADD crontab /etc/cron.d/mypackage
RUN chmod 0644 /etc/cron.d/mypackage
#ADD ssmtp.conf /etc/ssmtp/ssmtp.conf
#RUN chown root.mail /etc/ssmtp/ssmtp.conf
#RUN chmod 0640 /etc/ssmtp/ssmtp.conf
CMD cron -f

gethpeers crontab


* * * * * root /app/run-cronjob /app/start.sh

gethpeers run-cronjob


#!/bin/bash

if [ -z "$1" ] ; then
  echo "need name of cron job as first argument" >&2
  exit 1
fi
 
if [ ! -x "$1" ] ; then
  echo "cron job file $1 not executable, exiting" >&2
  exit 1
fi
 
if "$1"
then
  exit 0
else
  echo "cron job $1 failed!" 2>/proc/1/fd/2 >&2
  exit 1
fi

gethpeers start.sh


#!/bin/bash

IP_PORT=xxx.xxx.xxx.xxx:8545
ETH_METHOD=admin_peers
PEERS=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"'$ETH_METHOD'","params":[],"id":1}' $IP_PORT |  jq '.result[].network + {"project":"cronapp"}')

printf "\n===== Now Geth Peers =====\n"
printf "Peers: %s\n" $PEERS
echo $PEERS >> /app/cronapplog/gethpeers.log


fakelog Dockerfile


FROM docker.elastic.co/beats/filebeat:6.5.4
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chown root:filebeat /usr/share/filebeat/filebeat.yml
USER filebeat


fakelog filebeat.yml


filebeat.prospectors:

- type: log
  paths:
    - /app/cronapplog/gethpeers.log
  exclude_files: ['.gz$']
  fields:
    srcname: "geth"
    srctype: "cron"
    filebeatserverip: "xxx.xxx.xxx.xxx"
  fields_under_root: true
  symlinks: true

output.logstash:
  hosts: ["logstash:5044"]

k8s kubernetes Lesson 4 RKE

Use RKE only one YAML config

https://itnext.io/setup-a-basic-kubernetes-cluster-with-ease-using-rke-a5f3cc44f26f

[轉]"migrating" to Kubernetes from docker-compose in homelab

https://www.reddit.com/r/docker/comments/9j2vc7/migrating_to_kubernetes_from_dockercompose_in/


If / when you're able to spawn arbitrary VMs, you can look at kubeadm, CoreOS, RKE (my current choice), and so on for cluster creation.



Before you can use kompose, or use kubectl apply -f myawesome.yaml, you first and foremost need to set up a Kubernetes cluster. This might be the most challenging thing to do because Kubernetes is heavy-weight compared to docker-compose. I recommend using RKE to set it up. Also, run away if anyone mentions Kubespray.


=====

RKE ???

YAML multi-line string

https://rancher.com/docs/rke/v0.1.x/en/config-options/add-ons/user-defined-add-ons/


To define an add-on directly in the YAML file, make sure to use the YAML’s block indicator

|-

as the addons directive is a multi-line string option. It’s possible to specify multiple YAML resource definitions by separating them using the

---

directive.