發表文章

[轉]Docker, cron, mail and logs

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

OpenFaas

https://github.com/openfaas/faas

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.

[轉]Headless CMS: REST vs JSON:API vs GraphQL

https://dri.es/headless-cms-rest-vs-jsonapi-vs-graphql?fbclid=IwAR3PJouIotZns9DnthDvr4cA-vtWiFq60opwL-dCuAjLElaflI-qj4Uw5KY#operational-efficiency

嘉能 免手洗單槽洗淨過濾魔術平板拖把

爛! 不合用!


https://media.etmall.com.tw/XML/Scrshot/20190214/150926299_2190891.jpg

爛在那:


1. 拖把只能單邊收折,意謂只能單邊進入洗桶
2. 承1. 洗桶高度非常剛好是拖版的高度,那就代表一邊進去後,另一邊的最後面是洗不到的!!……整個無言了
3. 承2. 洗桶和拖版高度一致,導致…拖把不能弄略乾,水肯定要裝蠻高的,不然洗個屁,洗完慢慢拉出來,按照水的高度,不就只有一小段是能略乾,其他段都是溼
4. 裝水時根本不知道水裝了多少??
5. 另外拖把必須要特殊使用方式,不然地上會一痕一痕,還有拖完地板很溼!

基本上比最近市面上很紅的腳踏式拖把還差!比同類型雙桶(一洗一乾)還差!比跪在地上用手擦地還浪費時間!



能想像 拖把只能洗一半的情況嗎??!!

[轉]Benchmark results of Kubernetes network plugins (CNI) over 10Gbit/s network

https://itnext.io/benchmark-results-of-kubernetes-network-plugins-cni-over-10gbit-s-network-36475925a560

ethereum-etl to csv to filebeat to kafka to mysql


filbeat to kafka

https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html


sink-connector to mysql

https://docs.confluent.io/current/connect/kafka-connect-jdbc/sink-connector/index.html

[轉]做吃的

https://www.mobile01.com/topicdetail.php?f=747&t=5710232

我曾經是個牛肉麵 "第三代小老闆"(跑堂小弟)
自我國小5年級起!!!
從一碗小碗牛肉麵30元新台幣賣到2014年10月為止!
那年...牛肉麵一碗小碗漲賣130元
大碗賣到150元!
店租從早年每月5000元!
到最後紡寮夜市場被拆(租金當時15000元)
足足超過30年...
後來去景平路租6坪大小店面租金要8萬!!!
隨後放棄再賣牛肉麵!!!

其實!
我看到本版太多人想賣吃的賺錢!!!
但是...
麻煩一下!!!
看清楚現實!!!
俗話說..."秀才造反!三年不晚!!!"
你們想做吃的賺錢!!!
我是不反對!!!
但是有打算虧三年的心理準備嗎?

沒特色地小吃.餐廳或是飲料店!
基本上離倒店不遠!!!
坦白說...我家賣牛肉麵關門兩次...
一次是我家老闆娘生病...那次關了整整8年!
另一次是我那個無緣地越南前妻鬧政變!
那一次搞到至今無法再開店!
因為...無人可幫!!!
說沒人幫忙!太沉重...
應該說...不想把秘密流出去!
PS.別問我是否開班授徒! 答案是 NO

回頭把真實狀況想出來吧!!!
作吃地生意!
有三大影響收入問題
第一...進貨成本.
第二...開銷成本.
第三...人事成本.
這三個不解決!很難賺大錢
以牛肉麵而言...
進貨成本!
我從一箱牛肉(澳洲)2400元60磅
買到一箱牛肉(USA)6400元60磅
而每天購買小白菜從最低3元一斤到50元一斤(颱風天)
青蔥從20元一把到每把300元(颱風天)
大蒜一斤20元到一斤80元
老薑一箱30斤600元到2500元
......(還有許多)
其實沒去菜市場當"三寶"(台語.台北果菜批發市場對收尾大戶尊稱)
你永遠不知道怎樣省錢!
當時...我每天購買
20~30斤菜. 每天5把三星蔥一把蒜葉
每一星期進蒜頭20斤
每20~30天進老薑一箱
每兩個月進一箱辣椒粉與10斤花椒.
.....還有很多很多...
包括香料.醬油.糖.鹽.糯米醋.香醋.菜油...等.
每天口袋鈔票有萬元以上是要付出去!
所以!每天要有最低收入...否則開"天窗"
開銷成本.
房租!電費!瓦斯!水費!垃圾袋!(其他雜項開支)
其實這項最恐怖!
每當這項在每天收攤回家算錢作帳時!
總會發現少了點錢!
最恐怖的是...花在哪裡不知道!!!
明明辛苦賺上萬元!
怎口袋剩下4000多...要死了!!!
比較常見有...鈔票換銅板.1元.5元.10元.50元
碗盤.玻璃櫃破損.
修理冰箱.冷氣!運菜車...
人事成本
作吃的生意!!!
如果不是夫妻.兄弟.姊妹...下去做!
而且齊心齊力做!
根本無法賺錢(算薪水更恐怖.到底誰多誰少?)
因為外聘費用問題!
我從一位歐巴桑雇用3000元到最後12000元
只有洗菜.切菜.切酸菜.切豆干以及洗碗.
從早上10點坐到下午2點
另外一位是下午5點到晚上8點!
後來發現下午那一位偷錢所以開除!
以後來的都嫌髒.嫌油膩.端麵慢.收桌慢...
改為自己弄!!!
人...總是每天累翻!!!
每個月總休息兩天!(初一與十五)
因為每個月沒有收入XX萬...很難睡好覺!!!
當時!曾考慮外包麵條...
結果老客人不爽一天全又改回自己做手工麵條!
當時我家老爺高齡81歲做麵給小娃娃吃...
為的是"手工筋道"麵條
哀~~~麵粉錢也不少.
每次都要叫50袋麵粉才有便宜!
我家永遠用"駱駝" 因為該牌不偷...


