# Management Overview

> Octelium documentation. Canonical page: <https://octelium.com/docs/octelium/latest/management/core/overview>.

The *Core* API is the main API for *Cluster* management. The *Core* API includes resources such as [*Services*](https://octelium.com/docs/octelium/latest/management/core/service/overview.md), [*Namespaces*](https://octelium.com/docs/octelium/latest/management/core/namespace.md), [*Users*](https://octelium.com/docs/octelium/latest/management/core/user.md), [*Groups*](https://octelium.com/docs/octelium/latest/management/core/group.md), [*Policies*](https://octelium.com/docs/octelium/latest/management/core/policy.md), [*Devices*](https://octelium.com/docs/octelium/latest/management/core/device.md), [*ClusterConfig*](https://octelium.com/docs/octelium/latest/management/core/cluster-config.md) among other resource types.

## Applying Changes

The *Cluster* is designed to be managed, using the `octeliumctl` CLI, in a centralized and declarative way that is very similar to Kubernetes via the `octeliumctl apply` command, through which you can apply all changes of your resources and (re)produce the state of your *Cluster* with a single command.

You can define one or more resources in a single `yaml` file and then apply all changes as follows:

```bash
octeliumctl apply </PATH/TO/RESOURCES.yaml>
```

As your *Cluster*'s resources grow, you might want to define your resources in multiple `yaml` files and even organize them into further subdirectories. In a fairly complex system with at least tens or hundreds of resources, it's much better to organize your configuration into multiple files and subdirectories. Here is an example:

```text
octelium
├── policies
    ├── http.yaml
    ├── devops.yaml
├── services
    ├── dbs
        ├── aws.yaml
        ├── azure.yaml
    ├── apis.yaml
    ├── ssh.yaml
├── users
    ├── contractors.yaml
    ├── employees
        ├── dev.yaml
        ├── ops.yaml
```

In such case, you similarly use the `octeliumctl apply` command as follows:

```bash
octeliumctl apply </PATH/TO/RESOURCES_ROOT_DIR>
```

You can also apply changes to only a certain subdirectory or even a certain file. Here are some examples:

```bash
# Only apply changes in /policies directory
octeliumctl apply </PATH/TO/RESOURCES_ROOT_DIR>/policies

# Only apply changes in /services/dbs directory
octeliumctl apply </PATH/TO/RESOURCES_ROOT_DIR>/services/dbs

# Only apply changes in /users/employees/ops.yaml file
octeliumctl apply </PATH/TO/RESOURCES_ROOT_DIR>/users/employees/ops.yaml
```

By default, the `octeliumctl apply` command only applies changes to create or update exiting resources but does not delete nonexistent resources. If you want to completely synchronize the state described in your file/directory and prune all additional resources in the *Cluster* that no longer exist in the current configuration, you can add the `--prune` flag as follows:

```bash
octeliumctl apply --prune </PATH/TO/RESOURCES_ROOT_DIR>
```

By default changes to all Resource types, except for *Secret* resources which are meant to be mainly managed in an imperative way (read more [here](https://octelium.com/docs/octelium/latest/management/core/secret.md)), are applied. You can also choose to apply changes for certain Resource types instead of applying changes to all types. For example, you can apply changes for *User* and *IdentityProvider* resources only as follows:

```bash
octeliumctl apply --include User --include IdentityProvider </PATH/TO/RESOURCES_ROOT_DIR>
```

Now, only changes to `User` and `IdentityProvider` resources are applied.

You can also exclude one or more types as follows:

```bash
octeliumctl apply --exclude Service </PATH/TO/RESOURCES_ROOT_DIR>
```

You can also include *Secret* resources via the `--include-secret` flag as follows:

```bash
octeliumctl apply --include-secret </PATH/TO/RESOURCES_ROOT_DIR>
```

### Dry Run

You can see the changes that would be applied to the *Cluster* without actually applying them via the `--dry-run` flag as follows:

```bash
octeliumctl apply --dry-run </PATH/TO/RESOURCES_ROOT_DIR>
```

You can also see the resources that would be deleted by additionally using the `--prune` flag as follows:

```bash
octeliumctl apply --dry-run --prune </PATH/TO/RESOURCES_ROOT_DIR>
```

> **Note:**
>
> The current resources are still fetched from the *Cluster* in order to compute the changes. However, the desired resources are not validated by the *Cluster* in the dry run mode.

### Validating Resources

You can also strictly validate your desired state locally without connecting to the *Cluster* via the `octeliumctl validate` command. This command accepts the same files and directories as the `octeliumctl apply` command and reports all unknown fields, invalid enum values, invalid field types, unsupported kinds and duplicate resources at once. Here are some examples:

```bash
# Validate a single file
octeliumctl validate </PATH/TO/RESOURCES.yaml>

# Validate a root directory including all its yaml files and subdirectories
octeliumctl validate </PATH/TO/RESOURCES_ROOT_DIR>

# Validate multiple files and directories at once
octeliumctl validate </PATH/TO/RESOURCES.yaml> </PATH/TO/RESOURCES_ROOT_DIR>

# Validate from stdin
cat </PATH/TO/RESOURCES.yaml> | octeliumctl validate -
```

The command exits with an error if any error is found which makes it useful, for example, in CI pipelines before actually applying the changes to the *Cluster*. Note that the resources are not validated by the *Cluster* itself in this mode.

## Listing Resources

You can list the different *Cluster* resources via the `octeliumctl get` command. For example, you can list the *Cluster*'s *Services* as follows:

```bash
octeliumctl get service
# Or simply
octeliumctl get svc

# Or list by a certain Namespace
octeliumctl get svc --namespace default
# Or simply
octeliumctl get svc -n production

# Show a certain Service
octeliumctl get svc nginx.production
```

You can also set the page and number of items per page for the list as follows:

```bash
octeliumctl get svc --items-per-page 10 --page 2
```

By default, the list is ordered by the creation date. You can, however, set order the list by name as follows:

```bash
octeliumctl get svc --order-by-name
```

You can also reverse the order of the list as follows:

```bash
octeliumctl get svc --order-reverse
```

By default, the output of a `octeliumctl get` command is formatted as a table. You can force the output to be formatted as YAML as follows:

```bash
octeliumctl get svc -o yaml
# OR
octeliumctl get svc -o yml
```

You can also force the output to be formatted as JSON as follows:

```bash
octeliumctl get svc -o json

# You can also use jq
octeliumctl get svc -o json | jq
octeliumctl get sess -o json | jq -r .items[0].metadata.uid
```

## Deleting Resources

You can delete a certain resource via the `octeliumctl delete` command. Here are some examples:

```bash
octeliumctl delete secret my-secret
# OR
octeliumctl del secret my-secret

octeliumctl del svc nginx
```
