|
| 1 | +# Deploying kube-opex-analytics on Kubernetes and OpenShift |
| 2 | + |
| 3 | +- [Requirements](#requirements) |
| 4 | +- [Deployment Methods](#deployment-methods) |
| 5 | +- [Installation with Kustomize (Default Settings)](#installing-with-kustomize-default-settings) |
| 6 | +- [Customizing the Installation with Helm](#customizing-the-installation-with-helm) |
| 7 | +- [Accessing the Web Interface](#accessing-the-web-interface) |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +`kube-opex-analytics` requires read-only access to the following Kubernetes API endpoints: |
| 12 | + |
| 13 | +- `/api/v1` |
| 14 | +- `/apis/metrics.k8s.io/v1beta1` (provided by the [Kubernetes Metrics Server](https://github.com/kubernetes-sigs/metrics-server)). |
| 15 | + |
| 16 | + |
| 17 | +### Installing Kubernetes Metrics Server (Skip if using OpenShift) |
| 18 | + |
| 19 | +To install the Kubernetes Metrics Server, run the following command: |
| 20 | + |
| 21 | +```shell |
| 22 | +kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml |
| 23 | +``` |
| 24 | + |
| 25 | +## Deployment methods for Kubernetes |
| 26 | +`kube-opex-analytics` can be installed on a Kubernetes cluster using one of the following methods: |
| 27 | + |
| 28 | +* [kubectl + Kustomize](#Installing-with-Kustomize-Default-Settings) - Quick installation with default settings. |
| 29 | +* [Helm](#Customizing-the-Installation-with-Helm) - For more advanced customization. |
| 30 | + |
| 31 | +## Downloading the Deployment Artifacts |
| 32 | +Clone the repository and navigate to the main folder: |
| 33 | + |
| 34 | +```shell |
| 35 | +git clone https://github.com/rchakode/kube-opex-analytics.git --depth=1 |
| 36 | +cd kube-opex-analytics |
| 37 | +``` |
| 38 | + |
| 39 | +## Installing with Kustomize (Default Settings) |
| 40 | + |
| 41 | +This approach provides a quick way to deploy kube-opex-analytics using the default settings (see [`kustomize/kube-opex-analytics-config.yaml`](kustomize/kube-opex-analytics-config.yaml)). |
| 42 | + |
| 43 | +If these default settings do not meet your requirements, consider using the [Helm-based installation]((#customizing-the-installation-with-helm)) described below, which offers greater customization options. |
| 44 | + |
| 45 | +### Default Settings: |
| 46 | +- A persistent volume with a `1Gi` storage request. |
| 47 | +- The Kubernetes distribution is **not OpenShift**, as OpenShift requires additional SCC settings. |
| 48 | +- The pod is configured with security contexts that allow UID `4583` and GID `4583` inside the container. |
| 49 | + |
| 50 | +### Installation Steps |
| 51 | +Follow these steps to install kube-opex-analytics using Kustomize: |
| 52 | + |
| 53 | +```shell |
| 54 | +# Create the installation namespace if it does not exist |
| 55 | +kubectl create ns kube-opex-analytics |
| 56 | + |
| 57 | +# Create kube-opex-analytics resources |
| 58 | +kubectl -n kube-opex-analytics apply -k ./manifests/kustomize |
| 59 | + |
| 60 | +# Check that the status of the pod and wait that it starts |
| 61 | +kubectl -n kube-opex-analytics get po -w |
| 62 | + |
| 63 | +# If not pod is found, check events for additional information. |
| 64 | +kubectl -n kube-opex-analytics get ev |
| 65 | +``` |
| 66 | + |
| 67 | +## Customizing the Installation with Helm |
| 68 | + |
| 69 | +This approach is recommended when deploying on **OpenShift** or when advanced configuration is required. |
| 70 | + |
| 71 | +Customization is done by modifying the Helm values file: [`./manifests/helm/values.yaml`](./manifests/helm/values.yaml). |
| 72 | + |
| 73 | +### Common Customizations |
| 74 | + |
| 75 | +Below are some frequently used customizations: |
| 76 | + |
| 77 | +- **Use `emptyDir` for local testing** |
| 78 | + Set `.dataVolume.persist` to `false`. |
| 79 | + |
| 80 | +- **Enable deployment on OpenShift** |
| 81 | + Set `.securityContext.openshift` to `true`. This binds the SCC `nonroot-v2` to the `kube-opex-analytics` service account. |
| 82 | + If `emptyDir` is enabled, the SCC `hostaccess` is also bound to the service account. |
| 83 | + |
| 84 | +- **Customize CPU and memory requests** |
| 85 | + Adjust `.resources.requests.cpu` and `.resources.requests.memory` as needed. |
| 86 | + |
| 87 | +- **Customize the integration with Kubernetes** |
| 88 | +Set the different environment variables under the value `.envs`. See the [documentation of available configuration variables](./configuration-settings.md) |
| 89 | + |
| 90 | +### Installation Steps |
| 91 | + |
| 92 | +The installation consists of the following steps. The installation namespace (`kube-opex-analytics`) is created it does not exist. |
| 93 | + |
| 94 | +```shell |
| 95 | +# Create the installation namespace if it does not exist |
| 96 | +kubectl create ns kube-opex-analytics |
| 97 | + |
| 98 | +# Create kube-opex-analytics resources |
| 99 | +helm upgrade -n kube-opex-analytics --install kube-opex-analytics manifests/helm/ |
| 100 | + |
| 101 | +# Check that the status of the pod and wait that it starts |
| 102 | +kubectl -n kube-opex-analytics get po -w |
| 103 | + |
| 104 | +# If not pod is found, check events for additional information. |
| 105 | +kubectl -n kube-opex-analytics get ev |
| 106 | +``` |
| 107 | + |
| 108 | +## Get Access to the kube-opex-anakytics's Web Interface |
| 109 | +The deployment create an HTTP service named `kube-opex-analytics` on port `80` in the selected namespace. This service provides access to the built-in `kube-opex-analytics` dashboard. |
0 commit comments