Skip to content

About

C# WinForms app for managing K3s/Kubernetes clusters via REST API, with dashboards, YAML/JSON export, RBAC and a local Ollama AI chatbot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

KubernetesController

C# Kubernetes K3s Ollama Platform

KubernetesController is a C# WinForms desktop application designed to simplify the monitoring and management of a Kubernetes cluster running on K3s.

The application provides a graphical interface for users who want to inspect, create, delete, and export Kubernetes resources without relying exclusively on command-line tools such as kubectl.

It also includes a lightweight local AI assistant powered by Ollama and Llama 3.2 1B, capable of answering questions about the application and the Kubernetes resources displayed in it.


Overview

The main goal of this project is to provide an accessible desktop interface for interacting with a K3s cluster through the Kubernetes REST API.

The application connects directly to the Kubernetes API server using:

  • the IP address or URL of the K3s server;
  • port 6443;
  • a Kubernetes ServiceAccount bearer token.

For development or testing, it can also connect through kubectl proxy.

The project was developed as an educational application focused on Kubernetes administration, REST API communication, C# desktop development, RBAC authentication, resource visualization, and local AI integration.


Main Features

Cluster dashboard

The dashboard presents a visual overview of the connected cluster, including:

  • total number of nodes;
  • ready and unavailable nodes;
  • total CPU capacity;
  • total memory capacity;
  • pod capacity;
  • total namespaces;
  • total pods;
  • running pods;
  • deployments and active deployments;
  • total services;
  • available ingresses;
  • master node IP address;
  • most frequently used container image;
  • pods grouped by namespace;
  • node status charts;
  • memory capacity by node;
  • container images detected in the cluster.

Node management

The Nodes tab displays detailed information about each cluster node, such as:

  • node name;
  • readiness state;
  • roles;
  • Kubernetes and K3s versions;
  • operating system;
  • architecture;
  • internal IP address;
  • CPU and memory capacity;
  • pod capacity;
  • conditions;
  • labels;
  • annotations;
  • addresses;
  • taints;
  • system information;
  • managed fields.

Namespace management

The Namespaces tab allows the user to:

  • list all namespaces;
  • inspect namespace details;
  • create namespaces;
  • delete namespaces;
  • export a selected namespace as YAML or JSON.

Pod management

The Pods tab allows the user to:

  • list pods from all namespaces;
  • inspect pod status and configuration;
  • view containers, images, conditions, labels, annotations, owners, volumes, and tolerations;
  • create pods;
  • delete pods;
  • export a selected pod as YAML or JSON.

When creating a pod, the user can select an existing namespace and choose or enter a container in the name:image format.

Deployment management

The Deployments tab allows the user to:

  • list deployments from all namespaces;
  • inspect replica status;
  • inspect containers, images, selectors, strategy, conditions, labels, annotations, and managed fields;
  • create deployments;
  • define the number of replicas;
  • delete deployments;
  • export a selected deployment as YAML or JSON.

Service management

The Services tab allows the user to:

  • list services from all namespaces;
  • inspect service type, ClusterIP, external IP, ports, selectors, load balancer information, labels, annotations, finalizers, and managed fields;
  • create ClusterIP, NodePort, and LoadBalancer services;
  • configure service port, target port, and protocol;
  • delete services;
  • export a selected service as YAML or JSON.

Ingress management

The Ingresses section allows the user to:

  • list ingresses from all namespaces;
  • inspect hosts, paths, destination services, addresses, TLS information, labels, annotations, load balancer data, and managed fields;
  • create ingresses;
  • select an existing namespace;
  • select an existing destination service;
  • automatically use a service port when available;
  • delete ingresses;
  • export a selected ingress as YAML or JSON.

YAML and JSON export

Namespaces, pods, deployments, services, and ingresses can be exported individually.

The export workflow is:

  1. Select a resource.
  2. Click Export.
  3. Choose either YAML or JSON.
  4. Select the destination folder.
  5. Save the file.

The default file name is based on the selected Kubernetes resource.

XML export is not currently supported.

Local Kubernetes chatbot

The application includes a ChatBot tab connected to a local Ollama instance running inside the Ubuntu VM.

The chatbot uses:

llama3.2:1b

It can help users with questions such as:

  • What is a pod?
  • What is the purpose of a namespace?
  • How do I create a deployment?
  • How do I delete a service?
  • How do I export a resource as YAML or JSON?
  • What does CrashLoopBackOff mean?
  • What resources are currently loaded by the application?
  • How do I navigate through the application?

The assistant is restricted to topics related to:

  • Kubernetes;
  • K3s;
  • KubernetesController;
  • resources displayed by the application;
  • basic errors and operations supported by the interface.

Questions unrelated to the application are rejected with an appropriate message.

The chatbot does not directly create, delete, or modify resources. It only explains how to perform operations through the application.


Application Screenshots

The screenshots below are stored in the docs/images directory.

Connection screen

Connection screen

Cluster dashboard

Cluster dashboard

Nodes

Nodes management

Namespaces

Namespaces management

Pods

Pods management

Deployments

Deployments management

Services

Services management

Ingresses

Ingress management

Local Kubernetes chatbot

Local Kubernetes chatbot


Architecture

┌──────────────────────────────────────┐
│ KubernetesController                 │
│ C# WinForms desktop application      │
└──────────────────┬───────────────────┘
                   │
                   │ HTTPS + Bearer token
                   ▼
┌──────────────────────────────────────┐
│ Kubernetes API Server                │
│ K3s on Ubuntu VM                     │
│ https://VM_IP:6443                   │
└──────────────────────────────────────┘

┌──────────────────────────────────────┐
│ KubernetesController ChatBot tab     │
└──────────────────┬───────────────────┘
                   │
                   │ HTTP
                   ▼
┌──────────────────────────────────────┐
│ Ollama on Ubuntu VM                  │
│ http://VM_IP:11434                   │
│ Model: llama3.2:1b                   │
└──────────────────────────────────────┘

The application automatically builds the default Ollama address from the host used for the Kubernetes connection.

Example:

Kubernetes API:
https://192.168.1.50:6443

Ollama:
http://192.168.1.50:11434

The chatbot connection status is displayed only inside the ChatBot tab. A temporary Ollama connection failure does not prevent the rest of the application from opening or managing the cluster.


Technologies

  • C#;
  • Windows Forms;
  • Kubernetes REST API;
  • K3s;
  • JSON;
  • YAML;
  • HTTP and HTTPS;
  • bearer token authentication;
  • Kubernetes RBAC;
  • Ollama;
  • Llama 3.2 1B;
  • Ubuntu Server VM;
  • Visual Studio.

Requirements

Windows computer

  • Windows 10 or Windows 11;
  • Visual Studio with C# and Windows desktop development support;
  • network access to the Ubuntu VM.

Ubuntu virtual machine

  • Ubuntu Server;
  • K3s installed and running;
  • Ollama installed and running;
  • llama3.2:1b installed;
  • ports 6443 and 11434 accessible from the Windows host.

K3s Access Configuration

The application requires a Kubernetes ServiceAccount and the necessary RBAC permissions.

Create a file named:

kubernetes-controller-access.yaml

Add the following configuration:

apiVersion: v1
kind: Namespace
metadata:
  name: kubernetes-controller
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kubernetes-controller-sa
  namespace: kubernetes-controller
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-controller-admin
subjects:
  - kind: ServiceAccount
    name: kubernetes-controller-sa
    namespace: kubernetes-controller
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

Apply it:

sudo k3s kubectl apply -f kubernetes-controller-access.yaml

Generate a token:

sudo k3s kubectl create token kubernetes-controller-sa \
  -n kubernetes-controller \
  --duration=8760h

Copy the generated token and use it on the application connection screen.

The cluster-admin role is convenient for a controlled educational environment, but it provides unrestricted access to the cluster. A production deployment should use a dedicated least-privilege ClusterRole.


Ollama Configuration

Confirm that Ollama is installed:

ollama --version

Confirm that the model is available:

ollama list

Install the model when required:

ollama pull llama3.2:1b

Test it locally:

ollama run llama3.2:1b

By default, Ollama may only listen on localhost. To allow the Windows application to connect to it, edit the systemd service:

sudo systemctl edit ollama.service

Add:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Reload and restart the service:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Check its state:

sudo systemctl status ollama --no-pager

Test it from the Windows computer:

curl http://VM_IP:11434

Expected response:

Ollama is running

