Kubernetes Operatorで実現する NoOps の世界 OpenStack Days Tokyo, Cloud Native Days Tokyo 2018 / August 3, 2018 Shunya Murata @shmurata_ Kazuki Suda @superbrothers
Node A Pod ▶ Self Healing ▶ Declarative Configuration + desired state/actual state ▶ Liveness/Readiness Probe + Health Checks ▶ Podのセルフヒーリング + Nodeに障害が発⽣するとPod をサービスアウトして削除 + 不⾜するとPodを⾃動的に追加 10 Kubernetes コントローラ 障害検知 Node B Pod Pod Service 削除 追加
▶ In-Flight Renewing ▶ Rolling Update + 新しいバージョンのPodの追加と古いバージョンのPodを削除を繰り返すこと で無停⽌で更新 11 Kubernetes コントローラ Node Pod v1 Node Node Pod v1 Pod v1 Pod v2 আ Ճ
▶ カスタムコントローラの実装: k8s.io/code-generator 37 ▶ client-go は Kubernetes のビルトインリソース (e.g. Pods) を扱えるが、カスタム リソースは当然扱えない ▶ code-generator は、定義したカスタムリソースの Go 構造体から client-go で カスタムリソースを扱うためのいくつかのコードを⽣成 // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type EtcdCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec ClusterSpec `json:"spec"` Status ClusterStatus `json:"status"` } type ClusterSpec struct { // Size is the expected size of the etcd cluster. // The etcd-operator will eventually make the size of the running // cluster equal to the expected size. // The vaild range of the size is from 1 to 7. Size int `json:"size"` // Repository is the name of the repository that hosts // etcd container images. It should be direct clone of the repository in official // release: // https://github.com/coreos/etcd/releases // That means, it should have exact same tags and the same meaning for the tags. https://github.com/coreos/etcd-operator/blob/v0.9.2/pkg/apis/etcd/v1beta2/cluster.go