Skip to content

Instantly share code, notes, and snippets.

@ykyuen
ykyuen / boatswain
Created Feb 13, 2020
setting-the-time-interval-of-metrics-collection-in-boatswain-02
View boatswain
ykyuen@camus:~# boatswain --help
Usage: boatswain [options]
Options:
-f string
boatswain configuration file.
-v Show boatswain version and exit.
@ykyuen
ykyuen / boatswain.yml
Created Feb 13, 2020
setting-the-time-interval-of-metrics-collection-in-boatswain-01
View boatswain.yml
# 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 Jan 9, 2020
monitor-k8s-cluster-by-running-boatswain-as-a-daemonset-02
View kubectl.sh
[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 Jan 9, 2020
monitor-k8s-cluster-by-running-boatswain-as-a-daemonset-01
View daemon-set.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: boatswain
namespace: boatswain
spec:
selector:
matchLabels:
name: boatswain
template:
@ykyuen
ykyuen / project.sh
Created Apr 18, 2019
handling-http-request-in-go-echo-framework-2-05
View project.sh
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 Apr 18, 2019
handling-http-request-in-go-echo-framework-2-04
View base.html
{{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 Apr 18, 2019
handling-http-request-in-go-echo-framework-2-03
View about.html
{{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 Apr 18, 2019
handling-http-request-in-go-echo-framework-2-02
View main.go
...
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 Apr 18, 2019
handling-http-request-in-go-echo-framework-2-01
View post_full_name.go
package api
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"github.com/labstack/echo"
@ykyuen
ykyuen / project.sh
Last active Apr 18, 2019
handling-http-request-in-go-echo-framework-1-06
View project.sh
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