Running the Application

  1. Start the Ubuntu VM.

  2. Confirm that K3s is running:

    sudo systemctl status k3s --no-pager
  3. Confirm that Ollama is running:

    sudo systemctl status ollama --no-pager
  4. Open the solution in Visual Studio.

  5. Build the project.

  6. Start the application.

  7. Enter the Ubuntu VM IP address.

  8. Paste the Kubernetes ServiceAccount token.

  9. Connect to the cluster.

The application normally builds the Kubernetes API URL as:

https://VM_IP:6443

When no token is provided, the application may use a kubectl proxy connection such as:

http://VM_IP:8001

Kubernetes API Endpoints

The application uses endpoints such as:

GET /version
GET /api/v1/nodes
GET /api/v1/namespaces
GET /api/v1/pods
GET /apis/apps/v1/deployments
GET /api/v1/services
GET /apis/networking.k8s.io/v1/ingresses

Namespaced operations use endpoints such as:

/api/v1/namespaces/{namespace}/pods
/apis/apps/v1/namespaces/{namespace}/deployments
/api/v1/namespaces/{namespace}/services
/apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses

Create and delete operations are performed through the corresponding Kubernetes REST API endpoints.


Suggested Repository Structure

KubernetesController/
├── KubernetesController/
│   ├── Form1.cs
│   ├── DashboardForm.cs
│   ├── DashboardPods.partial.cs
│   ├── DashboardDeployments.partial.cs
│   ├── DashboardServicesIngresses.partial.cs
│   ├── DashboardChatbot.partial.cs
│   ├── CreateNamespaceForm.cs
│   ├── CreatePodForm.cs
│   ├── CreateDeploymentForm.cs
│   ├── CreateServiceForm.cs
│   ├── CreateIngressForm.cs
│   ├── Models/
│   └── Services/
├── docs/
│   └── images/
├── kubernetes-controller-access.yaml
├── LICENSE
└── README.md

The exact structure may vary depending on the current project version.


Security Notes

Do not commit the following information to GitHub:

  • Kubernetes bearer tokens;
  • ServiceAccount tokens;
  • credentials;
  • kubeconfig files containing certificates or tokens;
  • exported resources containing secrets.

Recommended .gitignore entries:

.vs/
bin/
obj/
*.user
*.suo
*.cache
*.log
appsettings.local.json
secrets.json
token.txt
kubeconfig

If a token is accidentally exposed, generate a new one and stop using the previous token.


Known Limitations

  • The application is intended primarily for educational and controlled laboratory environments.
  • The current chatbot uses a small 1B parameter model, so complex answers may be limited.
  • Chatbot availability depends on the Ubuntu VM and the Ollama service.
  • The chatbot is informational and does not execute cluster operations.
  • XML export is not supported.
  • The current RBAC example uses cluster-admin.
  • Advanced resources such as ConfigMaps, Secrets, StatefulSets, DaemonSets, Jobs, CronJobs, and persistent volumes are not yet managed by the interface.

Possible Future Improvements

  • least-privilege Kubernetes RBAC;
  • support for ConfigMaps and Secrets;
  • support for StatefulSets, DaemonSets, Jobs, and CronJobs;
  • pod log visualization;
  • Kubernetes event visualization;
  • resource editing;
  • YAML import and deployment;
  • filtering and searching;
  • namespace-specific views;
  • configurable Ollama model and endpoint;
  • chatbot conversation history;
  • more detailed cluster health diagnostics;
  • secure configuration storage;
  • automated tests;
  • installer or release package.

Educational Purpose

This project demonstrates practical knowledge in:

  • Kubernetes resource management;
  • K3s administration;
  • Kubernetes REST API usage;
  • authentication and RBAC;
  • asynchronous HTTP communication in C#;
  • JSON and YAML processing;
  • WinForms interface development;
  • local AI model integration;
  • virtual machine networking;
  • software documentation.

License

Add a LICENSE file to define how other users may use, modify, and distribute the project.

For an open-source educational project, the MIT License is a common option.


Author

Developed as an academic and portfolio project focused on Kubernetes, K3s, C# WinForms, REST APIs, and local artificial intelligence.

About

C# WinForms app for managing K3s/Kubernetes clusters via REST API, with dashboards, YAML/JSON export, RBAC and a local Ollama AI chatbot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages