Giter VIP home page Giter VIP logo

labs-k8s-operator's Introduction

kubernetes operator

credits

based on https://betterprogramming.pub/build-a-kubernetes-operator-in-10-minutes-11eec1492d30

Note: this repo is part of webofmars labs project. You can check other labs here https://github.com/webofmars/labs.

requirements

  • go version v1.17.9+
  • docker version 17.03+
  • kubectl version v1.11.3+
  • access to a Kubernetes v1.11.3+ cluster (I highly suggest using kind to set up your own local cluster, it’s very easy to use!).

setup

curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/$(go env GOOS)/$(go env GOARCH) && \
  chmod +x kubebuilder && mv kubebuilder /usr/local/bin/

or

asdf plugin add kubebuilder
asdf install

init our repo (step-1)

kubebuilder init --domain webofmars.com --repo webofmars.com/pizza

create CRDs (step 2)

kubebuilder create api --group pizza --version v1 --kind Pizza
go mod tidy
make generate

customize CRDs (step 3)

  • edit the file api/v1/pizza_types.go

customize the controller (step 4)

  • edit the file controllers/pizza_controller.go and inseert your own logic for a pizza

generate the manifests (step 5)

make manifests

install the CRDs (step 6)

NB: you need a working kubectl connected to your dev cluster in order to test it.

make install
kubectl get crds

run the controller (step 7)

Run the controller locally (it can later be packaged through helm or other means and run in a the kubernetes cluster).

make run

create your first pizza (step 8)

  • edit file config/samples/pizza_v1_pizza.yaml to match a valid pizza spec as defined in pizza_types.go
kubectl apply -f config/samples/pizza_v1_pizza.yaml

after a while you should see the controller reconcile loop pass over the pizza object and modify it if you instructed to do so in the controller (check step 4 code)

package the controller (step 9)

make docker-build
make docker-push

going further

You can now add some items to spec and status to reflect a valid pizza from your logic and play with thee controller

labs-k8s-operator's People

Contributors

fredleger avatar

Watchers

James Cloos avatar  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.