Hackers News

GitHub – soub4i/kubestatus-operator: kubestatus operator

Docker Cloud Build Status

Kubestatus is an free and open-source tool to easily add status page to your Kubernetes cluster that currently display the status (operational, degraded or DOWN) of services.It is written in Go and uses the Kubernetes API to fetch information about the clusters and resources checck the kubestatus-operand image.

The tool provides a simple and convenient way to view the current state of your cluster and resources without having to use the kubectl command-line tool or the Kubernetes dashboard and in the same time give you a costumer friendly page that can be used as you main status page.

Features:

  • ⚡ Lightweight
  • 🔧 Minimal configuration
  • 📖 Open-source
  • 📫 Support TCP and UDP services

Before installing the KubeStatus Operator, ensure you have:

  • Kubernetes cluster version 1.19+
  • kubectl installed and configured
  • Cluster admin access or appropriate RBAC permissions

You can install the KubeStatus Operator using the following command:

kubectl apply -f https://raw.githubusercontent.com/soubai/kubestatus-operator/main/dist/install.yaml
  1. Clone the repository:
git clone https://github.com/soubai/kubestatus-operator.git
cd kubestatus-operator
  1. Install the CRDs:
kubectl apply -f config/crd/bases
  1. Install the operator:
kubectl apply -f dist/install.yaml
  1. Check if the operator pod is running:
kubectl get pods -n kubestatus-operator-system
  1. Verify the CRDs are installed:
kubectl get crds | grep kubestatus
  1. Create a KubeStatus resource:
apiVersion: crd.soubai.me/v1
kind: KubeStatus
metadata:
  name: sample-kubestatus
spec:
  # Add your spec configuration here
  1. Apply the resource:
kubectl apply -f kubestatus-sample.yaml
  1. Check the status:
kubectl get kubestatus sample-kubestatus -o yaml

Field Type Description Required
spec.Namespaces []string List of namesp Yes
spec.Size integer Number of replicas of Kubestatus (default 3) No
spec.ConfigMapName string ConfigMap name used by Kubestatus (default kubestatus-configmap) No

apiVersion: crd.soubai.me/v1
kind: KubeStatus
metadata:
  name: dub-cluster12-status
spec:
  namespaces: 
    - default
    - web-namepace
  Size: 1

To monitor your services with KubeStatus, you need to add them to the watch list. You can do this by adding a specific annotation to each service you want to monitor:

kubectl annotate svc my-service-name kubestatus/watch='true'

You created this web application based on nginx image.

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
EOF

Exposing the web application using k8s service

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  selector:
    app: nginx
  ports:
  - port: 80
EOF

Add annotation to web-service:

kubectl annotate svc web-service kubestatus/watch='true'

In order to visit kubestatus status page you can port-forword the Kubestatus service:

kubectl port-forward service/kubestatus-service 8080 -n kubestatus

🚀 Now navigate to http://localhost:8080 you should see your status page like this:

  1. Operator pod not starting:

    kubectl logs -n kubestatus-operator-system deployment/kubestatus-operator-controller-manager -c manager
  2. Status not updating:

    • Check the operator logs for errors
    • Verify the KubeStatus resource is properly configured

If you encounter any issues:

  • Open an issue on GitHub
  • Check existing issues for solutions
  • Include operator logs and resource definitions when reporting problems

To remove the KubeStatus Operator from your cluster:

kubectl delete -f dist/install.yaml
kubectl delete -f config/crd/bases

Contributions are welcome! Please feel free to submit a Pull Request.

This project is licensed under the Apache License 2.0.

admin

The realistic wildlife fine art paintings and prints of Jacquie Vaux begin with a deep appreciation of wildlife and the environment. Jacquie Vaux grew up in the Pacific Northwest, soon developed an appreciation for nature by observing the native wildlife of the area. Encouraged by her grandmother, she began painting the creatures she loves and has continued for the past four decades. Now a resident of Ft. Collins, CO she is an avid hiker, but always carries her camera, and is ready to capture a nature or wildlife image, to use as a reference for her fine art paintings.

Related Articles

Leave a Reply