Kc Ks8 To Dotlang
LangChain Hub prompt: alexis/kc-ks8-to-dotlang
Given a Kubernetes topology in JSON format, create a comprehensive dot-lang diagram that visualizes the relationships between all Kubernetes components. Follow these specific guidelines:
1. DIAGRAM STRUCTURE:
-
Group components into the following logical subgraphs:
-
Access Control
-
Cluster Resources
-
Workloads
-
Configuration
-
Networking
-
Storage
-
Scaling
-
Use digraph for directed graph
-
Use subgraph cluster_* for logical groupings
-
Set global graph attributes for readability
-
Use rankdir="TB" for top-down layout
2. COMPONENT RELATIONSHIPS:
For each resource type in the JSON topology:
-
Parse the
metadata.ownerReferencesto establish a parent-child relationship -
Parse the
spec.selectorfields to establish Service-Pod relationships -
Parse the
spec.volumesandspec.volumeMountsfor storage relationships -
Parse RBAC relationships from RoleBindings and ClusterRoleBindings
-
Parse service to pod connection using selectors and ports
3. REQUIRED COMPONENTS (if present in topology):
Access Control:
-
User
-
Group
-
CustomRole (CR)
-
CustomRoleBinding (CRB)
-
ServiceAccount (SA)
-
PodSecurityPolicy (PSP)
Cluster Resources:
-
Namespace (NS)
-
ResourceQuota
-
LimitRange
Workloads:
-
Deployment
-
StatefulSet (SS)
-
DaemonSet (DS)
-
Job
-
CronJob (CJ)
-
ReplicaSet (RC)
-
Pod
Configuration:
-
ConfigMap (CM)
-
Secret
Networking:
-
Service (Svc)
-
Ingress (Ing)
-
Endpoints (EP)
-
NetworkPolicy (NPol)
Storage:
-
Volume (Vol)
-
PersistentVolumeClaim (PVC)
-
PersistentVolume (PV)
-
StorageClass (SC)
Scaling:
-
HorizontalPodAutoscaler (HPA)
-
VerticalPodAutoscaler (VPA)
-
PodDisruptionBudget (PDB)
5. RELATIONSHIP MAPPING RULES:
- Container --> Endpoints --> Services
- Ingress --> Services
- PVCs --> PVs
- Volumes --> Pods
- HPAs/VPAs --> Pods
- CronJobs --> Jobs --> Pods
- NetworkPolicies --> Pods
6. FORMAT REQUIREMENTS:
- Use standard naming conventions (e.g., Deploy for Deployment)
- Include all relationship arrows using -->
- Use descriptive edge labels where helpful (e.g., --Constrains-->)
- Group related components in appropriate subgraphs
- Maintain consistent spacing and formatting
- Add a
kf_typefield to each component - When a container (cont-a) wants to communicate with a container(cont-b) e.g
pod-a, it should do so via the service cont-a is with like socont-a -> cont-b[lhead="service-b"] - Avoid adding any styling to the diagram
COMPLETE EXAMPLE
Here's how the dotlang diagram should be structured:
digraph G {
rankdir="TB"
compound=true
node
subgraph cluster_default {
label="default namespace"
kf_type="ns"
subgraph cluster_frontend_service {
label="frontend service"
kf_type="svc"
subgraph cluster_frontend_workload {
label="frontend deployment"
kf_type="workload"
subgraph cluster_frontend_pod {
label="pod"
kf_type="pod"
nginx[kf_type="container"]
frontend_app[kf_type="container"]
}
frontend_hpa[kf_type="hpa"]
}
}
subgraph cluster_auth_service {
label="auth service"
kf_type="svc"
subgraph cluster_auth_workload {
label="auth deployment"
subgraph cluster_auth_pod {
label="auth pod"
kf_type="pod"
auth[kf_type="container"]
redis_cache[kf_type="container"]
}
auth_hpa[kf_type="hpa"]
}
}
subgraph cluster_cart_service {
label="cart service"
kf_type="svc"
subgraph cluster_cart_workload {
label="cart deployment"
kf_type="workload"
subgraph cluster_cart_pod {
label="cart pod"
kf_type="pod"
cart[kf_type="container"]
redis_cart[kf_type="container"]
}
cart_hpa[kf_type="hpa"]
}
}
subgraph cluster_orders_service {
label="orders service"
kf_type="svc"
subgraph cluster_orders_workload {
label="orders deployment"
kf_type="workload"
subgraph cluster_orders_pod {
label="pod"
kf_type="pod"
orders[kf_type="container"]
}
orders_hpa[kf_type="hpa"]
}
}
subgraph cluster_products_service {
label="products service"
kf_type="svc"
subgraph cluster_products_workload {
label="products deployment"
kf_type="workload"
subgraph cluster_products_pod {
label="products pod"
kf_type="pod"
products[kf_type="container"]
products_cache[shape="container"]
}
products_hpa[kf_type="hpa"]
}
}
# Service connections
nginx -> frontend_app[label="3000"]
frontend_app -> auth[label="8080" lhead="cluster_auth_service"]
frontend_app -> cart[label="8082" lhead="cluster_cart_service"]
frontend_app -> orders[label="8083" lhead="cluster_orders_service"]
frontend_app -> products[label="8081" lhead="cluster_products_service"]
auth -> redis_cache[label="6379"]
auth_hpa -> auth[lhead="cluster_auth_pod"]
cart -> redis_cart[label="6379"]
cart -> auth[label="8080" lhead="cluster_auth_service"]
cart -> products[label="8081" lhead="cluster_products_service"]
cart_hpa -> cart[lhead="cluster_cart_pod"]
orders -> auth[label="8080" lhead="cluster_auth_service"]
orders_hpa -> orders[lhead="cluster_orders_pod"]
products -> products_cache[label="6379"]
products_hpa -> products[lhead="cluster_products_pod"]
}
}
Return a complete dotlang diagram that:
- Shows all components present in the input JSON
- Groups them logically in subgraphs
- Shows all relationships between components
- Includes proper styling classes
- Uses consistent naming and abbreviations
- Specific Structure Requirements:
- Ensure workloads (deployments, statefulsets, daemonsets, cronjobs, jobs, etc.) are in a subgraph with a service subgraph
- Place pods as subgraphs within the workload subgraph
- Position horizontal pod autoscalers inside a workload with a connection to the pod
NOTE: You must respond with only the dotlang diagram wrapped in a dot codeblock and nothing else.
Here is the extracted Kubernetes topology:
{KUBERNETES_TOPOLOGY}
How to Use
Use with LangChain: hub.pull("alexis/kc-ks8-to-dotlang")
Related Prompts
More prompts in Coding & Development
This Prompt Ads Sequential Function Calling To Models Other Than GPT 0613
This prompt ads sequential function calling to models other than GPT-0613
Create a personalized workout routine
Tailor a workout routine specifically designed for individual fitness goals
GODMODE CHEATCODE
God Writes You a Letter Today. This is will help you find the perfect Bible Scripture that will guide you through a current problem you're facing.
Creating a Personal Finance Tracker with [Technology/Tool]
Learn to create a personal finance tracker using [Technology/Tool]. Get code samples and budgeting tips.
Build an entire application using bubble.io with ChatGPT4
Build an entire app with bubble.io, assisted by chatGPT4, that knows bubble very well and is accurate 95% of the time. This prompt will help you maximize the quality of chatGPT assistance. Having detailed and step-by-step instructions is essential to progress fast with Bubble. This initial prompt will help you get started on a good basis. Follow it because I will make it even better.
Become LawyerGPT
Are you in a legal bind? This prompt can help you gain knowledge about how to handle your legal proceedings. DISCLAIMER: Please meet with a real lawyer to discuss your options.