h2. POC steps
* Use operator-sdk to do it.
{code:java} operator-sdk olm-catalog gen-csv --csv-version 0.0.1 --csv-config memcached-operator.0.0.1.clusterserviceversion.yaml {code}
* Update the file created regards the missing information and also its details.
{code:java} apiVersion: operators.coreos.com/v1alpha1 kind: ClusterServiceVersion metadata: annotations: capabilities: Basic Install name: memcached-operator.v0.0.1 namespace: memcached-operator spec: apiservicedefinitions: {} customresourcedefinitions: owned: - kind: Memcached name: memcacheds.cache.example.com version: v1alpha1 description: Operator Memcached Desc displayName: Memcached Operator description: Operator Camila description displayName: Memcached Operator install: spec: deployments: - name: memcached-operator spec: replicas: 1 selector: matchLabels: name: memcached-operator strategy: {} template: metadata: labels: name: memcached-operator spec: containers: - command: - memcached-operator env: - name: WATCH_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: OPERATOR_NAME value: memcached-operator image: cmacedo/memcached-operator:v0.0.1 imagePullPolicy: Always name: memcached-operator resources: {} serviceAccountName: memcached-operator permissions: - rules: - apiGroups: - "" resources: - pods - services - endpoints - persistentvolumeclaims - events - configmaps - secrets verbs: - '*' - apiGroups: - "" resources: - namespaces verbs: - get - apiGroups: - apps resources: - deployments - daemonsets - replicasets - statefulsets verbs: - '*' - apiGroups: - monitoring.coreos.com resources: - servicemonitors verbs: - get - create - apiGroups: - apps resourceNames: - memcached-operator resources: - deployments/finalizers verbs: - update - apiGroups: - cache.example.com resources: - '*' verbs: - '*' serviceAccountName: memcached-operator strategy: deployment installModes: - supported: true type: OwnNamespace - supported: true type: SingleNamespace - supported: false type: MultiNamespace - supported: true type: AllNamespaces maturity: alpha provider: name: Camila, Inc version: 0.0.1 keywords: - memcached - app maintainers: - email: corp@example.com name: Some Corp labels: alm-owner-enterprise-app: memcached-operator alm-status-descriptors: memcached-operator.v0.0.1 {code}
* Create the namespace memcached-operator (oc new-project memcached-operator )
* Add ClusterServiceVersion
It will add the operator in the Developer Catalogue
{code:java} $ kubectl apply -f memcachedoperator.0.0.1.csv.yaml {code}
* Add CRD - ( Customer Resource Definition) It will add the type of the operator in the cluster/namespace
{code:java} kubectl create -f deploy/crds/cache_v1alpha1_memcached_crd.yaml {code}
* Add the RBAC rules created for the operator
{code:java} $ kubectl create -f deploy/service_account.yaml $ kubectl create -f deploy/role.yaml $ kubectl create -f deploy/role_binding.yaml {code}
* Create the following resources and then apply them.
{code:java}
apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: memcached-operator namespace: memcached-operator spec: displayName: Memcached Operator image: "" publisher: community-operators sourceType: grpc {code}
{code:java} apiVersion: operators.coreos.com/v1alpha2 kind: OperatorGroup metadata: name: memcached-operator namespace: memcached-operator spec: serviceaccount: memcached-operator targetNamespaces: - memcached-operator {code}
{code:java} apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: memcached-operator namespace: memcached-operator spec: name: memcached-operator source: memcached-operator sourceNamespace: memcached-operator startingCSV: memcached-operator.0.0.1 installPlanApproval: Automatic channel: alpha {code} |
|