Commit e6121ba4 authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

Edit README.md

parent 6ac10350
Loading
Loading
Loading
Loading
+442 −56
Changes for README.md: 442 added lines, 56 removed lines.
Original line number Diff line number Diff line
# ocm-scheduler
# Hypo OCM Scheduler – Helm Chart

This Helm chart deploys the **Hypo OCM Scheduler** on an Open Cluster Management (OCM) Hub cluster and configures the managed clusters required for location-aware workload scheduling.

The chart provides an automated installation and cleanup process, including scheduler deployment, OCM ClusterSet configuration, managed cluster labeling, and location-based ClusterClaims.

## Getting started
## 1. Overview

To make it easy for you to get started with GitLab, here's a list of recommended next steps.
The Hypo OCM Scheduler extends the OCM environment with scheduling functionality based on cluster-specific attributes.

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
Each managed cluster is associated with a location through a custom `ClusterClaim` named `hypo.filter.location`. The scheduler can use this information to select an appropriate managed cluster for workload placement.

## Add your files
The Helm chart automates:

* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
- Deployment of the Hypo Scheduler controller.
- Creation of the HypoSchedulingManifest Custom Resource Definition (CRD).
- Creation of an OCM `ManagedClusterSet` and its namespace binding.
- Assignment of managed clusters to the configured ClusterSet.
- Creation of location-based ClusterClaims on the managed clusters.
- Configuration of the required Kubernetes RBAC permissions.
- Cleanup of scheduler-related resources during uninstallation.

The scheduler runs on the **OCM Hub cluster**, while location ClusterClaims are created on the corresponding managed clusters.

## 2. Helm Chart Structure

ocm-scheduler-chart/
├── Chart.yaml
├── values.yaml
├── crds/
│   └── hypo-crd.yaml
└── templates/
    ├── scheduler.yaml
    ├── managed-clusters-job.yaml
    └── cleanup-job.yaml

The chart consists of the following files:

Chart.yaml – Defines the Helm chart metadata and version.

values.yaml – Configures the scheduler image, replicas, ClusterSet, and managed clusters.

crds/hypo-crd.yaml – Defines the HypoSchedulingManifest Custom Resource Definition.

templates/scheduler.yaml – Deploys the scheduler controller, Kubernetes resources, and required RBAC.

templates/managed-clusters-job.yaml – Runs after installation or upgrade to assign managed clusters to the ClusterSet and configure their location ClusterClaims.

templates/cleanup-job.yaml – Runs before uninstallation to remove Hypo scheduling resources, ClusterClaims, ClusterSet membership labels, and the Hypo CRD.

The setup and cleanup Jobs are implemented as Helm hooks, allowing cluster configuration and cleanup to be performed automatically during the Helm release lifecycle.

## 3. Prerequisites

Before installing the chart, ensure that:

- A Kubernetes cluster is configured as an OCM Hub.
- The required OCM components are installed and running.
- The target managed clusters are registered and available in OCM.
- Helm 3 and `kubectl` are installed.
- The Hub can access the Hypo Scheduler container image.
- Kubeconfig files are available for the managed clusters.
- The installation namespace exists.

Create the namespace if necessary:

```bash
kubectl create namespace hypo-scheduler-system
```

Verify the registered managed clusters:

```bash
kubectl get managedclusters
```

Both managed clusters should report `JOINED=True` and `AVAILABLE=True`.

## 4. Chart Configuration (`values.yaml`)

The chart is configured through `values.yaml`.

Example configuration:

```yaml
scheduler:
  replicaCount: 1

  image:
    repository: registry.ubitech.eu/nsit/hypo-ocm-scheduler
    tag: v1
    pullPolicy: IfNotPresent

  imagePullSecrets:
    - name: ubitech-registry

clusterSet:
  enabled: true
  name: test

managedClusters:
  - name: managed-1
    location: managed-1
    kubeconfigSecretName: managed1-kubeconfig

  - name: managed-2
    location: managed-2
    kubeconfigSecretName: managed2-kubeconfig
```

### Scheduler configuration

| Parameter | Description |
|---|---|
| `scheduler.replicaCount` | Number of scheduler controller replicas. |
| `scheduler.image.repository` | Container registry and image repository. |
| `scheduler.image.tag` | Scheduler image version. |
| `scheduler.image.pullPolicy` | Kubernetes image pull policy. |
| `scheduler.imagePullSecrets` | Kubernetes Secrets used to authenticate to the image registry. |

### ClusterSet configuration

| Parameter | Description |
|---|---|
| `clusterSet.enabled` | Enables creation of the configured OCM ManagedClusterSet. |
| `clusterSet.name` | Name of the ManagedClusterSet to which the managed clusters will be assigned. |

### Managed cluster configuration

| Parameter | Description |
|---|---|
| `managedClusters[].name` | Name of the ManagedCluster registered on the OCM Hub. |
| `managedClusters[].location` | Location value assigned to the cluster through the `hypo.filter.location` ClusterClaim. |
| `managedClusters[].kubeconfigSecretName` | Name of the Kubernetes Secret containing the managed cluster kubeconfig. |

