Created
February 8, 2019 19:56
-
-
Save ihcsim/02535331862136a5b876d65ac6a87de7 to your computer and use it in GitHub Desktop.
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
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: redis | |
labels: | |
app: redis | |
spec: | |
selector: | |
app: redis | |
ports: | |
- name: redis | |
port: 6379 | |
targetPort: redis | |
--- | |
kind: StatefulSet | |
apiVersion: apps/v1 | |
metadata: | |
name: redis | |
labels: | |
app: redis | |
spec: | |
replicas: 3 | |
serviceName: redis | |
selector: | |
matchLabels: | |
app: redis | |
template: | |
metadata: | |
labels: | |
app: redis | |
spec: | |
initContainers: | |
- name: init | |
image: redis | |
command: | |
- /bin/bash | |
- "-c" | |
- | | |
redis-server & | |
sleep 1s | |
redis-cli set hostname $${HOSTNAME} | |
redis-cli shutdown | |
volumeMounts: | |
- name: data | |
mountPath: /data | |
containers: | |
- name: redis | |
image: redis | |
ports: | |
- containerPort: 6379 | |
name: redis | |
volumeMounts: | |
- name: data | |
mountPath: /data | |
volumeClaimTemplates: | |
- metadata: | |
name: data | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 10Gi | |
--- | |
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: nginx | |
labels: | |
app: nginx | |
spec: | |
selector: | |
app: nginx | |
ports: | |
- name: http | |
port: 80 | |
targetPort: http | |
--- | |
kind: StatefulSet | |
apiVersion: apps/v1 | |
metadata: | |
name: nginx | |
labels: | |
app: nginx | |
spec: | |
replicas: 3 | |
serviceName: nginx | |
selector: | |
matchLabels: | |
app: nginx | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
initContainers: | |
- name: init | |
image: alpine | |
command: | |
- /bin/sh | |
- "-c" | |
- | | |
echo "hello $${HOSTNAME}" > /www/index.html | |
volumeMounts: | |
- name: www | |
mountPath: /www | |
containers: | |
- name: nginx | |
image: nginx | |
ports: | |
- containerPort: 80 | |
name: http | |
volumeMounts: | |
- name: www | |
mountPath: /usr/share/nginx/html | |
volumeClaimTemplates: | |
- metadata: | |
name: www | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 10Gi | |
--- | |
kind: Pod | |
apiVersion: v1 | |
metadata: | |
name: curl | |
labels: | |
app: curl | |
spec: | |
restartPolicy: Never | |
containers: | |
- name: curl | |
image: appropriate/curl | |
command: | |
- /bin/sh | |
- "-c" | |
- | | |
while : ; do | |
curl --silent nginx.default | |
sleep 0.5s | |
done | |
--- | |
kind: Pod | |
apiVersion: v1 | |
metadata: | |
name: redis-cli | |
labels: | |
app: redis-cli | |
spec: | |
restartPolicy: Never | |
containers: | |
- name: redis-cli | |
image: redis | |
command: | |
- /bin/bash | |
- "-c" | |
- | | |
while : ; do | |
redis-cli -h redis get hostname | |
sleep 0.5s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment