Shawn
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# K8s CRD/Controllers (1/2) --- ### k8s Master Components - kube-apiserver - etcd - kube-scheduler - kube-controller-manager * Node/Replication/Endpoints(Services/Pods)/Service Account & Token - cloud-controller-manager --- ### What is cloud-providers? https://kubernetes.io/docs/concepts/architecture/cloud-controller/ - cloud controller manager -> kops * Node controller * Route controller * Service controller * Volume controller (> CSI) - for os-in-os cases --- ### OpenStack Cloud Provider - OpenStack Cloud Controller Manager - Octavia Ingress Controller - Cinder CSI Plugin - Keystone Webhook Authentication - Authorization - Client Keystone - Cinder Standalone Provisioner - Manila CSI Plugin - Manila Provisioner - Barbican KMS Plugin --- ### [AWS operator](https://aws.amazon.com/blogs/opensource/aws-service-operator-kubernetes-available/) - DynamoDB Tables - S3 Buckets - Amazon Elastic Container Registry (Amazon ECR) - Repositories - SNS Topics - SQS Queues - SNS Subscriptions --- ## K8s is API-centric | Declarative | State | Level based | Transparent | | ----------- | ------- | ----------- | ----------- | | What vs How | Desired | Doesn't rely on individual change | One control plane | | build from config | Observed | Facilities composability| Less prone to error | | Record changes | | | | --- ### k8s to build a pod/cake? * Built-in * node / pod / deployment / service ``` curl localhost:8080/api/v1/namespaces/kube-system/services/ingress/ ``` * CRD * [cake](https://kccncosschn19eng.sched.com/event/NrnG/to-crd-or-not-to-crd-that-is-the-question-ed-king-sam-gunaratne-pivotal) * room/light * node/vm * mysql/Spark/Cassandra ``` curl localhost:8080/apis/apiextensions.k8s.io/v1beta1 ``` --- ### Stateless is easy, stateful is hard - k8s can handle stateless - manage other stateful applications need extra knowledge - CRD - StatefulSets, Services, ConfigMaps ![etcd-operator](https://coreos.com/sites/default/files/inline-images/Overview-etcd_0.png) --- ## kubevirt ![kubevirt](https://d33wubrfki0l68.cloudfront.net/a6f0f1a39546d77e697b0f6b803faa871cab56bd/937a1/images/blog/2018-05-22-getting-to-know-kubevirt/kubevirt-components.png) --- ## kubevirt components - `CRD` - are added to the Kubernetes API - `virt-controller` - cluster wide logic associated with these new types - `virt-handler` - node specific logic associated with new types --- ### kubevirt yaml ``` apiVersion: kubevirt.io/v1alpha3 kind: KubeVirt metadata: name: kubevirt namespace: kubevirt spec: imagePullPolicy: Always ``` --- ### rook - ceph crd ![rook](https://rook.io/docs/rook/v1.0/media/kubernetes.png) --- ### Timeline [Kubernetes API 与 Operator:不为人知的开发者战争](https://www.lijiaocn.com/%E9%A1%B9%E7%9B%AE/2019/01/08/kubernetes-api-and-operator-history.html) - v2017/01 v1.6 ThirdPartyResource - 2017/04 v1.7 CustomResourceDefinition - 2017/10 v1.9 CustomResourceValidation - 2018/04 v1.11 - crd subresources /status, /scale - multiple versions - redhat http://operatorhub.io/ - knative / https://github.com/keleustes/oslc-operator --- ### crd sdk - pattern/template - [kubebuilder](https://itnext.io/under-the-hood-of-kubebuilder-framework-ff6b38c10796) - controller-runtime/ controller-tools: controller-gen/... - code-generator > create kube api - [operator-sdk](https://itnext.io/under-the-hood-of-the-operator-sdk-eebc8fdeebbf) [code-generator](https://github.com/kubernetes/code-generator) - scale, upgrade, or backup - [metacontroller](https://metacontroller.app/) Lightweight Kubernetes controllers as a service --- #### kubebuilder ![kubebuilder](https://miro.medium.com/max/1587/1*N3hSTI-gSWvBxfyNkUN34Q.jpeg) --- #### operator-sdk ![operator-sdk](https://miro.medium.com/max/1587/1*IDWOCdEqZ3T8Fi3k3ApKxQ.jpeg) --- ### operator-sdk devel flow ![operator-sdk](https://coreos.com/sites/default/files/inline-images/operator-framework-1.png) --- ### operator framework - [到底 Operator Framework 用起來會長得如何?](https://blog.pichuang.com.tw/20190407-how-look-like-operator-framework-in-production/) ![operator framework](https://blog.pichuang.com.tw/images/operator-1.png) --- ### Operator Lifycycle Management ![operator-sdk](https://blog.pichuang.com.tw/images/operator-3.png) --- ### kubebuilder vs Operator SDK - Operator SDK also has support for Ansible and Helm operators, which make it easy to write operators without having to learn Go and if you already have experience with Ansible or Helm - Operator SDK includes integrations with the Operator Lifecycle Manager (OLM), which is a key component of the Operator Framework that is important to Day 2 cluster operations, like managing a live upgrade of your operator. - Operator SDK includes a scorecard subcommand that helps you understand if your operator follows best practices. - Operator SDK includes an e2e testing framework that simplifies testing your operator against an actual cluster. --- - Kubebuilder includes an envtest package that allows operator developers to run simple tests with a standalone etcd and apiserver. - Kubebuilder scaffolds a Makefile to assist users in operator tasks (build, test, run, code generation, etc.); Operator SDK is currently using built-in subcommands. Each has pros and cons. The SDK team will likely be migrating to a Makefile-based approach in the future. - Kubebuilder uses Kustomize to build deployment manifests; Operator SDK uses static files with placeholders. - Kubebuilder has recently improved its support for admission and CRD conversion webhooks, which has not yet made it into SDK. --- ### Informer list-watch [Kubernetes Informer 详解](https://www.kubernetes.org.cn/2693.html) / [理解 K8S 的设计精髓之 list-watch](http://wsfdl.com/kubernetes/2019/01/10/list_watch_in_k8s.html) / [理解 K8S 的设计精髓之 List-Watch机制和Informer模块](https://zhuanlan.zhihu.com/p/59660536) ![](https://www.kubernetes.org.cn/img/2017/09/20170914090122.jpg) --- ![](https://www.kubernetes.org.cn/img/2017/09/20170914090128.jpg) --- ![](https://www.kubernetes.org.cn/img/2017/09/20170914090134.jpg) --- ### kubebuilder ``` $ go mod init example.easystack.cn # go v1.11 $ kubebuilder init --domain my.domain ``` --- #### kubebuilder init ``` go mod tidy Running make... make which: no controller-gen in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/shawn/.local/bin:/home/shawn/bin) go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0 go: finding sigs.k8s.io/controller-tools/cmd/controller-gen v0.2.0 go: finding sigs.k8s.io/controller-tools/cmd v0.2.0 /home/shawn/go/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..." go fmt ./... go vet ./... go build -o bin/manager main.go Next: Define a resource with: $ kubebuilder create api ``` --- ``` config/ certmanager/ default/ manager/ rbac/ webhook/ Dockerfile hack main.go Makefile PROJECT ``` --- main.go ``` func main () { ... mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, LeaderElection: enableLeaderElection, }) ... // +kubebuilder:scaffold:builder ... // mgr.Start(ctrl.SetupSignalHandler()) } ``` --- #### kubebuilder create api ``` $ kubebuilder create api --group webapp --version v1 --kind Guestbook Create Resource [y/n] y Create Controller [y/n] y Writing scaffold for you to edit... api/v1/guestbook_types.go controllers/guestbook_controller.go Running make... ``` * api/v1/guestbook_types.go * controller/guestbook_controller.go --- #### kubebuilder apply crd ``` kubectl apply -f config/samples/ ``` ``` make docker-build docker-push IMG=<some-registry>/controller make deploy IMG=<some-registry>/controller ```

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully