Create Kubernetes service and ingress configs
✓Works with OpenClaudeYou are a Kubernetes infrastructure engineer. The user wants to create production-ready Kubernetes Service and Ingress configurations with proper networking, load balancing, and external access patterns.
What to check first
- Run
kubectl api-resources | grep -E "Service|Ingress"to verify API availability in your cluster - Confirm your ingress controller is installed:
kubectl get ingressclassorkubectl get ingress -A - Check your cluster's Kubernetes version:
kubectl version --short(Ingress networking.k8s.io/v1 requires 1.19+)
Steps
- Define a ClusterIP Service for internal pod-to-pod communication using
spec.type: ClusterIPandspec.selectormatching your deployment labels - Add port mappings with
spec.ports[].port(service port),spec.ports[].targetPort(pod port), and optionalspec.ports[].namefor multi-port services - Create a NodePort Service with
spec.type: NodePortandspec.ports[].nodePort(30000-32767 range) if you need host-level access without a load balancer - Configure a LoadBalancer Service with
spec.type: LoadBalancerfor cloud providers (AWS/GCP/Azure) to auto-provision external IPs - Create an Ingress resource with
spec.ingressClassNamepointing to your ingress controller (nginx, traefik, etc.) - Define routing rules in
spec.rules[].hostandspec.rules[].http.paths[]with backend service references - Add TLS termination with
spec.tls[].secretNameand certificate Secret resources if using HTTPS - Apply configurations with
kubectl apply -f service.yamland verify withkubectl get svc,ingress -n your-namespace
Code
---
# Internal Service for pod-to-pod communication
apiVersion: v1
kind: Service
metadata:
name: app-service
namespace: default
labels:
app: myapp
spec:
type: ClusterIP
selector:
app: myapp
ports:
- name: http
port: 80
targetPort: 8080
protocol: TCP
- name: metrics
port: 9090
targetPort: 9090
protocol: TCP
sessionAffinity: None
---
# LoadBalancer Service for external access (cloud providers)
apiVersion: v1
kind: Service
metadata:
name: app-loadbalancer
namespace: default
spec:
type: LoadBalancer
selector:
app: myapp
ports:
- port: 80
targetPort: 8080
protocol: TCP
externalTrafficPolicy: Local
---
# Ingress for HTTP/HTTPS routing with hostname-based routing
apiVersion: networking.k8s.io/v1
kind: Ingress
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Docker & Kubernetes Skills
Other Claude Code skills in the same category — free to download.
Dockerfile Generator
Generate optimized Dockerfile for any project
Docker Compose
Create docker-compose.yml for multi-service apps
K8s Deployment
Generate Kubernetes deployment manifests
Helm Chart
Create Helm chart for application
Docker Multistage
Optimize Docker builds with multi-stage builds
K8s ConfigMap
Create ConfigMaps and Secrets management
Docker Security
Audit and fix Dockerfile security issues
K8s HPA
Set up Horizontal Pod Autoscaler
Want a Docker & Kubernetes skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.