Kubernetes Meetup Tokyo #11 - KubeCon EU Recap https://k8sjp.connpass.com/event/85336/
Google Slide ver. https://docs.google.com/presentation/d/1-4XHr7Q_uEK6vFrNJmByqJzkdiyPmTAGk2T14a_5I90/edit?usp=sharing
RecapSIG API MachineryDeep DiveKubernetes meetup Tokyo #11Aya Igarashi @ladicle
View Slide
@LadicleAya IgarashiSoftware Engineer - Z Lab Corp.Who am I?
Custom ResourcesDemohttps://github.com/Ladicle/crd-sample
Outline of the Talk★ DeepDiveStefan SchimanskiSenior Software Engineer at Red Hat○ api-serverがapiextensions-apierverに委譲する流れ○ CRDを生成する流れと, raceするbugの紹介○ spec+ statusパターンの推奨 (for subresource)○ structuredなclientコード生成のすゝめ○ OpenAPI v3 schemaによるvalidationの紹介○ 上記のvalidationを利用したpruning(schema外のfieldがあった場合は除去 )○ Subresourceの /scaleと /status の紹介○ Versioning, Pruning/Defaulting, Graceful Deletion,Server Side Printing Columns, Subresources★ Custom Resources 1.11+ (1.12+)https://www.youtube.com/watch?v=XsFH7OEIIvI
Versioning & ValidationDEEP DIVE
CRD versioning (nop conversion) v1.11○ Design: https://github.com/kubernetes/community/pull/2054/files○ Pull-Request: https://github.com/kubernetes/kubernetes/pull/63830 #ONGOINGtype CustomResourceDefinitionSpec struct {...// 将来的にDeprecatedになる.Version string// 対応するVersionリスト.// StoredVersionsリストに含まれているものは削除できない.Versions []CustomResourceDefinitionVersion}type CustomResourceDefinitionVersion struct {// v2beta1などのバージョン名.Name string// REST APIから指定できるようにするかのフラグ.Served Boolean// Storage(etcd)に保存する時のVersionであるかのフラグ.// Versionリストの中で1つのみTrueにする.Storage Boolean}type CustomResourceDefinitionStatus struct {...// Storageに保存されているCRのVersionリスト.// migrationが完了したらリストから除く.StoredVersions []string}
CRD versioning v1.12+○ Design: https://github.com/kubernetes/community/pull/2026/files #ONGOINGtype CustomResourceDefinitionVersion struct {...Conversion CustomResourceConversion}// 変更するpathごとにconversion resourceを作成するtype CustomResourceConversion struct {Declarative map[string]CustomResourceDeclarativeConversion}type CustomResourceDeclarativeConversion struct {Rename RenameConversion// 右のWebhook用の設定External CustomResourceConversionWebhook}// JsonPath(例: .spec.hoge)形式で指定type RenameConversion struct {From JsonPathTo JsonPath}type CustomResourceExternalConversion struct {// 変換先のVersion名リスト.To []stringWebhook ConversionWebhook}type ConversionWebhook struct {// clientとどう通信するかを定義するもの.// WebhookのService等を指定するClientConfig WebhookClientConfig}// 各VersionのValidationにも対応するようだが// これの詳細はまだ未定
ValidationOpenAPI v3 schema & Admission Controllers
Validation using OpenAPI v3 schemaapiVersion: apiextensions.k8s.io/v1beta1kind: CustomResourceDefinitionmetadata:name: meetups.kube.tokyo...validation:openAPIV3Schema:properties:spec:properties:eventName:type: stringpattern: '^KubernetesMeetup#\d+$'theme:type: stringenum:- normal- recapspeakerNames:type: arrayitems:type: stringcapacity:type: integerdefault: 10minimum: 10apiVersion: kube.tokyo/v1kind: Meetupmetadata:name: meetup11namespace: defaultspec:eventName: Kubernetes Meetup Tokyo #11theme: recapspeakerNames:- lanMLewis- amsy810- ladicle- nasa9085- jyoshise- rafiror- dtan4capacity: 200
Validation using Admission Controllers--enable-admission-plugins=DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota● ValidatingAdmissionWebhook○ リソースをValidationするためのWebhook (変更はできない)● MutatingAdmissionWebhook○ リソースのチェックや変更をするための Webhook● Initializers○ リソースを初期化するための metadata.initializers.pendingリストを付与する○ 全ての初期化が終わるまでリソースが作成されないetc...
What should I use to validate resources?
WE AREHIRING!
THANK YOUFor your time & we’ll see you soonladicle