Deployment with OpenShift CLI for Redis Enterprise for Kubernetes
Use these steps to set up a Redis Enterprise Software cluster with OpenShift.
Prerequisites
- OpenShift cluster with at least 3 nodes (each meeting the minimum requirements for a development installation)
- OpenShift CLI
To see which version of Redis Enterprise for Kubernetes supports your OpenShift version, see Supported Kubernetes distributions.
Deploy the operator
Create a new project.
oc new-project <your-project-name>Verify the newly created project.
oc project <your-project-name>Get the deployment files.
git clone https://github.com/RedisLabs/redis-enterprise-k8s-docsDeploy the OpenShift operator bundle.
Note:If you are using version 6.2.18-41 or earlier, you must apply the security context constraint before the operator bundle.oc apply -f openshift.bundle.yamlWarning -Changes to theopenshift.bundle.yamlfile can cause unexpected results.Verify that your
redis-enterprise-operatordeployment is running.oc get deploymentA typical response looks like this:
NAME READY UP-TO-DATE AVAILABLE AGE redis-enterprise-operator 1/1 1 1 0m36s
Install security context constraint
The Redis Enterprise pods must run in OpenShift with privileges set in a Security Context Constraint. This grants the pod various rights, such as the ability to change system limits or run as a particular user.
Apply the file
scc.yamlfile.Warning -Do not edit this file.oc apply -f openshift/scc.yamlYou should receive the following response:
securitycontextconstraints.security.openshift.io "redis-enterprise-scc-v2" configuredReleases before 6.4.2-6 use the earlier version of the SCC, named
redis-enterprise-scc.Provide the operator permissions for the pods.
oc adm policy add-scc-to-user redis-enterprise-scc-v2 \ system:serviceaccount:<my-project>:<rec>
If you are using version 6.2.18-41 or earlier, add additional permissions for your cluster.
oc adm policy add-scc-to-user redis-enterprise-scc-v2 \
system:serviceaccount:<my-project>:redis-enterprise-operator
You can check the name of your project using the oc project command. To replace the project name, use oc edit project myproject. Replace rec with the name of your Redis Enterprise cluster, if different.
Create a Redis Enterprise cluster custom resource
Apply the
RedisEnterpriseClusterresource file (rec_rhel.yaml).You can rename the file to
<your_cluster_name>.yaml, but it is not required. Examples below use<rec_rhel>.yaml. Options for Redis Enterprise clusters has more info about the Redis Enterprise cluster (REC) custom resource, or see the Redis Enterprise cluster API for a full list of options.Note:Each Redis Enterprise cluster requires at least 3 nodes. Single-node RECs are not supported.Apply the custom resource file to create your Redis Enterprise cluster.
oc apply -f <rec_rhel>.yamlThe operator typically creates the REC within a few minutes.
Check the cluster status.
oc get podYou should receive a response similar to the following:
| NAME | READY | STATUS | RESTARTS | AGE | | -------------------------------- | ----- | ------- | -------- | --- | | rec-name-0 | 2/2 | Running | 0 | 1m | | rec-name-1 | 2/2 | Running | 0 | 1m | | rec-name-2 | 2/2 | Running | 0 | 1m | | rec-name-controller-x-x | 1/1 | Running | 0 | 1m | | Redis-enterprise-operator-x-x | 1/1 | Running | 0 | 5m |
Configure the admission controller
Verify the
admission-tlssecret exists.kubectl get secret admission-tlsThe output should look similar to
NAME TYPE DATA AGE admission-tls Opaque 2 2m43sSave the certificate to a local environment variable.
CERT=`kubectl get secret admission-tls -o jsonpath='{.data.cert}'`Create a Kubernetes validating webhook, replacing
<namespace>with the namespace where the REC was installed.The
webhook.yamltemplate can be found in redis-enterprise-k8s-docs/admissionsed 's/OPERATOR_NAMESPACE/<namespace>/g' webhook.yaml | kubectl create -f -Create a patch file for the Kubernetes validating webhook.
cat > modified-webhook.yaml <<EOF webhooks: - name: redisenterprise.admission.redislabs clientConfig: caBundle: $CERT admissionReviewVersions: ["v1beta1"] EOFPatch the webhook with the certificate.
kubectl patch ValidatingWebhookConfiguration \ redis-enterprise-admission --patch "$(cat modified-webhook.yaml)"
Limit the webhook to relevant namespaces
If not limited, the webhook intercepts requests from all namespaces. If you have several REC objects in your Kubernetes cluster, limit the webhook to the relevant namespaces. If you aren’t using multiple namespaces, skip this step.
Verify your namespace is labeled and the label is unique to this namespace, as shown in the next example.
apiVersion: v1 kind: Namespace metadata: labels: namespace-name: staging name: stagingPatch the webhook spec with the
namespaceSelectorfield.cat > modified-webhook.yaml <<EOF webhooks: - name: redisenterprise.admission.redislabs namespaceSelector: matchLabels: namespace-name: staging EOFApply the patch.
oc patch ValidatingWebhookConfiguration \ redis-enterprise-admission --patch "$(cat modified-webhook.yaml)"
For releases before 6.4.2-4, use this command instead:
sh
oc patch ValidatingWebhookConfiguration \
redb-admission --patch "$(cat modified-webhook.yaml)"
The 6.4.2-4 release introduces a new ValidatingWebhookConfiguration to replace redb-admission. See the 6.4.2-4 release notes.
Verify admission controller installation
Apply an invalid resource as shown below to force the admission controller to reject it. If it applies successfully, the admission controller is not installed correctly.
oc apply -f - << EOF
apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
name: redis-enterprise-database
spec:
evictionPolicy: illegal
EOF
You should see this error from the admission controller webhook redisenterprise.admission.redislabs.
Error from server: error when creating "STDIN": admission webhook "redisenterprise.admission.redislabs" denied the request: eviction_policy: u'illegal' is not one of [u'volatile-lru', u'volatile-ttl', u'volatile-random', u'allkeys-lru', u'allkeys-random', u'noeviction', u'volatile-lfu', u'allkeys-lfu']
Create a Redis Enterprise database custom resource
The operator uses the instructions in the Redis Enterprise database (REDB) custom resources to manage databases on the Redis Enterprise cluster.
Create a
RedisEnterpriseDatabasecustom resource.This example creates a test database. For production databases, see creating a database and database options.
cat << EOF > /tmp/redis-enterprise-database.yml apiVersion: app.redislabs.com/v1alpha1 kind: RedisEnterpriseDatabase metadata: name: redis-enterprise-database spec: memorySize: 100MB EOFApply the newly created REDB resource.
oc apply -f /tmp/redis-enterprise-database.yml