Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tcarmet/first-setup
First commit
- Loading branch information
Showing
8 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
*.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
# k8s-connection-reset | ||
Sharing code to reproduce an issue with Kubernetes | ||
|
||
## Requisites | ||
To install the following code you'll need | ||
|
||
* A kubernetes cluster. | ||
* `kubectl`. | ||
|
||
## Install steps to reproduce the issue | ||
|
||
### Deploying with skaffold | ||
|
||
If you have [skaffold](https://github.com/GoogleContainerTools/skaffold) | ||
installed. | ||
|
||
```bash | ||
$ skaffold run | ||
# or | ||
$ skaffold dev | ||
``` | ||
|
||
### Deploying with kubectl | ||
|
||
```bash | ||
$ kubectl apply -f kube | ||
``` | ||
|
||
## :warning: Important note :warning: | ||
|
||
Some of the clients pod must be scheduled on a different node | ||
(it can be just one different node) to reproduce the issue. | ||
|
||
We identified that when everything was scheduled on only one node the | ||
problem was harder to reproduce. | ||
|
||
## Identifying the issue | ||
|
||
Check on Stackdriver logging the log from the server and client. | ||
on the search bar you can set `text:'reset by peer'` and you'll see the | ||
following errors: | ||
|
||
```bash | ||
# Error reported by the server | ||
E [info] 11#11: *21885 client 10.20.6.249 closed keepalive connection (104: Connection reset by peer) | ||
# Error reported by the client | ||
E curl: (56) Recv failure: Connection reset by peer | ||
``` | ||
|
||
Both line should follow each other. If the client and the server are not | ||
reporting at the same time a `Connection reset by peer` you can ignore the | ||
event as it might be something else. | ||
|
||
## Troubleshooting | ||
|
||
If the clients seem stuck feel free to restart the pods like the following | ||
`kubectl delete pod -l app=client` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: skaffold/v1beta4 | ||
kind: Config | ||
build: | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- kube/*.yaml |