Giter Club home page Giter Club logo

kubebuilder-controller's Introduction

Kubebuilder: Controllers, CRDs, and Operators

How to build custom controllers, the easy way.

To begin, clone (quickstart or kube builder book): https://book.kubebuilder.io/

For the impatient

The substantive part of this tutorial is in these two files:

  1. DEPLOYMENT-CONTROLLERRUNTIME.md
  2. REPLICAS-UPDATE-DEPLOYMENT.md

Runbooks

Not a tutorial based on theory. Just some basic developer workflow runbooks.

Runbook (startup)

Developer workflow for custom controllers

  1. Install custom types and generate code make install.
  2. Run controller (make run).
  3. Make changes to code while running controller.
  4. in new terminal, apply changes to cluster and note changes. kubectl apply -f config/samples.

Note that the apply will cause the Reconciler to "reconcile." So applying a change to the cluster will, for example, log any print/log statements in the controller's reconcile() function.

Sample Controller workflows

Workflows for developing custom CRDs and controllers (custom operators).

Log statement:

  1. Make change in guestbook controller's Reconcile code (add fmt.Println("henlo")).
  2. Run controller (make run).
  3. See the controller print "henlo" in the make run terminal window/tmux window.

Add labels imperatively and apply to cluster:

  1. Run controller (make run).
  2. Add labels to ./config/samples/webapp_v1_guestbook.yaml under metadata
metadata:
name: guestbook-sample
labels:
  is-awesome: totes
  is-bad: nopes
  1. apply to cluster: apply -f ./config/samples.
  2. Use CLI label selector. k get guestbook -l is-awesome=totes. You'll see guestbook crd.

Get guestbook CRD, its labels, its namespace ...

  1. Use Reconciler function in Controller to Get object properties from NamespacedName struct.
  2. Run controller (make run).
  3. Note changes

Create a basic Deployment

  • Use this document DEPLOYMENT-CONTROLLERRUNTIME.md
  • Topics covered: controller runtime pkg, client pkg, appsv1 pkg, etc
  • You'll learn how to navigate the Kubernetes API at pkg.go.dev

Specify a desired state (scaled replicas), and update Deployment

Create a basic Service ...

kubebuilder-controller's People

Contributors

abstractmachines avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.