Skip to content

Instantly share code, notes, and snippets.

@ykyuen
ykyuen / boatswain
Created February 13, 2020 06:33
setting-the-time-interval-of-metrics-collection-in-boatswain-02
ykyuen@camus:~# boatswain --help
Usage: boatswain [options]
Options:
-f string
boatswain configuration file.
-v Show boatswain version and exit.
@ykyuen
ykyuen / boatswain.yml
Created February 13, 2020 06:30
setting-the-time-interval-of-metrics-collection-in-boatswain-01
# Please register and get the token from https://app.boatswain.io/
token: token_here
# Period is the collection time interval of the host and docker metrics.
# CPU load could be reduced by using longer period.
# - short = 10s
# - default = 30s
# - long = 60s
period: default
@ykyuen
ykyuen / kubectl.sh
Created January 9, 2020 08:59
monitor-k8s-cluster-by-running-boatswain-as-a-daemonset-02
[ykyuen@camus ~]$ kubectl get ds -n boatswain
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
boatswain 1 1 1 1 1 kubernetes.io/hostname=gke-boatswain-default-pool-v2-1234abcd-5678 52s
@ykyuen
ykyuen / daemon-set.yaml
Created January 9, 2020 08:43
monitor-k8s-cluster-by-running-boatswain-as-a-daemonset-01
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: boatswain
namespace: boatswain
spec:
selector:
matchLabels:
name: boatswain
template:
@ykyuen
ykyuen / project.sh
Created April 18, 2019 09:38
handling-http-request-in-go-echo-framework-2-05
handling-http-request-in-go-echo-example-2/
├── api/ # folder of api endpoints
│ ├── get_full_name.go # api for get full name
│ ├── post_full_name.go # api for post full name
├── handler/ # folder of request handlers
│ ├── home_handler.go # handler for home page
│ └── about_handler.go # handler for about page
├── model/ # folder of custom struct types
│ ├── example_request.go # struct type of get_full_name request
│ └── example_response.go # hstruct type of get_full_name response
@ykyuen
ykyuen / base.html
Created April 18, 2019 09:35
handling-http-request-in-go-echo-framework-2-04
{{define "base.html"}}
<!DOCTYPE html>
<html>
<head>
<title>{{template "title" .}}</title>
<!-- jQuery -->
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
@ykyuen
ykyuen / about.html
Created April 18, 2019 09:34
handling-http-request-in-go-echo-framework-2-03
{{define "title"}}
Boatswain Blog | {{index . "name"}}
{{end}}
{{define "body"}}
<h1>{{index . "msg"}}</h1>
<h2>This is the about page.</h2>
<!-- HTML form -->
<form id="post-full-name-form">
@ykyuen
ykyuen / main.go
Created April 18, 2019 09:32
handling-http-request-in-go-echo-framework-2-02
...
func main() {
// Echo instance
e := echo.New()
// Instantiate a template registry with an array of template set
// Ref: https://gist.github.com/rand99/808e6e9702c00ce64803d94abff65678
templates := make(map[string]*template.Template)
templates["home.html"] = template.Must(template.ParseFiles("view/home.html", "view/base.html"))
templates["about.html"] = template.Must(template.ParseFiles("view/about.html", "view/base.html"))
@ykyuen
ykyuen / post_full_name.go
Created April 18, 2019 09:30
handling-http-request-in-go-echo-framework-2-01
package api
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"github.com/labstack/echo"
@ykyuen
ykyuen / project.sh
Last active April 18, 2019 08:49
handling-http-request-in-go-echo-framework-1-06
handling-http-request-in-go-echo-example-1/
├── api/ # folder of api endpoints
│ ├── get_full_name.go # api for get full name
├── handler/ # folder of request handlers
│ ├── home_handler.go # handler for home page
│ └── about_handler.go # handler for about page
├── model/ # folder of custom struct types
│ ├── example_request.go # struct type of get_full_name request
│ └── example_response.go # hstruct type of get_full_name response
├── vendor/ # dependencies managed by dep