本資料は、CNDT2021「Kubernetesオペレータのアンチパターン&ベストプラクティス」の補足資料です。
プレゼンの中では説明しきれなかったベストプラクティスの実装を詳細に解説します。
プレゼンでも紹介したように、必ず現在の状態をチェックしてから実行すべき処理を決定することになります。
Necoとはいったい何なのか。
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
"time" | |
homedir "github.com/mitchellh/go-homedir" | |
"github.com/spf13/cobra" |
package main | |
import ( | |
"bufio" | |
"context" | |
"crypto/sha256" | |
"encoding/hex" | |
"flag" | |
"fmt" | |
"log" |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"github.com/Cside/jsondiff" |
# Stage1: build from source | |
FROM quay.io/cybozu/golang:1.12-bionic AS build | |
COPY main.go /work/main.go | |
WORKDIR /work | |
RUN CGO_ENABLED=0 go build -o server ./main.go | |
# Stage2: setup runtime container | |
FROM scratch |
--- | |
kind: DaemonSet | |
apiVersion: extensions/v1beta1 | |
metadata: | |
name: calico-node | |
namespace: kube-system | |
labels: | |
k8s-app: calico-node | |
spec: | |
selector: |
import rx.Observable; | |
import rx.Observer; | |
import rx.Producer; | |
import rx.Subscriber; | |
import rx.schedulers.Schedulers; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class BackPressureSample { |
import java.io.File | |
import org.embulk.EmbulkEmbed | |
object EmbulkEmbedTest extends App { | |
val bootstrap = new EmbulkEmbed.Bootstrap() | |
val embulkEmbed = bootstrap.initialize() | |
val loader = embulkEmbed.newConfigLoader() | |
val yaml = new File(getClass.getClassLoader.getResource("test.yml").getPath) | |
val config = loader.fromYamlFile(yaml) |
///<reference path="rx.js.d.ts" /> | |
declare module Rx { | |
interface Observable { | |
/* Observable.startとtoAsyncは、rx.js.d.tsに定義されている。rx.js 2.2でrx.jsからrx.async.jsに移動したのがまだ反映されてない模様。 | |
start<T>(func: () => T, scheduler?: IScheduler, context?: any): IObservable<T>; | |
toAsync<T>(func: (...args: any[]) => T, scheduler?: IScheduler, context?: any): (...args: any[]) => IObservable<T>; | |
*/ | |
fromCallback<T>(func: (...args: any[]) => void, scheduler?: IScheduler, context?: any, selector?: (...args: T[])=>T): () => IObservable<T>; | |
fromNodeCallback<T>(func: (...args: any[]) => void, scheduler?: IScheduler, context?: any, selector?: (...args: any[])=>T): (...args: any[]) => IObservable<T>; |