Skip to content

Instantly share code, notes, and snippets.

@tennix
Created October 22, 2019 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tennix/9deed74c5ce2e695be45ff6ff4d096a9 to your computer and use it in GitHub Desktop.
Save tennix/9deed74c5ce2e695be45ff6ff4d096a9 to your computer and use it in GitHub Desktop.
k8s dns checker

To verify if the DNS service is normal in a Kubernetes cluster. We can deploy a simple service to diagnose this:

$ kubectl apply -f nginx.yaml
$ kubectl exec -it web-0 sh # enter web-0 pod to resolve the other two pods domain name.
/ # nslookup web-1.nginx
/ # nslookup web-2 nginx
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx
serviceName: nginx
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.11-alpine
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment