cloud_edge_summit_chatops

MIT License

Stars
6

LINE Bot ChatOps

  • K3D Kubernetes
  • (LINE Bot)
  • LINE Bot Kubernetes

MacWindowsLinux Docker Cluster

  • Virtual Box
    • v6.1.28
  • NodeJS: v14.15.5
  • Python: 3.9
    • iTerm
    • WSL2

Virtual Box (Optional)

Google Drive

Virtual Box NAT ****

ssh demo@VM_IP  # default pwd 123456
sudo passwd root
su -

Root

VM IP

ifconfig | grep 1

Ubuntu Docker + netools (ifconfig)

sudo apt-get update -y
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release net-tools -y

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update -y
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo docker run hello-world

VM Python

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update -y
sudo apt-get install python3-pip -y
sudo apt-get install python3.8 -y

docker-ed

apt-cache madison docker-ce # find version
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

cluster

  • k3d
wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
  • kubectl command line
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
chmod +x kubectl
mkdir -p ~/.local/bin/kubectl
mv ./kubectl ~/.local/bin/kubectl

source from https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

  • Clone
git clone https://github.com/louis70109/cloud_edge_summit_chatops.git

VM GitHub

SHA

ssh-keygen
cat .ssh/id_rsa.pub

GitHub settings

Apply k3d cluster

cd cloud_edge_summit_chatops/
k3d cluster create testcluster --agents 1 -p "31110-31112:31110-31112@server:0"
kubectl create ns kube-ops
kubectl apply -f prometheus/
kubectl apply -f api/
  • prometheus/: Metrics
  • api/: API

LINE Bot

  • Official Account Manager **** LINE Bot
  • OA Manager LINE Bot
  • Developer Console LINE Bot

bot-proxy LINE Bot VM LINE Cluster

cd bot_proxy/
mv .env.example .env # vim to edit it
pip3 install -r requirements.txt --user
python3 api.py

Mac || Windows

NodeJS, ngrok NodeJS https://nodejs.org/zh-tw/download/

npx ngrok http --authtoken 'YOUR_NGROK_TOKEN' -region=ap --host-header=rewrite IP:8000

refs: https://ngrok.com/docs

- API

Bash Item API Deployment

while [ 1 ]
do
        curl IP:31110/items; sleep 1s
        curl -X POST IP:31110/items; sleep 1s
        curl -X POST IP:31110/items\?name=1; sleep 1s
done

chatbot

lens k9s Cluster k9s

namespace

namespace -n

kubectl get pods -n kube-ops
kubectl get svc -n kube-ops

Mac

Mac brew k3d kubectl

brew install k3d
brew install kubectl

Prometheus query:

  • rate(process_cpu_seconds_total{job="service"}[1m])

LICENSE

MIT

Related Projects