|
| 1 | +# Steps for deploying the OpenShift MCP server on OpenShift |
| 2 | + |
| 3 | +The [OpenShift MCP server](https://github.com/manusa/kubernetes-mcp-server) is a Kubernetes MCP server implementation configured with a few tools that can: |
| 4 | + |
| 5 | +- Automatically view and manage the current Kubernetes `.kube/config` or in-cluster configuration |
| 6 | +- Use tools to perform operations on any Kubernetes or OpenShift resource such as: |
| 7 | + - **Pod operations** - It can list, get, delete, show logs, exec, run pods |
| 8 | + - **Namespace operations** - It can list Kubernetes Namespaces |
| 9 | + - **Events** - View Kubernetes events in all namespaces or in a specific namespace |
| 10 | + - **Projects** - List OpenShift Projects |
| 11 | + |
| 12 | +## Pre-Requisites |
| 13 | + |
| 14 | +You will need the following installed on your local machine: |
| 15 | + |
| 16 | +- `podman` |
| 17 | +- `oc` |
| 18 | + |
| 19 | +## Step 1: Building the Containerfile |
| 20 | + |
| 21 | +You will need to first build a container image using the `Containerfile` and can do this by using `podman`. To build the container image from the current directory: |
| 22 | + |
| 23 | +``` |
| 24 | +podman build -t ocp-mcp-server:latest -f Containerfile . |
| 25 | +``` |
| 26 | + |
| 27 | +If running on a Mac: |
| 28 | + |
| 29 | +``` |
| 30 | +podman build -t ocp-mcp-server:latest --platform="linux/amd64" -f Containerfile . |
| 31 | +``` |
| 32 | + |
| 33 | +If run successfully, you should see your image `localhost/ocp-mcp-server` listed when you run: |
| 34 | + |
| 35 | +``` |
| 36 | +podman images |
| 37 | +``` |
| 38 | + |
| 39 | +## Step 2: Pushing the container image to Quay |
| 40 | + |
| 41 | +Next, you will need to push your container image to a public image repository like [quay.io](https://quay.io/). Make sure you create an account on quay.io, if you don't have one already. Once you have an account, you will need to login: |
| 42 | + |
| 43 | +``` |
| 44 | +podman login -u=<user_name> -p=<pass_word> quay.io |
| 45 | +``` |
| 46 | + |
| 47 | +Once you're logged in successfully, you can now push your image by first tagging your local image: |
| 48 | + |
| 49 | +``` |
| 50 | +podman tag localhost/ocp-mcp-server:latest quay.io/<username>/ocp-mcp-server:latest |
| 51 | +``` |
| 52 | + |
| 53 | +Then you can push to your quay registry: |
| 54 | + |
| 55 | +``` |
| 56 | +podman push quay.io/<username>/ocp-mcp-server:latest |
| 57 | +``` |
| 58 | + |
| 59 | +### Step 3: Deploying on OpenShift |
| 60 | + |
| 61 | +To deploy the OpenShift MCP server on OpenShift, make sure you have access to an active OpenShift cluster and namespace. Note that as this MCP server is implemented to perform certain operations on a OpenShift/Kubernetes environment you will need to setup a `ServiceAccount` with `edit` RoleBinding access to allow suitable permissions for the MCP server to execute those operations. This has been defined in the `deployment.yaml`. |
| 62 | + |
| 63 | +**Login to Openshift** |
| 64 | + |
| 65 | +``` |
| 66 | +oc login --token=<your user token> --server=<your openshift cluster server> |
| 67 | +``` |
| 68 | + |
| 69 | +Select a suitable namespace within the cluter: |
| 70 | + |
| 71 | +``` |
| 72 | +oc project <your namespace> |
| 73 | +``` |
| 74 | + |
| 75 | +**Deploy the OpenShift MCP server application**: |
| 76 | + |
| 77 | +``` |
| 78 | +oc apply -f deployment.yaml |
| 79 | +``` |
| 80 | + |
| 81 | +You should now see a pod running successfully in OpenShift as well as a service created for it! You should see an address created for the service in your OpenShift something like `http://172.xx.yyy.zzz:8000`. |
| 82 | + |
| 83 | +### Step 4: Testing the OpenShift MCP server |
| 84 | + |
| 85 | +You can run the example sript in `app/src/0_simple_agent.py` by modifying the following: |
| 86 | + |
| 87 | +- Set the `REMOTE_MCP_URL` env var to `http://<your mcp service endpoint>:8000/sse` |
| 88 | +- Set the `REMOTE_BASE_URL` env var to your hosted llama stack server |
| 89 | +- Provide a suitable user query to test. You can try an example user prompt like "Please list all the pods running in my xyz namespace?" and pass it [here](https://github.com/redhat-et/llama-stack-on-ocp/blob/main/app/src/0_simple_agent.py#L74) |
| 90 | + |
| 91 | +Then run the script like: |
| 92 | + |
| 93 | +``` |
| 94 | +python 0_simple_agent.py -r -a |
| 95 | +``` |
0 commit comments