請不要認為!
牛肉麵好賣...
有錢的吃的起牛肉麵.
其他都吃"牛肉湯麵"
而且來店不一定吃牛肉麵...
專賣牛肉麵 = 倒店
所以...有牛雜麵.
榨菜肉絲麵...
小菜有...
炒豆干.炒海帶.棒打黃瓜.台式泡菜.辣頭皮耳朵!!!...等
這些...材料費用也不少...

香料部分...這是秘密!
說穿...市面上都有很多賣"滷味"香料包.
從5種香料到40多種!!!
說穿了...
各家香料配方方式多少雷同或不同!
我就不說我家的...
畢竟...沒考慮外流
但香料好壞決定一鍋"滷牛肉"的好與壞!!!
打比方...
滷的好...喵公公與浪浪最先知道!
而且會排隊等著偷吃與施捨!!!
滷的不好或是用料爛!
野喵與浪浪一隻也沒看到!
更別提外面會有客人上門!!!
常見有台十三香.廣十三香與川十三香
請不要問我一堆有的沒有的!
我上面寫很"白"
請不要考慮市售餐飲用"牛肉湯包"
如果真的玩到這地步!!!
那乾脆別賣!
好吃又賺錢的牛肉麵店家
是絕對不用這些玩意!
因為一吃就知道!!!

今天就寫到這...用不著待續!
如果各位要我推薦哪家麵好吃...
口袋名單...
"老牌牛肉麵"
這是我國小三年級到國小五年級在台北打工
常去的一家...
"小雜"值得推薦!!

k8s kubernetes Lesson 3 k8s by hand

Kubernetes wiki
https://wiki.gslin.org/wiki/Kubernetes

How to Install a Kubernetes Docker Cluster on CentOS 7
https://www.howtoforge.com/tutorial/centos-kubernetes-docker-cluster/
https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

=====
https://www.howtoforge.com/tutorial/centos-kubernetes-docker-cluster/

only one master/node k8s



yum update

setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

modprobe br_netfilter
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables

swapoff -a

vim /etc/fstab     >> mark swap

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce

cat << eof > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

yum install -y kubelet kubeadm kubectl

sudo reboot  


systemctl start docker && systemctl enable docker
systemctl start kubelet && systemctl enable kubelet

docker info | grep -i cgroup

sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

systemctl daemon-reload
systemctl restart kubelet


## kubeadm init --apiserver-advertise-address=10.0.15.10 --pod-network-cidr=10.244.0.0/16
kubeadm init --pod-network-cidr=10.244.0.0/16

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

kubectl get nodes
kubectl get pods --all-namespaces

https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#control-plane-node-isolation

kubectl taint nodes --all node-role.kubernetes.io/master-

If use calico
https://docs.projectcalico.org/v3.5/getting-started/kubernetes/

Dashboard



##### dashboard
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

#modify clusterip -> nodeport
nano kubernetes-dashboard.yaml
# ------------------- Dashboard Service ------------------- #

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
    - port: 443
      targetPort: 8443
      nodePort: 30393
  selector:
    k8s-app: kubernetes-dashboard

kubectl -n kube-system get service kubernetes-dashboard



[root@localhost ~]# kubectl -n kube-system get service kubernetes-dashboard
NAME                   TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   10.110.11.88           443:30393/TCP   103

use 30393 EX: https://192.168.99.118:30393 (192.168.99.118 is virtualbox give ip)



Dashboard ERROR NET::ERR_CERT_INVALID

https://github.com/kubernetes/dashboard/issues/2954
https://github.com/kubernetes/dashboard/wiki/Certificate-management


mkdir certs  ( At user home path )
openssl req -nodes -newkey rsa:2048 -keyout certs/dashboard.key -out certs/dashboard.csr -subj "/C=/ST=/L=/O=/OU=/CN=kubernetes-dashboard"
openssl x509 -req -sha256 -days 365 -in certs/dashboard.csr -signkey certs/dashboard.key -out certs/dashboard.crt

kubectl delete -f kubernetes-dashboard.yaml
kubectl create secret generic kubernetes-dashboard-certs --from-file=certs -n kube-system
kubectl create -f kubernetes-dashboard.yaml

Try again. https://192.168.99.118:30393





Get Dashboard token

https://github.com/kubernetes/dashboard/wiki/Creating-sample-user


nano dashboard-adminuser.yaml


apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system


kubectl create -f dashboard-adminuser.yaml

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

If see admin-user token, just copy token pass to web login.

IF Get Error

try to Create ClusterRoleBinding


nano dashboard-adminuser.yaml

Addpend



apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system



kubectl create -f dashboard-adminuser.yaml

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')



[轉]Kubernetes 的失敗案例

https://blog.gslin.org/archives/2019/01/30/8707/kubernetes-%E7%9A%84%E5%A4%B1%E6%95%97%E6%A1%88%E4%BE%8B/

[轉]kubernetes failure stories

https://github.com/hjacobs/kubernetes-failure-stories

[轉]ingress-nginx & kubernetes-ingress with NGINX & nginxinc/kubernetes-ingress with NGINX Plus

https://github.com/nginxinc/kubernetes-ingress/blob/master/docs/nginx-ingress-controllers.md

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



================
https://mritd.me/2017/03/04/how-to-use-nginx-ingress/