This repository contains a simple telnet and DNS client tool, containerized for use in Kubernetes environments. It helps developers and operations teams test connectivity between their Kubernetes clusters and external resources like databases, third-party services, or internal APIs.
- Telnet and DNS Client: Tools to test network connectivity and DNS resolution from within Kubernetes clusters.
- Kubernetes Ready: Easily deployable as a Kubernetes service.
- Lightweight: Minimal resource usage, allowing for testing without heavy footprint.
- Fully Containerized: Available as a Docker container, making it easy to integrate with your CI/CD pipelines.
- Kubernetes Cluster: Make sure you have a running Kubernetes cluster.
- kubectl CLI: To interact with your Kubernetes cluster.
- Terraform: For those using the terraform-kubernetes-provider to manage the cluster resources.
- Docker: (Optional) For local testing before pushing the container to your cluster.
The image is available on DockerHub:
docker pull aleskerov/k8s-pingops:latest
- Kubernetes YAML Manifest If you're not using Terraform, here’s a YAML version of the Kubernetes manifest:
Click to Expand YAML Manifest
---
apiVersion: v1
kind: Namespace
metadata:
labels:
k8s-balancer: "true"
name: k8s-pingops
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: k8s-pingops
name: k8s-pingops
namespace: k8s-pingops
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: k8s-pingops
template:
metadata:
labels:
app.kubernetes.io/name: k8s-pingops
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: k8s-pingops
topologyKey: kubernetes.io/hostname
weight: 1
containers:
- image: aleskerov/k8s-pingops:latest
imagePullPolicy: IfNotPresent
name: k8s-pingops
ports:
- containerPort: 8080
resources:
limits:
cpu: 150m
memory: 128Mi
requests:
cpu: 10m
memory: 10Mi
---
apiVersion: v1
kind: Service
metadata:
name: k8s-pingops
namespace: k8s-pingops
spec:
ports:
- name: http
port: 80
targetPort: 8080
selector:
app.kubernetes.io/name: k8s-pingops
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: k8s-pingops
namespace: k8s-pingops
spec:
ingressClassName: nginx
rules:
- host: pingops.yourdomain.com
http:
paths:
- backend:
service:
name: k8s-pingops
port:
number: 80
path: /
pathType: Prefix
-
Apply Kubernetes YAML Once you have the manifest, apply it to your Kubernetes cluster:
kubectl apply -f k8s-pingops.yaml
-
Access the Service The service is now available at
http://pingops.yourdomain.com
. You can test connectivity using the telnet and DNS client tools.
If you prefer to use Terraform to manage Kubernetes resources, below is the Terraform configuration for deploying k8s-pingops
in your cluster.
The following resources will be created:
- Namespace:
k8s-pingops
- Deployment: A 2-replica deployment for the ping client.
- Service: ClusterIP service exposing the container on port 80.
- Ingress: Ingress route (using NGINX ingress controller).
You can copy the provided Terraform code into your own .tf
file and apply it to your Kubernetes environment.
resource "kubernetes_namespace" "k8s_pingops" {
metadata {
name = "k8s-pingops"
}
}
resource "kubernetes_deployment" "k8s_pingops" {
metadata {
name = "k8s-pingops"
namespace = kubernetes_namespace.k8s_pingops.metadata[0].name
}
spec {
replicas = 2
selector {
match_labels = {
"app.kubernetes.io/name" = "k8s-pingops"
}
}
template {
metadata {
labels = {
"app.kubernetes.io/name" = "k8s-pingops"
}
}
spec {
container {
name = "k8s-pingops"
image = "aleskerov/k8s-pingops:latest"
}
}
}
}
}
resource "kubernetes_service" "k8s_pingops" {
metadata {
name = "k8s-pingops"
}
spec {
selector = {
"app.kubernetes.io/name" = "k8s-pingops"
}
port {
port = 80
}
}
}
To deploy with Terraform:
terraform init
terraform apply
- CPU: Requests
10m
, Limits150m
- Memory: Requests
10Mi
, Limits128Mi
Make sure these values align with your cluster's capacity.
You can modify the configuration of this app by editing:
- Replicas: Change the
replicas
field in the Kubernetes manifest or Terraform file. - Resource Limits: Modify CPU and memory requests/limits as needed.
Feel free to open an issue or submit a pull request if you have any improvements or suggestions!
This project was developed by Kanan Alasgarli. If you like the project, please ⭐ it!
This project is licensed under the MIT License. See the LICENSE file for details.