Helm Chart as Operator
Scaffold the new operator
create a new directory on your machine, for instance : $HOME/vis-helm
operator-sdk init --domain com.redhat --plugins helm
Generate an API
Le’s create an API for our operator :
operator-sdk create api --group operators --version v1 --kind VisitorSite
Copy Helm Chart sample
In your new project you have a folder : helm-charts/visitorsite
, delete the content and replace it with the content from $TUTORIAL_HOME/apps/helm
Run your operator locally
Be sure to be connected to a Kubernetes cluster and then run
make install run
Apply a Custom Resource
You can now apply a custom resource
apiVersion: operators.com.redhat/v1
kind: VisitorSite
metadata:
name: visitorsite-sample
spec:
backend:
size: 1
frontend:
title: Operator Deployed Visitors Site
kubectl apply -f $TUTORIAL_HOME/apps/cr/visitorsite-helm.yml
Check the pods getting created :
kubectl get pods
NAME READY STATUS RESTARTS AGE
mysql-86c559bb7f-kjjvt 1/1 Running 0 28h
visitors-backend-7489bb97dd-wggkt 1/1 Running 0 28h
visitors-frontend-86df47fffc-d2bgl 1/1 Running 0 28h