Created
February 23, 2024 16:24
-
-
Save peterj/a01ef6a0b6408657cf7e9750e1024d79 to your computer and use it in GitHub Desktop.
stateful set stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: httpbin-statefulset | |
spec: | |
serviceName: httpbin | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: httpbin | |
template: | |
metadata: | |
labels: | |
app: httpbin | |
selector: httpbin | |
spec: | |
containers: | |
- image: docker.io/kong/httpbin | |
imagePullPolicy: IfNotPresent | |
name: httpbin | |
# Same as found in Dockerfile's CMD but using an unprivileged port | |
command: | |
- gunicorn | |
- -b | |
- 0.0.0.0:8080 | |
- httpbin:app | |
- -k | |
- gevent | |
env: | |
# Tells pipenv to use a writable directory instead of $HOME | |
- name: WORKON_HOME | |
value: /tmp | |
ports: | |
- containerPort: 8080 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: httpbin | |
labels: | |
app: httpbin | |
spec: | |
clusterIP: None | |
selector: | |
app: httpbin | |
ports: | |
- port: 80 | |
targetPort: 8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming you've scaled up the set, you can run
nslookup
(from another pod) against the service name:Note the 3 IP address at the end correspond to the pods' IP addresses. Then, if you do nslookup against any of the instances:
And doing
curl httpbin-statefulset-0.httpbin.default.svc.cluster.local:8080/headers
will send a response to the pod 0.