Posts

Showing posts from April, 2021

Fluentd.yaml

kube-loging.yaml kind : Namespace apiVersion : v1 metadata : name : kube-logging Fluentd.yaml apiVersion : v1 kind : ServiceAccount metadata : name : fluentd namespace : kube-logging labels : app : fluentd --- apiVersion : rbac.authorization.k8s.io/v1 kind : ClusterRole metadata : name : fluentd labels : app : fluentd rules : - apiGroups : - "" resources : - pods - namespaces verbs : - get - list - watch --- kind : ClusterRoleBinding apiVersion : rbac.authorization.k8s.io/v1 metadata : name : fluentd roleRef : kind : ClusterRole name : fluentd apiGroup : rbac.authorization.k8s.io subjects : - kind : ServiceAccount name : fluentd namespace : kube-logging --- apiVersion : apps/v1 kind : DaemonSet metadata : name : fluentd namespace : kube-logging labels : app : fluentd spec : selector : matchLabels : app : fluentd template : metadata : labels : app : fluentd spec : serviceAccount...

ELK on K8S

 1. Cài sẵn bộ Elk và elasticseach mở cổng 9200 2. Cài filebeat để bắt log trong hệ thống cluster và cấu hình các loại log cần bắt nó đến từ pod nào, container nào , ip nào ..... 3. Cài metricbeat để bắt log về resources của hệ thống RAM CPU 4. Alert lỗi trên Elk  https://www.elastic.co/guide/en/kibana/master/action-types.html https://www.elastic.co/guide/en/observability/master/logs-threshold-alert.html

Go wire

 https://blog.drewolson.org/go-dependency-injection-with-wire

Install Go for MacOS

===========install go==================  https://golang.org/doc/install Có 2 biến GOPATH và GOROOT cần lưu ý GOPATH là nơi dùng để lưu lại package hoặc file bin khi install một package nào đó, hoặc lưu trữ package download về từ git  GOROOT là nơi chứa thư viện mặc định của go khi cài đặt =============install visual code============ install plugin for golang install code in cmd https://code.visualstudio.com/docs/setup/mac =================go command=============== Usage: go <command> [arguments] The commands are: bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get add dependencies to current module and i nstall them install compile and install pa...

Minimum layout for a library should look like this

  ├── Makefile  ├── README.rst  ├── setup.py  ├── src      └── apptool      ├── common.py │       ├── __init__.py │       └── parse.py  └── tests      ├── integration       └── unit

Format time in python

 https://www.journaldev.com/23365/python-string-to-datetime-strptime#:~:text=We%20can%20convert%20a%20string,datetime%20and%20time%20objects%20respectively. Directive Description Example Output %a Weekday as locale’s abbreviated name. Sun, Mon, …, Sat (en_US) So, Mo, …, Sa (de_DE) %A Weekday as locale’s full name. Sunday, Monday, …, Saturday (en_US) Sonntag, Montag, …, Samstag (de_DE) %w Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. 0, 1, 2, 3, 4, 5, 6 %d Day of the month as a zero-padded decimal number. 01, 02, …, 31 %b Month as locale’s abbreviated name. Jan, Feb, …, Dec (en_US) Jan, Feb, …, Dez (de_DE) %B Month as locale’s full name. January, February, …, December (en_US) Januar, Februar, …, Dezember (de_DE) %m Month as a zero-padded decimal number. 01, 02 … 12 %y Year without century as a zero-padded decimal number. 01, 02, … 99 %Y Year with century as a decimal number. 0001, 0002, … , 9999 %H Hour (24-hour clock) as a zero-padded decimal number. 01, 02, … ,...