This is an OpenShift operator to run and rule Infinispan.
- go
- Docker
- A running OKD cluster with
system:adminaccess, or a Minikube cluster.
- Add the source under any folder:
$ git clone https://github.com/infinispan/infinispan-operator.git
- Change to the operator source directory.
$ cd ./infinispan-operator
- Review the available build targets.
$ make
- Run any build target. For example, compile and build the Infinispan Operator with:
$ make build
- (Optional) The docker image can be build running:
$ make image IMAGE=image_name TAG=image_tag
or if your docker version doesn't have multistage build
$ make image IMAGE=image_name TAG=image_tag MULTISTAGE=NO
There also a Cekit build environment under build/cekit
$ cekit build --overrides "{version: <version_default_is_latest>}" docker
- Start OKD. For example:
$ oc cluster up
- Specify the Kube configuration for the OKD cluster.
$ export KUBECONFIG=/path/to/admin.kubeconfig
- Create the Infinispan operator on OKD.
- Use the public jboss/infinispan-operator image:
$ make run
- It's possible to change a 'default' project name to the custom defined:
$ export PROJECT_NAME=myproject
- Use a locally built image:
$ make run-local
- Open a new terminal window and create an Infinispan cluster with three nodes:
$ oc apply -f deploy/cr/minimal/cr_minimal.yaml
infinispan.infinispan.org/example-infinispan configured
- Watch the pods start until they start running.
$ oc get pods -w
NAME READY STATUS RESTARTS AGE
example-infinispan-54c66fd755-28lvx 0/1 ContainerCreating 0 4s
example-infinispan-54c66fd755-7c4zc 0/1 ContainerCreating 0 4s
example-infinispan-54c66fd755-8gbxf 0/1 ContainerCreating 0 5s
infinispan-operator-69d7d4469d-f62ws 1/1 Running 0 3m
example-infinispan-54c66fd755-8gbxf 1/1 Running 0 8s
example-infinispan-54c66fd755-7c4zc 1/1 Running 0 8s
example-infinispan-54c66fd755-28lvx 1/1 Running 0 8s
- Configure Minikube virtual machine. You only need to do this once:
$ make minikube-config- Start Minikube:
$ make minikube-start- Build the operator and run it locally:
$ make minikube-run-local- Open a new terminal window and create an Infinispan cluster with three nodes:
$ kubectl apply -f deploy/cr/minimal/cr_minimal.yaml -n local-operators- Watch the pods start until the start running
$ kubectl get pods -w
NAME READY STATUS RESTARTS AGE
example-infinispan-0 1/1 Running 0 8m29s
example-infinispan-1 1/1 Running 0 5m53s
example-infinispan-2 1/1 Running 0 5m36sNow it's time to have some fun. Let's see the Infinispan operator in action.
Change the cluster size in deploy/cr/minimal/cr_minimal.yaml and then apply it again. The Infinispan operator scales the number of nodes in the cluster up or down.
The Infinispan Operator creates clusters based on custom resource definitions that specify the number of nodes and configuration to use.
Infinispan resources are defined in infinispan-types.go.
Creates Infinispan clusters:
apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
# Sets a name for the Infinispan cluster.
name: example-infinispan-minimal
spec:
# Sets the number of nodes in the cluster.
replicas: 3Infinispan operator has other capabilities. Check the official operator documentation for more details.
Use the test target to test the Infinispan Operator on a specific OKD cluster.
To test a locally running cluster, run:
$ make test
Alternatively, pass KUBECONFIG to specify cluster access:
$ make test KUBECONFIG=/path/to/openshift.local.clusterup/openshift-apiserver/admin.kubeconfig
There are two categories for submissions to operatorhub.io, upstream and community.
- Upstream submissions should run on vanilla Kubernetes, such as Minikube.
- Community submissions should run on Red Hat OpenShift. See the community-operators site for minimum requirements.
Testing submissions is a two-step process:
- Push the operator to a quay.io application repository. Details on this will be provided ASAP.
- Test the operator on Minikube or OpenShift.
- Upstream submissions, see Testing Upstream Submissions with Minikube.
- Community submissions, see Testing Community Submissions with OpenShift.
Modifying the Namespace: The test procedures in this README assume that the operator is installed in the local-operators namespace.
To use a different namespace, you must modify the YAML descriptor files and make calls. For descriptors, replace local-operators with your desired namespace. For scripts, add your desired namespace as an environment variable; for example, make NAMESPACE=my_namespace ${make_target}.
The operatorhub/minikube folder contains a Makefile and several make targets that you can use to test upstream submissions of the Infinispan Operator.
Minikube does not provide the Operator Lifecycle Manager (OLM) and Operator Marketplace components. You must install them before you can install and test the Infinispan Operator.
- Ensure
minikubeis in your$PATH. - Run the appropriate
maketarget. For example, run themake alltarget as follows:
$ cd operatorhub/minikube
$ make all
The Makefile uses a minikube profile with an optimal configuration for testing the Infinispan Operator.
By default, the profile uses Virtual Box VM drivers. Use the VMDRIVER argument to specify a different hypervisor.
make VMDRIVER=${vm_driver_name} ${make_target}to specify different VM drivers.make VMDRIVER= ${make_target}if you do not want to specify VM drivers (pass an empty value).
See the Minikube docs for information about supported hypervisors.
-
make allruns each make target in sequence. -
make testinstantiates an Infinispan cluster with the upstream submission. Note that themake testtarget requires the Infinispan CRD and the Infinispan Operator must be running.Check that the Infinispan CRD is installed:
$ kubectl get crd NAME CREATED AT infinispans.infinispan.org 2019-04-03T09:15:48Z
Check that the Infinispan Operator is running:
$ kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE local-operators infinispan-operator-5549f446f-9mqkp 1/1 Running 0 44s
-
make cleanremoves the example Infinispan custom resource and Infinispan Operator from the Kubernetes cluster. -
make deletedestroys the Minikube virtual machine.
no matches for kind errors can occur when Kubernetes elements are not installed correctly, such as when descriptors are installed too quickly for changes to take effect.
First, you need to identify the make target that failed.
-
Example where the
make install-olmtarget did not complete:+ kubectl create -f deploy/upstream/manifests/latest/ unable to recognize \ "deploy/upstream/manifests/latest/0000_50_olm_11-olm-operators.catalogsource.yaml": \ no matches for kind "CatalogSource" in version "operators.coreos.com/v1alpha1" -
Example where the
make install-operatortarget did not complete:+ kubectl apply -f https://raw.githubusercontent.com/infinispan/infinispan-operator/0.2.1/deploy/cr/cr_minimal.yaml -n local-operators \ error: unable to recognize "https://raw.githubusercontent.com/infinispan/infinispan-operator/0.2.1/deploy/cr/cr_minimal.yaml": \ no matches for kind "Infinispan" in version "infinispan.org/v1"
To resolve the error and continue testing, do the following:
- Run the
maketarget again. Note that you might notice errors about existing elements but you can ignore them. - Verify pods are running. For example, run:
$ kubectl get pods --all-namespaces
- Open the
Makefileand determine which target is next in the sequence. For example, if errors occur for themake install-olmtarget, the next target in the sequence ismake checkout-marketplace. - Manually run the remaining
maketargets.
Test community submissions of the Infinispan Operator with either OpenShift 4 or OpenShift 3.11.
The operatorhub/openshift4 folder contains a Makefile and several make targets that you can use to test community submissions of the Infinispan Operator.
OpenShift 4 includes the Operator Lifecycle Manager (OLM) and Operator Marketplace components. You do not need to install them separately.
Before You Begin: You must have a running OpenShift 4 cluster with an oc client that is configured for the cluster. You must also be logged in with an administrator account.
Run the appropriate make target. For example, run the make all target as follows:
$ cd operatorhub/openshift4
$ make all
make alladds the Infinispan Operator to the OperatorHub, installs it in the defined namespace, and then instantiates an Infinispan cluster with the community submission.make install-operatorsourceadds the Infinispan Operator to the OperatorHub. You can then manually install the operator through the OperatorHub user interface in the OpenShift console.make testinstantiates an Infinispan cluster with the community submission.make cleanremoves the example Infinispan custom resource and Infinispan Operator from the Kubernetes cluster.
To create releases, run:
$ make DRY_RUN=false GITHUB_USERNAME=<...> REPLACES_RELEASE_NAME=N.M.O RELEASE_NAME=X.Y.Z SERVER_VERSION=a.b.c release
As a final step, the release script creates two PRs in operatorhub.io for the release to be included there. Once the PRs have been created, edit the description and add the PR form suggested here, marking those fields that apply.