diff --git a/content/kubernetes/deployment/openshift/openshift-cli.md b/content/kubernetes/deployment/openshift/openshift-cli.md index 6a0f40d7c6e..66ee639d575 100644 --- a/content/kubernetes/deployment/openshift/openshift-cli.md +++ b/content/kubernetes/deployment/openshift/openshift-cli.md @@ -1,7 +1,7 @@ --- -Title: Redis Enterprise Software on Kubernetes deployment with OpenShift CLI tools +Title: Deployment with OpenShift CLI for Redis Enterprise Software on Kubernetes linkTitle: OpenShift CLI -description: The operator and cluster can be installed via CLI tools +description: The Redis Enterprise operator and cluster can be installed via CLI tools OpenShift weight: 60 alwaysopen: false @@ -22,317 +22,229 @@ aliases: [ These are the steps required to set up a Redis Enterprise Software cluster with OpenShift. -Prerequisites: +## Prerequisites -1. An [OpenShift cluster installed](https://docs.openshift.com/container-platform/4.8/installing/index.html) at version 4.6 or higher, with at least three nodes (each meeting the [minimum requirements for a development installation]({{< relref "/rs/administering/designing-production/hardware-requirements.md" >}}) -1. The [kubectl package installed](https://kubernetes.io/docs/tasks/tools/install-kubectl/) at version 1.9 or higher -1. The [OpenShift cli installed](https://docs.openshift.com/container-platform/4.8/cli_reference/openshift_cli/getting-started-cli.html) +- [OpenShift cluster](https://docs.openshift.com/container-platform/4.8/installing/index.html) installed at version 4.6 or higher, with at least three nodes (each meeting the [minimum requirements for a development installation]({{< relref "/rs/administering/designing-production/hardware-requirements.md" >}})) +- [kubectl tool](https://kubernetes.io/docs/tasks/tools/install-kubectl/) installed at version 1.9 or higher +- [OpenShift CLI](https://docs.openshift.com/container-platform/4.8/cli_reference/openshift_cli/getting-started-cli.html) installed -## Step 1: Login +## Deploy the operator -1. Log in to your OpenShift account as a super admin so that you have access to all the default projects. -1. Create a new project, fill in the name and other details for the project, and click **Create**. +1. Create a new project. - ![getting-started-kubernetes-openshift-image1]( /images/rs/getting-started-kubernetes-openshift-image1.png ) - -1. Click on **admin** (upper right corner) and then **Copy Login command**. - - ![getting-started-kubernetes-openshift-image4]( /images/rs/getting-started-kubernetes-openshift-image4.png ) - -1. Paste the `login` command into your shell, for example: - - ```sh - oc login --token= --server=https:// + ```bash + oc new-project ``` -1. To verify that you are using the newly created project, run: +1. Verify that you are using the newly created project, run: - ```sh - oc project + ```bash + oc project ``` -This shifts to your project rather than the default project. You can confirm that you are in the correct project with `oc project`. - -## Step 2: Get deployment files - -Clone Kubernetes docs repository to get the deployment files: +1. Get deployment files by cloning the `redis-enterprise-k8s-docs` repository. -```sh -git clone https://github.com/RedisLabs/redis-enterprise-k8s-docs -``` - - + ```bash + git clone https://github.com/RedisLabs/redis-enterprise-k8s-docs + ``` -## Step 3: Prepare your yaml files +1. Apply the file `scc.yaml` file. -Let’s look at each yaml file to see what requires editing: + The scc ([Security Context Constraint](https://docs.openshift.com/container-platform/4.8/authentication/managing-security-context-constraints.html)) yaml defines security context constraints for the cluster for our project. We strongly recommend that you **not** change anything in this yaml file. -- [scc.yaml](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/openshift/scc.yaml) + ```bash + oc apply -f openshift/scc.yaml + ``` - The scc ([Security Context Constraint](https://docs.openshift.com/container-platform/4.8/authentication/managing-security-context-constraints.html)) yaml defines security context constraints for the cluster for our project. We strongly recommend that you **not** change anything in this yaml file. + You should receive the following response: - 1. Apply the file: + ```bash + oc adm policy add-scc-to-group redis-enterprise-scc system:serviceaccounts: + ``` - ```sh - oc apply -f redis-enterprise-k8s-docs/openshift/scc.yaml - ``` + You can see the name of your project with `oc project`. - You should receive the following response: +1. Deploy the OpenShift operator bundle. - ```sh - securitycontextconstraints.security.openshift.io “redis-enterprise-scc” configured - ``` + {{< warning >}}Changes to the `openshift.bundle.yaml` file can cause unexpected results.{{< /warning >}} - 1. To bind the scc to your project, replace with the project name, and run: + ```bash + oc apply -f openshift.bundle.yaml + ``` - ```sh - oc adm policy add-scc-to-group redis-enterprise-scc system:serviceaccounts: - ``` +1. Verify that your redis-enterprise-operator deployment is running, run: - You can see the name of your project with `oc project`. + ```bash + oc get deployment + ``` -- [openshift.bundle.yaml](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/openshift.bundle.yaml) - + A typical response will look like this: - The bundle file includes several declarations: + ```bash + NAME READY UP-TO-DATE AVAILABLE AGE + redis-enterprise-operator 1/1 1 1 0m36s + ``` - - rbac (Role-Based Access Control) defines who can access which resources. The Operator application requires these definitions to deploy and manage the entire Redis Enterprise deployment (all cluster resources within a namespace). These include declaration of rules, role and rolebinding. - - crd declaration creates a [CustomResourceDefinition](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions) for your Redis Enterprise Cluster resource. This provides another API resource that the k8s API server can use and the operator can manage in other deployments. - - operator deployment declaration creates the operator deployment that is responsible for managing the k8s deployment and lifecycle of a Redis Enterprise Cluster. Among many other responsibilities, it creates a [stateful set](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/) that runs the Redis Enterprise nodes as pods. The yaml contains the latest image tag representing the latest Operator version available. +## Create your Redis Enterprise cluster (REC) custom resource - {{< warning >}} -Changes to this file can cause unexpected results. - {{< /warning >}} +1. Apply the `RedisEnterpriseCluster` resource file ([rec_rhel.yaml](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/openshift/rec_rhel.yaml)). - 1. Apply the yaml file with: + You can rename the file to `.yaml`, but it is not required (the examples below will use `.yaml`). [Options for Redis Enterprise clusters]({{}}) has more info about the REC custom resource, or see the [Redis Enterprise cluster API](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_cluster_api.md) for a full list of options. - ```sh - oc apply -f openshift.bundle.yaml - ``` +1. Apply the custom resource file to create your Redis Enterprise cluster. - The command returns a confirmation response such as: + ```bash + oc apply -f .yaml + ``` - ```sh - role.rbac.authorization.k8s.io/redis-enterprise-operator created - serviceaccount/redis-enterprise-operator created - rolebinding.rbac.authorization.k8s.io/redis-enterprise-operator created - customresourcedefinition.apiextensions.k8s.io/redisenterpriseclusters.app.redis.com configured - deployment.apps/redis-enterprise-operator created - ``` + The operator typically creates the REC within a few minutes. - 1. To verify that your redis-enterprise-operator deployment is running, run: +1. Check the cluster status - ```sh - oc get deployment - ``` + ```bash + kubectl get pod + ``` - A typical response will look like this: + You should receive a response similar to the following: + + ```bash + | 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 | + ``` - ```sh - NAME READY UP-TO-DATE AVAILABLE AGE - redis-enterprise-operator 1/1 1 1 0m36s - ``` +## Configure the admission controller - - - - -- The [rec_rhel.yaml](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/openshift/rec_rhel.yaml) defines the configuration of the newly created resource: Redis Enterprise Cluster. You can rename the file to `your_cluster_name.yaml`, but it is not required. - - You can edit this yaml file for your requirements, but you can use the sample provided for testing, developement and quick start deployments. Here are the main fields you to review and edit: - - - name: “your_cluster_name” - For example “demo-cluster” - - nodes: number_of_nodes_in_the_cluster - Must be an [uneven number of 3 or more](https://redis.com/redis-enterprise/technology/highly-available-redis/) - - uiServiceType: service_type - Service type value can be either `ClusterIP` or `LoadBalancer`. This is an optional configuration based on [k8s service types](https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/). The default is `ClusterIP`. - - - storageClassName: “gp2“ - This specifies the [StorageClass](https://kubernetes.io/docs/concepts/storage/storage-classes/) used for the persistent disks in your nodes. For example, AWS uses “gp2” as a default, GKE uses “standard”, and Azure uses "default". - - - redisEnterpriseNodeResources: The [compute resources](https://docs.openshift.com/enterprise/3.2/dev_guide/compute_resources.html#dev-compute-resources) required for each node. - - limits – Specifies the maximum resources for a Redis node. - - requests – Specifies the minimum resources for a Redis node. - - For example: - - ```sh - limits - cpu: “4000m” - memory: 4Gi - requests - - cpu: “4000m” - memory: 4Gi - ``` - - The default is 4 cores (4000m) and 4GB (4Gi). - - {{< note >}} -[Resource limits should equal requests](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/topics.md#resource-limits-and-quotas). - {{< /note >}} - - ```sh - persistentSpec: - storageClassName: “gp2“ - ``` - - - redisEnterpriseImageSpec: This configuration controls the Redis Enterprise version used, and where it is fetched from. This is an optional field. The Operator automatically uses the matching RHEL image version for the release. - - ```sh - imagePullPolicy: IfNotPresent - repository: redislabs/redis - versionTag: 6.0.20-97 - ``` - - The version tag must be as it appears on your repository, such as on [DockerHub](https://hub.docker.com/r/redislabs/redis/). + ```bash + apiVersion: v1 + kind: Namespace + metadata: + labels: + namespace-name: staging + name: staging + ``` -## Step 4: Create your Cluster +1. Patch the webhook spec with the `namespaceSelector` field. + ```bash + cat > modified-webhook.yaml <}}) and [database options]({{}}). -## Step 5: Create a database + Example: + ```bash + cat << EOF > /tmp/redis-enterprise-database.yml + apiVersion: app.redislabs.com/v1alpha1 + kind: RedisEnterpriseDatabase + metadata: + name: redis-enterprise-database + spec: + memorySize: 100MB + EOF + ``` -To create your database: +1. Apply the newly created REDB resource -1. Apply port forwarding to your Cluster: - - ```sh - oc port-forward your_cluster_name-0 8443:8443 + ```bash + oc apply -f /tmp/redis-enterprise-database.yml ``` - {{< note >}} -- your_cluster_name-0 is one of your cluster pods. Consider running the port-forward command in the background. -- The Openshift UI provides tools for creating additional routing options, including external routes. These are covered in [RedHat Openshift documentation](https://docs.openshift.com/container-platform/4.8/networking/ingress-operator.html). - {{< /note >}} - - Next, create your database. - -1. Open a browser window and navigate to the Redis Enterprise admin console at: `localhost:8443` - - ![getting-started-kubernetes-openshift-image5]( /images/rs/getting-started-kubernetes-openshift-image5.png ) - -1. To get your password from the OpenShift management console, go `Workloads > Secrets > your_cluster_name`, select your project name, and select **Reveal Secret**. - - {{< warning >}} -Do not change the default admin user password in the Redis Enterprise admin console. -Changing the admin password can cause unextpected results in your K8s deployment. - {{< /warning >}} - - ![getting-started-kubernetes-openshift-image3]( /images/rs/getting-started-kubernetes-openshift-image3.png ) - -1. Continue with the [instructions to create your database]({{< relref "/rs/administering/creating-databases/_index.md" >}}). +## More info -{{< note >}} -To conduct the Ping test through Telnet, you can create a new route to the new database port as described above for the UI port. After you create your database, go to the Openshift management console, select your project name, and go to `Applications > Services`. Two new services are shown that represent the database along with their IP and port information, similar to the screenshot below. -{{< /note >}} +- [Options for Redis Enterprise clusters (REC)]({{}}) +- [Redis Enterprise cluster API](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_cluster_api.md) +- [Options for Redis Enterprise databases (REDB)]({{}}) +- [Redis Enterprise database API](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_database_api.md) -![getting-started-kubernetes-openshift-image6]( /images/rs/getting-started-kubernetes-openshift-image6.png )