Custom Operator (don't know anything)

No comments
Controller Runtime: The Kubernetes controller-runtime Project is a set of go libraries for building Controllers Operator SDK: The Operator SDK is a framework that uses the controller-runtime library to make writing operators easier 

https://sdk.operatorframework.io/docs/building-operators/ansible/quickstart/
https://sdk.operatorframework.io/docs/building-operators/ansible/tutorial/
https://sdk.operatorframework.io/docs/building-operators/ansible/reference/dependent-watches/
https://docs.openshift.com/container-platform/4.7/operators/operator_sdk/ansible/osdk-ansible-inside-operator.html


https://itnext.io/a-practical-kubernetes-operator-using-ansible-an-example-d3a9d3674d5b
https://two-oes.medium.com/building-custom-ansible-based-operator-for-openshift-4-ec681fa0466d




Example:

operator-sdk init --domain operator.redhatgov.io --plugins ansible

operator-sdk create api --group workshops --version v1alpha1 --kind Workshop --generate-role


It will create some directory structure(defaults file will be available)



Creating CRD:

kubectl create -f config/crd/bases/workshops.operator.redhatgov.io_workshops.yaml


Run custom Operator:
command: make deploy


create custom resource now
-----

apiVersion: workshops.operator.redhatgov.io/v1alpha1

#workshops.operator.redhatgov.io/v1alpha1

kind: Workshop

metadata:

  name: example-workshop

spec:

  # Add fields here

  cr_my_replicas: 1



kubectl create -f config/crd/bases/workshops_v1_workshop_cr.yaml

you can check logs of custom - operator

kubectl logs -f workshop-controller-manager-9f6ff675b-rbcqw -n workshop-system



In RBAC role.yaml
I updated below

### added by prakash ###

  - apiGroups:

      - "*"

    resources:

      - "*"

    verbs:

      - "*"






No comments :

Post a Comment