Skip to content

This is equivalent to "Hello, World!" but for k8s operators.

Notifications You must be signed in to change notification settings

MustafaSaber/basicK8sOperator

Repository files navigation

K8s Operator

This is a simple k8s operator written in Go with operator framework. The idea is to watch a custom resource then make an nginx deployment with

  • Number of replicas.
  • Message to be served via nginx.

Deployment

Prerequisties

Create Your Image

To deploy the operator from the repo with your own docker image use

./build-deploy-operator-on-custer.sh example/k8s-operator:1.0

This script will build and publish image, then deploy the operator in the current loaded kubeconfig. P.S. This script login to docker using .docker-secret

Next steps will be in Testing Section

Use Existing Image

To deploy the operator with an existing image run

make deploy IMG=mustafasaber/custom-k8s-operator:v9.1.0

Deleting

To delete the deployment just run

make undeploy

Testing

To test the operator we apply a yaml file with the CR like this

k apply -f ./config/samples/_v1_onekind.yaml

And now you can have nginx service up and running, expose the service with

minikube service onekind-sample

About

This is equivalent to "Hello, World!" but for k8s operators.

Topics

Resources

Stars

Watchers

Forks