GithubHelp home page GithubHelp logo

gbaeke / kopf-example Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 5.0 6 KB

Simple Kubernetes operator with kopf

Python 97.01% Dockerfile 2.99%
kubernetes operator kubernetes-operator kopf python sample

kopf-example's Introduction

kopf-example

Simple Kubernetes operator with kopf

Make sure you install kopf and kubernetes client (pip install kopf kubernetes) Verify you can execute kopf on the command line Create the demowebs CRD with:

kubectl create -f crd.yaml

Run the operator with (in another terminal):

kopf run with_create.py

Create the custom resource with:

kubectl create -f demoweb.yaml

You can modify demoweb.yaml with a number of replicas and a path to a public git repository that contains an index.html.

Verify that the number of replicas were created:

kubectl get pods

Connect to a pod:

kubectl port-forward <pod_name> 8080:80

Browse to http://localhost:8080 to verify the content is served.

If you want to be able to modify the custom resource (e.g. change the number of replicas), run the with_update.py operator:

kopf run with_update.py

To run the operator in Kubernetes, build and push a container image with the provided Dockerfile. Next, deploy the operator with:

kubectl apply -f deploy_operator.yaml

Note:: before deploying the operator, create a service account that has the requires access rights

Blog post: https://blog.baeke.info/2020/01/26/writing-a-kubernetes-operator-with-kopf/

kopf-example's People

Contributors

gbaeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.