The `location` value is used by the scheduler when evaluating location-based scheduling requirements. It should match the location expected by the corresponding workload scheduling configuration.

## 5. Configure Access to Managed Clusters

The Helm setup and cleanup Jobs require access to the managed clusters to create and remove ClusterClaims.

If we deploy manually the Hlem chart and not from HypO, we need for each managed cluster, to create a Kubernetes Secret in the scheduler namespace containing its kubeconfig.

Example:

```bash
kubectl create secret generic managed1-kubeconfig \
  --from-file=kubeconfig=/home/ubuntu/managed1.yaml \
  -n hypo-scheduler-system

kubectl create secret generic managed2-kubeconfig \
  --from-file=kubeconfig=/home/ubuntu/managed2.yaml \
  -n hypo-scheduler-system
```

**Important:** The Secret data key must be named `kubeconfig`, as expected by the Helm Jobs.

Verify the Secrets:

```bash
kubectl get secrets -n hypo-scheduler-system
```

The Secret names must match the `kubeconfigSecretName` values in `values.yaml`.

### Private container registry

If the scheduler image is hosted in a private registry, configure an image pull Secret named `ubitech-registry` in the same namespace.

The name must match the `scheduler.imagePullSecrets` configuration.

Registry credentials and kubeconfig files should not be committed to GitLab.

## 5. Deploy the Scheduler

Navigate to the Helm chart directory:

```bash
cd ocm-scheduler-chart
```

Validate the chart:

```bash
helm lint .
```

Optionally inspect the generated Kubernetes manifests:

```bash
helm template hypo-scheduler . \
  -n hypo-scheduler-system
```

Install the chart:

```bash
helm install hypo-scheduler . \
  -n hypo-scheduler-system \
  --wait \
  --wait-for-jobs \
  --timeout 10m
```

The installation performs the following operations:

1. Creates the HypoSchedulingManifest CRD.
2. Deploys the Hypo Scheduler controller and required Kubernetes resources.
3. Creates the configured OCM ManagedClusterSet and ManagedClusterSetBinding.
4. Executes a Helm post-install Job to configure the managed clusters.
5. Assigns each managed cluster to the configured ClusterSet.
6. Creates the `hypo.filter.location` ClusterClaim on each managed cluster.

The installation completes successfully when the scheduler is ready and the post-install configuration Job finishes.

## 7. Verify the Deployment

### Check the Helm release

```bash
helm status hypo-scheduler \
  -n hypo-scheduler-system
```

Expected status:

```text
STATUS: deployed
```
cd existing_repo
git remote add origin https://labs.etsi.org/rep/osl/hypo/code/addons/ocm-scheduler.git
git branch -M main
git push -uf origin main

### Check the scheduler controller

```bash
kubectl get pods -n hypo-scheduler-system

kubectl get deployments -n hypo-scheduler-system
```

The scheduler controller should be running and available:

```text
hypo-scheduler-controller-manager   1/1
```

### Check the OCM ClusterSet

```bash
kubectl get managedclusterset

kubectl get managedclustersetbinding \
  -n hypo-scheduler-system
```

The configured ClusterSet (`test`) and its binding should exist.

### Check managed cluster membership

```bash
kubectl get managedclusters \
  -L cluster.open-cluster-management.io/clusterset
```

Expected result:

```text
NAME        JOINED   AVAILABLE   CLUSTERSET
managed-1   True     True        test
managed-2   True     True        test
```

### Check the location ClusterClaims

Assuming  we have the kubeconfig files for the managed clusters on the paths:
- /home/ubuntu/managed1.yaml
- /home/ubuntu/managed2.yaml
```bash
kubectl --kubeconfig=/home/ubuntu/managed1.yaml \
  get clusterclaim hypo.filter.location -o yaml

kubectl --kubeconfig=/home/ubuntu/managed2.yaml \
  get clusterclaim hypo.filter.location -o yaml
```

Verify that the ClusterClaims exist and contain the expected location values configured in `values.yaml`.

### Check the Hypo CRD

```bash
kubectl get crd \
  hyposchedulingmanifests.scheduling.hypo.eu
```

## Integrate with your tools
The CRD should exist.

