Skip to content

Latest commit

 

History

History

application-scaler

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Sample operator build with kubebuilder

This repo contains a sample operator build by using toolkit provided by the Kubebuilder framework. The idea is to create a simplified version of Kubenetes Deployment, and call it AppScaler.

Prerequisites

  1. Kubernetes 1.17+ / Openshift 3.11+ cluster
  2. Unpack and install oc binary - here
  3. Golang 1.13
  4. Kubebuilder 2.0.0

Install

  1. Deploy a cluster
  1. Install golang
  2. Install kubebuilder

Steps to create a CR

We need to scaffold our operator code with kubebulder. Recommend to have a look at kubebuilder Getting Started to get a grasp.

kubebuilder init --domain example.com --license apache2
kubebuilder create api --group deploy --version v1 --kind AppScaler

This will generate our initial project structure, similar to one hosted in this repo. Notice initial template for our CR in the ./config/samples directory. You may edit it at any moment to match the CR specification in the appscaler_types, and then deploy it in your cluster.

CR - example.com/v1.AppScaler

apiVersion: sample.example.com/v1
kind: AppScaler
metadata:
  name: appscaler-sample
  namespace: test
spec:
  replicas: 2
  image: "docker.io/busybox"
  command: ["sleep", "10000"]

Executing our cutstom controller code locally

make
make manifests
make install
make run

Create a sample CR

oc create -f ./samples

Sources