Skip to content

Instantly share code, notes, and snippets.

package leaderelection
import (
"context"
"time"
coordinationv1 "k8s.io/api/coordination/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
@d-kuro
d-kuro / kube-aws.md
Last active October 25, 2019 05:19
kube-aws component version
@d-kuro
d-kuro / cloudnativejp.md
Created September 26, 2019 11:46
Cloud Native Meetup Tokyo #10

Cloud Native Meetup Tokyo #10

Kubernetes 上で KVS をマネージドっぽく使いたい!

  • Redis Operator
    • HA 構成の Redis
    • 何も考えずに HA の Redis が作れる
  • 一発でエンドポイントが払い出せる
@d-kuro
d-kuro / mercari.md
Created May 25, 2019 14:47
Mercari Meetup for Microservices Platform #2

Mercari Meetup for Microservices Platform #2

How we structure our work at Microservices platform team @deeeet

  • 初期の management
    • 初期はマネジメントなんてなかった
    • 各メンバーが課題見つけてそれぞれやってた
  • 個人プレー
@d-kuro
d-kuro / fork.md
Last active July 18, 2019 05:10
GitHub で Fork 元の更新を取り込む
git remote add upstream https://github.com/foo/bar.git
git fetch upstream
git checkout master
git merge --ff upstream/master
git push origin master
@d-kuro
d-kuro / go-conference.md
Created May 19, 2019 13:19
Go Conference 2019 Spring

Go Conference 2019 Spring

Case studies of designing developer friendly libraries

  • Speaker: Masayuki Izumi
  • Twitter: izumin5210

>ライブラリやツールなど、自分以外の人間が「ユーザ」となる開発では、その Interface / Experience が重要であり、生産性や開発の楽しさにも直結します。本セッションでは、自身のこれまでの経験・まわりからのフィードバックから集めた、Developer にとってより良い Interface / Experience なライブラリ・ツールを作るための Tips や考え方を紹介します。

@d-kuro
d-kuro / kubernetes-meetup.md
Last active April 22, 2019 16:54
Kubernetes Meetup Tokyo #18

Kubernetes Meetup Tokyo #18

kubebuilder/controller-runtime 入門 (30min)

  • slideshare
  • kubebuilder
    • コードのテンプレート/マニフェスト群を生成してくれる CLI ツール
  • book.kubebuilder.io がよく書かれている
@d-kuro
d-kuro / cloud_native_meetup_tokyo.md
Created April 13, 2019 09:56
Cloud Native Meetup Tokyo #7 @abema Towers

Cloud Native Meetup Tokyo #7 @Abema Towers

Telepresence ではじめる k8s 時代のローカル開発

Telepresence とは

  • telepresence
  • 単一のサービスをリモートの k8s クラスタに接続しながらローカル開発
// from: https://github.com/kubernetes/kubernetes/blob/87f9429087d4e31201412548517d36e83abebc8d/pkg/controller/cronjob/utils.go#L89-L149
// getRecentUnmetScheduleTimes gets a slice of times (from oldest to latest) that have passed when a Job should have started but did not.
//
// If there are too many (>100) unstarted times, just give up and return an empty slice.
// If there were missed times prior to the last known start time, then those are not returned.
func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time.Time, error) {
starts := []time.Time{}
sched, err := cron.ParseStandard(sj.Spec.Schedule)
if err != nil {
// from: https://github.com/kubernetes/kubernetes/blob/87f9429087d4e31201412548517d36e83abebc8d/pkg/controller/cronjob/cronjob_controller.go#L248-L261
times, err := getRecentUnmetScheduleTimes(*sj, now)
if err != nil {
recorder.Eventf(sj, v1.EventTypeWarning, "FailedNeedsStart", "Cannot determine if job needs to be started: %v", err)
klog.Errorf("Cannot determine if %s needs to be started: %v", nameForLog, err)
return
}
// TODO: handle multiple unmet start times, from oldest to newest, updating status as needed.
if len(times) == 0 {