Commit d097c53c authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

Add docs explaining how to deploy services using local execution

parent 4314ba4d
Loading
Loading
Loading
Loading
+82 −0
Original line number Diff line number Diff line
# Deploying to an Existing Cluster

This guide explains how to use the Operator Platform Ansible collection to deploy services to an existing Kubernetes cluster using only a Kubeconfig file.

## Overview

By default, the automation scripts are designed to spin up a local Kind cluster. However, you can target any existing Kubernetes cluster (local or remote) by pointing Ansible to your specific Kubeconfig and running the playbooks locally.

## Prerequisites

1.  **Ansible** installed on your local machine.
2.  **Kubeconfig file** for the target cluster accessible on your local machine.
3.  **Connectivity** to the target cluster's API server.

## Inventory Configuration

Since the `kubectl` commands are executed from your local machine (where the Kubeconfig resides), you should target `localhost` in your Ansible inventory.

Create a temporary inventory file (e.g., `inventory/local_target.yml`):

```yaml
all:
  hosts:
    localhost:
      ansible_connection: local
  children:
    kind_cluster:
      hosts:
        localhost:
```

## Required Variables

When running the playbooks, you must override specific variables to prevent Ansible from looking for the default Kind cluster configuration.

| Variable | Description | Example |
| :--- | :--- | :--- |
| `kind_config_dir` | Directory containing your Kubeconfig file. | `/home/user/.kube` |
| `kubeconfig_output_dir` | Same as above (for compatibility). | `/home/user/.kube` |
| `kubeconfig_filename` | The name of your Kubeconfig file. | `config` |
| `host_ip` | The IP address reachable by the cluster (often the API server IP or LoadBalancer IP). This is used for Ingress/NodePort configurations. | `192.168.1.100` |

## Deployment Command

Use `ansible-playbook` with the `-e` (extra vars) flag to inject the configuration.

### Example: Deploying Artefact Manager

```bash
ansible-playbook -i inventory/local_target.yml \
  -e "kind_config_dir=/path/to/your/kube/dir" \
  -e "kubeconfig_output_dir=/path/to/your/kube/dir" \
  -e "kubeconfig_filename=your-config-file" \
  -e "host_ip=192.168.1.100" \
  playbooks/tools/artefact-manager/deploy.yml
```

### Example: Deploying Federation Manager with Lite2Edge

If you need to link services (e.g., connecting Federation Manager to Lite2Edge), pass the corresponding port and client variables:

```bash
ansible-playbook -i inventory/local_target.yml \
  -e "kind_config_dir=/path/to/your/kube/dir" \
  -e "kubeconfig_output_dir=/path/to/your/kube/dir" \
  -e "kubeconfig_filename=your-config-file" \
  -e "host_ip=192.168.1.100" \
  -e "federation_manager_ecp_port=30081" \
  -e "federation_manager_ecp_client_name=lite2edge" \
  playbooks/tools/federation-manager/deploy.yml
```

## Common Issues

### "host_ip is undefined"
The playbooks use `host_ip` to configure where services advertise themselves. If this fails, ensure you are passing `-e "host_ip=<CLUSTER_IP>"` in your command.

### Connection Refused
Ensure your local machine can reach the cluster's API server. You can verify this by running:
```bash
kubectl --kubeconfig /path/to/your/kube/config get nodes
```