K10s: A Solution to Kubernetes Cluster Management
Introduction
Kubernetes, a powerful platform for managing containerized applications, is widely used across industries for its scalability and flexibility. However, managing and visualizing Kubernetes clusters can often be complex and challenging. The K10s project emerged from the need to simplify the process of interacting with and monitoring Kubernetes clusters through a user-friendly interface. As a university project at Karel de Grote University of Applied Sciences, this tool is designed to manage, visualize, and interact with Kubernetes clusters, allowing users to easily explore and control their Kubernetes environments.
The Problem
Managing a Kubernetes cluster involves multiple components such as pods, services, deployments, nodes, and config maps. For many users, understanding how these elements interconnect and monitoring their performance can be difficult. The complexity of Kubernetes often requires advanced knowledge to troubleshoot and manage resources effectively.
K10s was developed as a response to this problem. It provides an intuitive and accessible web interface that enables users to visualize their Kubernetes clusters, making it easier to manage the various components without having to dive deeply into the command line or technical details.
The Solution
The K10s project aims to simplify the Kubernetes cluster management experience by offering a clear, hierarchical view of the entire infrastructure. It enables users to navigate and manage the following Kubernetes resources:
- Pods: The smallest deployable units in Kubernetes that run your containers.
- Nodes: The machines (virtual or physical) that run your pods.
- Deployments: Manages the deployment and scaling of sets of pods.
- ConfigMaps: Store configuration data that can be used by applications in your Kubernetes cluster.
- Secrets: Store sensitive information such as passwords or OAuth tokens.
The K10s platform consists of three main components:
- Frontend: A responsive Angular-based UI that displays the Kubernetes resources, providing users with an interactive and easily navigable interface.
- Backend: Written in Go, this handles all the API endpoints that interact with the Kubernetes cluster, retrieving and managing resources and their statuses.
- Load Balancer: This component ensures efficient distribution of traffic and helps manage the scalability of the application.
K10s makes it possible to deploy these components seamlessly in a Kubernetes cluster. It runs three containerized images:
- Frontend (Angular): A user-friendly interface that is fully responsive, allowing users to view and interact with their Kubernetes cluster.
- Backend (Go): Handles all the logic and communication with the Kubernetes API to fetch the necessary resources and stats.
- Load Balancer: Routes traffic between the frontend and backend efficiently.
This approach ensures the application is scalable, highly available, and efficient. K10s can be easily deployed on a Kubernetes cluster, and users can access it by navigating to the IP address of the deployed service. Importantly, K10s is designed for private use in local environments, ensuring that complex statistics and sensitive Kubernetes data are not exposed publicly.
Technologies Used
K10s leverages several key technologies to ensure its smooth operation and performance in a Kubernetes environment:
- Kubernetes: The application is designed to run on a Kubernetes cluster, leveraging Kubernetes' native capabilities for managing containerized applications.
- Angular: Used for the frontend, Angular allows us to create a dynamic, responsive, and user-friendly interface to interact with the Kubernetes resources.
- Go: The backend of K10s is built using Go (Golang), a language known for its efficiency and performance in handling backend services.
- Gin Framework: For the backend, we utilized the Gin framework, which is a fast web framework for Go. It is lightweight, yet powerful enough to handle requests from the frontend and interact with Kubernetes API endpoints.
- CORS (Cross-Origin Resource Sharing): We implemented CORS to allow secure communication between the frontend and backend, ensuring only the frontend from trusted origins can access the APIs.
- Gin Auth Middleware: Authentication and authorization are handled using Gin’s middleware, which secures certain routes and ensures that only authenticated users can access sensitive data.
Application Structure and Deployment
The K10s application is designed to be easily deployed on any Kubernetes cluster. The deployment consists of three primary components:
- Frontend (Angular): The user interface is developed using Angular, making it responsive and accessible on various devices. It connects to the backend API to fetch and display the Kubernetes data.
- Backend (Go): The Go-based backend serves as the intermediary between the frontend and Kubernetes API. It retrieves data from the Kubernetes cluster (e.g., pod statuses, node performance) and sends it to the frontend.
- Load Balancer: The load balancer ensures that incoming traffic is efficiently distributed to the frontend and backend services. It enables horizontal scaling if the application needs to handle more users or traffic.
Deployment of the K10s platform is simple and involves using Kubernetes manifests to create the required pods, services, and deployments. Once deployed, users can access the application via the cluster's external IP address.
Security Considerations
Given that Kubernetes clusters often manage sensitive data and critical applications, it’s essential to maintain the security of the K10s platform. To address this, the backend API has secure endpoints protected by an authentication system. Users need to log in to access certain Kubernetes resources, such as viewing pod metrics or creating new deployments.
The security flow is as follows:
- Login: Users authenticate using the login endpoint (/api/login), which returns a session token.
- Secure Endpoints: Once logged in, users can access secure endpoints, such as /api/secured/, which include resources like pods, nodes, and services.
This authentication and authorization system ensures that only authorized users can interact with sensitive resources in the Kubernetes cluster.
Conclusion
K10s is a powerful and user-friendly solution for managing Kubernetes clusters. It simplifies the complex process of monitoring and interacting with Kubernetes resources, making it more accessible for developers, sysadmins, and other IT professionals. By leveraging technologies like Kubernetes, Angular, Go, and the Gin framework, K10s offers a robust and scalable platform that is easy to deploy and use.
Whether you are managing a small personal project or a large-scale enterprise application, K10s helps you keep track of your Kubernetes clusters with ease, efficiency, and security.