* [Set up project integrations](https://labs.etsi.org/rep/osl/hypo/code/addons/ocm-scheduler/-/settings/integrations)
### Check scheduler logs

## Collaborate with your team
```bash
kubectl logs -n hypo-scheduler-system \
  deployment/hypo-scheduler-controller-manager
```

* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
Review the logs for startup or scheduling errors.

## Test and Deploy
These checks verify the deployment and configuration. To validate scheduling functionality itself, submit a HypoSchedulingManifest and verify that the scheduler selects the expected managed cluster and creates the corresponding ManifestWork.

Use the built-in continuous integration in GitLab.
## 8. Update the Deployment

* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
After modifying `values.yaml` or the Helm templates, upgrade the existing installation:

***
```bash
helm upgrade hypo-scheduler . \
  -n hypo-scheduler-system \
  --wait \
  --wait-for-jobs \
  --timeout 10m
```

# Editing this README
The Helm post-upgrade Job reapplies the managed cluster configuration, including ClusterSet membership and location ClusterClaims.

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
Verify the updated configuration using the checks in Section 7.

## Suggestions for a good README
## 9. Uninstall the Scheduler

Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
The chart includes a Helm `pre-delete` cleanup Job that removes scheduler-specific resources before Helm deletes the release.

## Name
Choose a self-explaining name for your project.
Uninstall:

```bash
helm uninstall hypo-scheduler \
  -n hypo-scheduler-system \
  --wait \
  --timeout 10m
```

The cleanup Job performs the following operations:

1. Deletes HypoSchedulingManifest resources.
2. Deletes scheduler-owned ManifestWorks.
3. Removes the `hypo.filter.location` ClusterClaims from the configured managed clusters.
4. Removes the managed clusters' ClusterSet membership labels.
5. Deletes the HypoSchedulingManifest CRD.

Helm then removes the chart-managed resources, including the scheduler controller, associated RBAC resources, ClusterSet, and ClusterSetBinding.

**Note:** Helm does not automatically remove CRDs installed through the chart's `crds/` directory. The cleanup Job explicitly deletes the HypoSchedulingManifest CRD.

The registered OCM ManagedClusters themselves are not deleted.

## 10. Verify the Uninstallation

### Confirm Helm release removal

```bash
helm list -n hypo-scheduler-system --all
```

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
The `hypo-scheduler` release should no longer appear.

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
### Confirm scheduler resources are removed

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
```bash
kubectl get all -n hypo-scheduler-system
```

No scheduler workloads should remain.

### Confirm ClusterSet removal

```bash
kubectl get managedclusterset test

kubectl get managedclustersetbinding test \
  -n hypo-scheduler-system
```

Both resources should return `NotFound`.

### Confirm membership labels are removed

```bash
kubectl get managedclusters \
  -L cluster.open-cluster-management.io/clusterset
```

Expected result:

```text
NAME        JOINED   AVAILABLE   CLUSTERSET
managed-1   True     True
managed-2   True     True
```

The ManagedClusters remain registered and available, but no longer belong to the scheduler's ClusterSet.

### Confirm ClusterClaim removal

```bash
kubectl --kubeconfig=/home/ubuntu/managed1.yaml \
  get clusterclaim hypo.filter.location

kubectl --kubeconfig=/home/ubuntu/managed2.yaml \
  get clusterclaim hypo.filter.location
```

Both commands should return `NotFound`.

### Confirm CRD removal

```bash
kubectl get crd \
  hyposchedulingmanifests.scheduling.hypo.eu
```

Expected result: `NotFound`.

### Confirm scheduler-owned ManifestWorks are removed

```bash
kubectl get manifestworks -A \
  -l scheduling.hypo.eu/owner
```

No scheduler-owned ManifestWorks should remain.

### Confirm manually created Secrets are preserved

```bash
kubectl get secrets -n hypo-scheduler-system
```

The managed cluster kubeconfig Secrets and image registry Secret should remain available for future installations.

## 11. Troubleshooting

### Installation fails during managed cluster configuration

Inspect the setup Job:

```bash
kubectl get jobs -n hypo-scheduler-system

kubectl logs -n hypo-scheduler-system \
  job/hypo-scheduler-configure-clusters
```

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Common causes include:

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
- Missing kubeconfig Secrets.
- Incorrect Secret data keys.
- Invalid or inaccessible managed cluster kubeconfigs.
- Insufficient permissions to modify ManagedClusters.
- Missing OCM `managedclustersets/join` authorization.

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
The setup Job requires both ManagedCluster patch permissions and authorization to join the configured ClusterSet.

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.

## Contributing
State if you are open to contributions and what your requirements are for accepting them.
## 12. Resource Lifecycle Summary

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
| Resource | Installation | Uninstallation |
|---|---|---|
| Hypo Scheduler controller | Created | Deleted |
| Scheduler RBAC | Created | Deleted |
| HypoSchedulingManifest CRD | Created | Deleted by cleanup Job |
| OCM ManagedClusterSet | Created | Deleted |
| ManagedClusterSetBinding | Created | Deleted |
| ManagedCluster membership labels | Applied | Removed |
| Location ClusterClaims | Created or updated | Deleted |
| Scheduler-owned ManifestWorks | Created during scheduling | Deleted by cleanup Job |
| Registered OCM ManagedClusters | Preserved | Preserved |
| Manually created kubeconfig Secrets | Reused | Preserved |
| Manually created registry Secret | Reused | Preserved |

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
**Important:** The current cleanup behavior assumes the configured ClusterSet, location ClusterClaims, and Hypo CRD are dedicated to this scheduler installation. Avoid sharing these resources with unrelated workloads or Helm releases, since the cleanup Job explicitly removes them.

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
---

## License
For open source projects, say how it is licensed.

## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Add the appropriate project license and copyright information here.
 No newline at end of file