Created
December 10, 2019 22:32
-
-
Save nithu0115/da2049f6192e7af71d3930375cc762e2 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
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: config-nginx | |
data: | |
default.conf: | | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
error_log /var/log/nginx/error.log debug; | |
server_name localhost; | |
location / { | |
root /data; | |
} | |
} | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx | |
labels: | |
app: nginx | |
spec: | |
sessionAffinity: ClientIP | |
ports: | |
- name: http | |
port: 80 | |
targetPort: 80 | |
protocol: TCP | |
selector: | |
app: nginx | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx | |
labels: | |
app: nginx | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: nginx | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
initContainers: | |
- name: create-content | |
image: alpine | |
command: ['/bin/sh', '-c'] | |
args: ['dd if=/dev/urandom of=/data/small-file.txt bs=1M count=4'] | |
volumeMounts: | |
- name: workspace | |
mountPath: /data | |
containers: | |
- name: nginx | |
image: nginx:1.15.1-alpine | |
imagePullPolicy: "IfNotPresent" | |
ports: | |
- name: http | |
containerPort: 80 | |
resources: | |
limits: | |
cpu: "1" | |
memory: 1Gi | |
requests: | |
cpu: "1" | |
memory: 1Gi | |
volumeMounts: | |
- name: workspace | |
mountPath: /data | |
- name: config-nginx | |
mountPath: /etc/nginx/conf.d/ | |
volumes: | |
- name: workspace | |
emptyDir: | |
- name: config-nginx | |
configMap: | |
name: config-nginx | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: client | |
labels: | |
app: client | |
spec: | |
replicas: 10 | |
selector: | |
matchLabels: | |
app: client | |
template: | |
metadata: | |
labels: | |
app: client | |
spec: | |
containers: | |
- name: client-connection-reset | |
image: byrnedo/alpine-curl:0.1.7 | |
imagePullPolicy: "IfNotPresent" | |
command: ['/bin/sh', '-c'] | |
args: ['/client.sh http://nginx/small-file.txt'] | |
volumeMounts: | |
- name: workspace | |
mountPath: /tmp | |
- name: client-script | |
mountPath: /client.sh | |
subPath: client.sh | |
volumes: | |
- name: workspace | |
emptyDir: | |
- name: client-script | |
configMap: | |
name: client-script | |
defaultMode: 0755 | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: client-script | |
data: | |
client.sh: | | |
#!/bin/sh | |
# $1 file url | |
# waiting for the server to be available | |
sleep 10 | |
while true; do | |
curl -o file.txt $1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment