SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
Kubernetes Operator
for vSphere VM
KubernetesからvSphereのVMを作成してみる
VMware DevOps Meetup #3
今日のお話
KubernetesのOperatorを利用して、Kubernetes APIからvSphere上に仮想マシンを作
ります。
紹介するOperatorはPoC向けでありプロダクション向けのものではありません。
VMworld 2019 Session: Kubernetes Operators for VMware Enterprise PKS and
VMware Cloud PKS [CODE1360U] の内容をベースにしています。
● Streaming : https://videos.vmworld.com/global/2019/videoplayer/27913
● Presentation : https://cms.vmworldonline.com/event_data/12/session_notes/CODE1360U.pdf
● Github : https://github.com/embano1/kopf-operator-vmworld
Master3
Master2
Node
Node
Master1 Node
Client
(kubectl)
API Server
Cluster State Store
(etcd)
kubelet
Container
Runtime
Pod
(Container)
Controller Manager
Controllers
Scheduler
Kubernetesのアーキテクチャ
KubernetesのReconciliation Loop
Observe
Analyze
Act
期待する状態を現在
の状態を比較
状態の差異を
埋める
API Serverへ
現在の状態を
問い合わせる
● Deployment
● ReplicaSet
● StatefulSet
● ...etc
Operatorとは
Operatorは”Custom Resource Defnition”と”Custom Controller”の組み合わせ。
ステートフルなアプリケーション等に対する運用のナレッジをコード化し、Kubernetes
API上でアプリケーションライフサイクルの管理を実現する。
Operator CRD
(Custom Resource Definition)
Controller
(Custom Controller)
+=
● Custom Resource Definition : KubernetesのAPI上に任意のリソースを追加する
● Custom Controller : CRDによって定義されたカスタムリソースのライフサイクルを管理する
https://coreos.com/blog/introducing-operators.html
Introducing Operators: Putting Operational Knowledge into Software
2016/11/3 Brandon Philips
Operatorの例
● MySQL
● Elasticsearch
● Kafka
● Istio
● Sysdig Agent
● Velero
● Amazon RDS
● etc...
https://operatorhub.io/
Master3
Master2
Node
Node
Master1 Node
Client
(kubectl)
API Server
Cluster State Store
(etcd)
kubelet
Container
Runtime
Pod
(Container)
Controller Manager
Controllers
Scheduler
vSphereへの対応
Custom Controller
CRD
VmGroup(vg)をCRDとして定義する。
Custom Resource Definition(CRD)
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: vmgroups.vsphere.vmware.com
spec:
scope: Namespaced
group: vsphere.vmware.com
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: VmGroup
plural: vmgroups
singular: vmgroup
shortNames:
- vg
additionalPrinterColumns:
- name: Template
type: string
priority: 0
JSONPath: .spec.template
description: Template this VM group is based on
- name: Desired
type: integer
priority: 0
JSONPath: .spec.replicas
description: The number of configured replicas in this VM group
- name: Available
type: string
priority: 0
JSONPath: .status.vm_operator.currentReplicas
description: The number of available replicas in this VM group
- name: Phase
type: string
priority: 0
JSONPath: .status.vm_operator.phase
description: Deployment status of this VM group
Controllerの作成 - Operator Frameworkの利用
● kopf : Kubernetes Operator Pythonic Framework
○ https://github.com/zalando-incubator/kopf
○ Kubernetes APIの詳細を知らなくても Reconsilication Logicが実装可能
○ Supported Language : Python
● その他のFramework
○ Operator Framework - https://github.com/operator-framework
■ Supported Languanges : Golang (HelmチャートやAnsible Playbookの再利用が可能)
○ Kubebuilder - https://github.com/kubernetes-sigs/kubebuilder
■ Supported Languages: Golang
○ Google Metacontroller - https://metacontroller.app
■ Supported Languages: Python, JavaScript,
Kopfを使って、Kubernetes API上でVmGroup(vg)をCRDのライフサイクルを管理する
ためのコントローラーを作成する。
Custom Controller
import kopf
from pyVim.connect import Disconnect
from pyVmomi import vim
@kopf.on.event('vsphere.vmware.com', 'v1alpha1', 'vmgroups')
def vm_operator(event, spec, meta, status, logger, **_):
sleep(3)
if event_type == "DELETED":
delete_vm_group(vmgroup, logger)
return
try:
phase = status['vm_operator']['phase']
except KeyError:
phase = "PENDING"
if phase == "PENDING":
exists = vm_group_exists(vmgroup)
...
https://github.com/embano1/kopf-operator-vmworld/blob/master/controller.py
...
def create_vm_group(vmgroup_name: str, vmgroup_spec: Dict[str, str], logger:
logging.Logger) -> int:
try:
vsphere.create_folder(dc, vmgroup_name)
except vsphere.ObjectAlreadyExists as e:
logger.warn(str(e))
return
try:
created = vsphere.clone_vm(content, dc, CLUSTER, DATASTORE, vmgroup_name,
vmgroup_spec, logger)
except vsphere.CloneError as e:
logger.warn(str(e))
return -1
return created
Reconciliation Loopの実装
Custom Resourceの作成
CRDとして作成した VmGroup リソースを作成する。
apiVersion: vsphere.vmware.com/v1alpha1
kind: VmGroup
metadata:
name: kopf-example
labels:
vmdevops: "0918"
spec:
cpu: 1
memory: 1
template: kopf-vm-template
replicas: 3
# kubectl apply -f demo.yaml
vmgroup.vsphere.vmware.com/kopf-example created
# kubectl get vmgroup
NAME TEMPLATE DESIRED AVAILABLE PHASE
kopf-example kopf-vm-template 3 3 READY
デモ
Project Pacific ここ
Project Pacific – Technical Overview : https://blogs.vmware.com/vsphere/2019/08/project-pacific-technical-overview.html

Mais conteúdo relacionado

Mais procurados

Jenkins User Conference 東京 2015
Jenkins User Conference 東京 2015Jenkins User Conference 東京 2015
Jenkins User Conference 東京 2015
Kohsuke Kawaguchi
 

Mais procurados (20)

Kubernetesのワーカーノードを自動修復するために必要だったこと
Kubernetesのワーカーノードを自動修復するために必要だったことKubernetesのワーカーノードを自動修復するために必要だったこと
Kubernetesのワーカーノードを自動修復するために必要だったこと
 
Kubernetes Meetup Tokyo #8 Self-hosted Kubernetes を調べてみた
Kubernetes Meetup Tokyo #8 Self-hosted Kubernetes を調べてみたKubernetes Meetup Tokyo #8 Self-hosted Kubernetes を調べてみた
Kubernetes Meetup Tokyo #8 Self-hosted Kubernetes を調べてみた
 
AKS (k8s) Hands on Lab Contents
AKS (k8s) Hands on Lab ContentsAKS (k8s) Hands on Lab Contents
AKS (k8s) Hands on Lab Contents
 
kubernetes(GKE)環境におけるdatadog利用
kubernetes(GKE)環境におけるdatadog利用kubernetes(GKE)環境におけるdatadog利用
kubernetes(GKE)環境におけるdatadog利用
 
Japan Container Day 2018
Japan Container Day 2018Japan Container Day 2018
Japan Container Day 2018
 
”30分”ぐらいでわかる「Kubernetes」について
”30分”ぐらいでわかる「Kubernetes」について”30分”ぐらいでわかる「Kubernetes」について
”30分”ぐらいでわかる「Kubernetes」について
 
対話AI on Kubernetes
対話AI on Kubernetes対話AI on Kubernetes
対話AI on Kubernetes
 
DOO-003_Jenkins 作者が語る、Docker コンテナによる継続的デリバリのオススメと新機能のご紹介
DOO-003_Jenkins 作者が語る、Docker コンテナによる継続的デリバリのオススメと新機能のご紹介DOO-003_Jenkins 作者が語る、Docker コンテナによる継続的デリバリのオススメと新機能のご紹介
DOO-003_Jenkins 作者が語る、Docker コンテナによる継続的デリバリのオススメと新機能のご紹介
 
DockerとKubernetesが作る未来
DockerとKubernetesが作る未来DockerとKubernetesが作る未来
DockerとKubernetesが作る未来
 
Jenkins User Conference 東京 2015
Jenkins User Conference 東京 2015Jenkins User Conference 東京 2015
Jenkins User Conference 東京 2015
 
Kubernetes上のWindows Server コンテナーのマイクロサービス間分離
Kubernetes上のWindows Server コンテナーのマイクロサービス間分離Kubernetes上のWindows Server コンテナーのマイクロサービス間分離
Kubernetes上のWindows Server コンテナーのマイクロサービス間分離
 
新しいOpenShiftのしくみを調べてみた
新しいOpenShiftのしくみを調べてみた新しいOpenShiftのしくみを調べてみた
新しいOpenShiftのしくみを調べてみた
 
Java on Azure 2019
Java on Azure 2019Java on Azure 2019
Java on Azure 2019
 
自動化ハンズオン
自動化ハンズオン自動化ハンズオン
自動化ハンズオン
 
~Dockerfileの開発を劇的に楽にする~ Dockerfile開発環境 EDGE
~Dockerfileの開発を劇的に楽にする~ Dockerfile開発環境 EDGE~Dockerfileの開発を劇的に楽にする~ Dockerfile開発環境 EDGE
~Dockerfileの開発を劇的に楽にする~ Dockerfile開発環境 EDGE
 
Recap: [Code fresh] Deploying to kubernetes thousands of times per day @kuber...
Recap: [Code fresh] Deploying to kubernetes thousands of times per day @kuber...Recap: [Code fresh] Deploying to kubernetes thousands of times per day @kuber...
Recap: [Code fresh] Deploying to kubernetes thousands of times per day @kuber...
 
Kubernetes etc.. & rancher 2.0 technical preview
Kubernetes etc.. & rancher 2.0 technical previewKubernetes etc.. & rancher 2.0 technical preview
Kubernetes etc.. & rancher 2.0 technical preview
 
Rootlessコンテナ
RootlessコンテナRootlessコンテナ
Rootlessコンテナ
 
Windowsコンテナ入門
Windowsコンテナ入門Windowsコンテナ入門
Windowsコンテナ入門
 
Introduction of Azure Docker Integration
Introduction of Azure Docker IntegrationIntroduction of Azure Docker Integration
Introduction of Azure Docker Integration
 

Semelhante a Kubernetes Operator for vSphere VM

Semelhante a Kubernetes Operator for vSphere VM (20)

Kubernetes Meetup Tokyo #23 kubebuilder-v2
Kubernetes Meetup Tokyo #23 kubebuilder-v2Kubernetes Meetup Tokyo #23 kubebuilder-v2
Kubernetes Meetup Tokyo #23 kubebuilder-v2
 
[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門
 
CyberAgent: How We Deployed Production Kubernetes Clusters on OpenStack witho...
CyberAgent: How We Deployed Production Kubernetes Clusters on OpenStack witho...CyberAgent: How We Deployed Production Kubernetes Clusters on OpenStack witho...
CyberAgent: How We Deployed Production Kubernetes Clusters on OpenStack witho...
 
[Cloud OnAir] 【Google Kubernetes Engine 演習】解説を聞きながら GKE を体験しよう 2020年10月29日 放送
[Cloud OnAir] 【Google Kubernetes Engine 演習】解説を聞きながら GKE を体験しよう 2020年10月29日 放送[Cloud OnAir] 【Google Kubernetes Engine 演習】解説を聞きながら GKE を体験しよう 2020年10月29日 放送
[Cloud OnAir] 【Google Kubernetes Engine 演習】解説を聞きながら GKE を体験しよう 2020年10月29日 放送
 
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
 
[Cloud OnAir] Google Cloud 主催イベント Anthos Day 情報 2020 年 2 月 13 日放送
[Cloud OnAir] Google Cloud 主催イベント Anthos Day 情報 2020 年 2 月 13 日放送[Cloud OnAir] Google Cloud 主催イベント Anthos Day 情報 2020 年 2 月 13 日放送
[Cloud OnAir] Google Cloud 主催イベント Anthos Day 情報 2020 年 2 月 13 日放送
 
[OracleCodeTokyo2019] Kubernetesで実現する運用自動化の新しいアプローチとは
[OracleCodeTokyo2019] Kubernetesで実現する運用自動化の新しいアプローチとは[OracleCodeTokyo2019] Kubernetesで実現する運用自動化の新しいアプローチとは
[OracleCodeTokyo2019] Kubernetesで実現する運用自動化の新しいアプローチとは
 
Cluster API によるKubernetes環境のライフサイクル管理とマルチクラウド環境での適用
Cluster API によるKubernetes環境のライフサイクル管理とマルチクラウド環境での適用Cluster API によるKubernetes環境のライフサイクル管理とマルチクラウド環境での適用
Cluster API によるKubernetes環境のライフサイクル管理とマルチクラウド環境での適用
 
VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発
 
Container Storage Interface のすべて
Container Storage Interface のすべてContainer Storage Interface のすべて
Container Storage Interface のすべて
 
20220302_TechDojo_OpenShift_BootCamp_1章概要
20220302_TechDojo_OpenShift_BootCamp_1章概要20220302_TechDojo_OpenShift_BootCamp_1章概要
20220302_TechDojo_OpenShift_BootCamp_1章概要
 
今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門
 
Machine configoperatorのちょっとイイかもしれない話
Machine configoperatorのちょっとイイかもしれない話 Machine configoperatorのちょっとイイかもしれない話
Machine configoperatorのちょっとイイかもしれない話
 
AKS と ACI を組み合わせて使ってみた
AKS と ACI を組み合わせて使ってみたAKS と ACI を組み合わせて使ってみた
AKS と ACI を組み合わせて使ってみた
 
コンテナ未経験新人が学ぶコンテナ技術入門
コンテナ未経験新人が学ぶコンテナ技術入門コンテナ未経験新人が学ぶコンテナ技術入門
コンテナ未経験新人が学ぶコンテナ技術入門
 
The potential of Kubernetes as more than just an infrastructure to deploy
The potential of Kubernetes as more than just an infrastructure to deployThe potential of Kubernetes as more than just an infrastructure to deploy
The potential of Kubernetes as more than just an infrastructure to deploy
 
Kubernetes1.9でWindowsコンテナーをクラスタ化
Kubernetes1.9でWindowsコンテナーをクラスタ化Kubernetes1.9でWindowsコンテナーをクラスタ化
Kubernetes1.9でWindowsコンテナーをクラスタ化
 
マルチクラウド環境でモビンギはどのようにコンテナを動かしているか
マルチクラウド環境でモビンギはどのようにコンテナを動かしているかマルチクラウド環境でモビンギはどのようにコンテナを動かしているか
マルチクラウド環境でモビンギはどのようにコンテナを動かしているか
 
Dev ops meetup_01_photonos_tomochikak
Dev ops meetup_01_photonos_tomochikakDev ops meetup_01_photonos_tomochikak
Dev ops meetup_01_photonos_tomochikak
 
これから始めるAzure Kubernetes Service入門
これから始めるAzure Kubernetes Service入門これから始めるAzure Kubernetes Service入門
これから始めるAzure Kubernetes Service入門
 

Último

Último (7)

業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 

Kubernetes Operator for vSphere VM