Skip to content

Instantly share code, notes, and snippets.

@shudipta
Created November 7, 2019 10:53
Show Gist options
  • Save shudipta/cc4376cfcf63fb026e6c7e52559fc69b to your computer and use it in GitHub Desktop.
Save shudipta/cc4376cfcf63fb026e6c7e52559fc69b to your computer and use it in GitHub Desktop.
$ kubectl create -f sts-svc.yaml
$ kubectl logs -f web-0
PING web-0.test (10.28.0.104): 56 data bytes
64 bytes from 10.28.0.104: seq=0 ttl=64 time=0.029 ms
--- web-0.test ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.029/0.029/0.029 ms
PING web-1.test (10.28.2.71): 56 data bytes
64 bytes from 10.28.2.71: seq=0 ttl=62 time=1.357 ms
--- web-1.test ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.357/1.357/1.357 ms
PING web-2.test (10.28.1.81): 56 data bytes
64 bytes from 10.28.1.81: seq=0 ttl=62 time=1.515 ms
--- web-2.test ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.515/1.515/1.515 ms
apiVersion: v1
kind: Service
metadata:
name: test
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
tier: backend
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "test"
replicas: 3
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
tier: backend
spec:
containers:
- name: test
image: busybox
command:
- sh
- -c
- |
sleep 10
ping web-0.test -c 1
echo
ping web-1.test -c 1
echo
ping web-2.test -c 1
echo
sleep 5
ports:
- containerPort: 80
name: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment