Skip to content

Commit fb32030

Browse files
dragetddchaykin
authored andcommitted
Use consistent markdown lists for commands and code
1 parent b31e73c commit fb32030

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

README.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A picture serves to illustrate the communication:
3131
`kind` unfortunately doesn't use the environment variable `GOPATH`, so we have to update this in [config.yaml](cluster/config.yaml#L21):
3232

3333
```sh
34-
`sed -i.bak 's|'{GOPATH}'|'${GOPATH}'|g' cluster/config.yaml`
34+
sed -i.bak 's|'{GOPATH}'|'${GOPATH}'|g' cluster/config.yaml
3535
```
3636

3737
You can also open [config.yaml](cluster/config.yaml#L21) and replace `{GOPATH}` with the absolute path manually. If you already installed kind (Kubernetes in Docker) on your local system, you can create the cluster with this command:
@@ -115,7 +115,9 @@ We suggest labelling a worker node where the pod is going to be deployed. By def
115115

116116
So, we label a worker node with _debug=true_:
117117

118-
`kubectl label nodes local-debug-k8s-worker debug=true`
118+
```sh
119+
kubectl label nodes local-debug-k8s-worker debug=true
120+
```
119121

120122
### Creating a docker image
121123

@@ -144,21 +146,29 @@ ENTRYPOINT ["/go/bin/dlv", "debug", ".", "--listen=:30123", "--accept-multiclien
144146

145147
First, build the docker image locally:
146148

147-
`docker build -t setlog/debug-k8s .`
149+
```sh
150+
docker build -t setlog/debug-k8s .
151+
```
148152

149153
Load the docker image into the node _local-debug-k8s-worker_:
150154

151-
`kind load docker-image setlog/debug-k8s:latest --name=local-debug-k8s --nodes=local-debug-k8s-worker`
155+
```sh
156+
kind load docker-image setlog/debug-k8s:latest --name=local-debug-k8s --nodes=local-debug-k8s-worker
157+
```
152158

153159
This message will be shown, and it is just saying that the image was not there:
154160

161+
```
155162
Image: "setlog/debug-k8s:latest" with ID "sha256:944baa03d49698b9ca1f22e1ce87b801a20ce5aa52ccfc648a6c82cf8708a783" not present on node "local-debug-k8s-worker"
163+
```
156164

157165
### Starting the delve server in the cluster
158166

159167
Now we want to create a persistent volume and its claim in order to mount the project path into the worker node:
160168

161-
`kubectl create -f cluster/persistent-volume.yaml`
169+
```sh
170+
kubectl create -f cluster/persistent-volume.yaml
171+
```
162172

163173
The interesting part here is:
164174

@@ -173,24 +183,31 @@ Let's take a look at the full chain of mounting the local project path into the
173183

174184
Check, if your persistent volume claim has been successfully created (STATUS must be Bound):
175185

176-
`kubectl get pvc`
186+
```sh
187+
kubectl get pvc
177188

178189
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
179190
go-pvc Bound go-pv 256Mi RWO hostpath 51s
191+
```
180192

181193
You are ready to start the service in debug mode:
182194

183-
`kubectl create -f cluster/deploy-service.yaml`
195+
```sh
196+
kubectl create -f cluster/deploy-service.yaml
197+
```
184198

185199
Let's go through the deployment.
186200

187201
* Image name is what we loaded into the kind cluster with the command `kind load image...`. _imagePullPolicy_ must be set to _IfNotPresent_, because it is already loaded, we don't want Kubernetes to try loading it again.
188202

189-
image: setlog/debug-k8s:latest
190-
imagePullPolicy: IfNotPresent
203+
```yaml
204+
image: setlog/debug-k8s:latest
205+
imagePullPolicy: IfNotPresent
206+
```
191207
192208
* We use the persistent volume claim to mount the project path into the pod and make `/go/src` to be linked with `${GOPATH}/src` on your computer:
193209

210+
```yaml
194211
containers:
195212
- name: debug-k8s
196213
...
@@ -201,19 +218,22 @@ Let's go through the deployment.
201218
- name: go-volume
202219
persistentVolumeClaim:
203220
claimName: go-pvc
221+
````
204222
205223
* As there might be several workers in your cluster, we deploy the pod on the one, that is labelled with _debug=true_. The docker image _setlog/debug-k8s_ has been loaded earlier in it already.
206224
225+
```yaml
207226
nodeSelector:
208227
debug: "true"
228+
```
209229
210230
* Service _service-debug_ has the type _NodePort_ and is mounted into the worker node. This port 30123 is equal to the parameter _--listen=:30123_ in the Dockerfile, which makes it possible to send debug commands to the delve server.
211231
212232
* Service _debug-k8s_ will be connected to the ingress server in the final step. It serves for exposing the API endpoints we are going to debug.
213233
214234
If you did all steps correctly, your pod should be up and running. Check it with `kubectl get pod`. You should see the output with the pod status _Running_ and two additional services _debug-k8s_ and _service-debug_:
215235

216-
```sh
236+
```
217237
NAME READY STATUS RESTARTS AGE
218238
pod/debug-k8s-6d69b65cf-4fl6t 1/1 Running 0 1h
219239

@@ -230,8 +250,9 @@ Usually it takes a couple of seconds to start the debugging process with delve.
230250
Also, you can output logs of the pod by performing `kubectl logs $PODNAME` in order to make sure the delve API server is listening at 30123.
231251
232252
Output:
233-
253+
```
234254
API server listening at: [::]:30123
255+
```
235256
236257
_Hint: always wait until this log message is shown for this pod before you start the debugging process. Otherwise, the delve server is not up yet and cannot answer to the debugger._
237258
@@ -269,11 +290,15 @@ After starting the debug process there is a new log created by the go service:
269290

270291
We are ready to debug, but we have to trigger the API functions through the ingress service. Deploy it with kubectl:
271292

272-
`kubectl create -f cluster/ingress.yaml`
293+
```sh
294+
kubectl create -f cluster/ingress.yaml
295+
```
273296

274297
And try accessing it now:
275298

276-
`curl http://localhost:8090/hello`
299+
```sh
300+
curl http://localhost:8090/hello
301+
```
277302

278303
Which should trigger the debugger:
279304

@@ -285,4 +310,6 @@ Happy debugging!
285310

286311
If you don't need your kind cluster anymore, it can be removed with following command:
287312

288-
`kind delete cluster --name=local-debug-k8s`
313+
```sh
314+
kind delete cluster --name=local-debug-k8s
315+
```

0 commit comments

Comments
 (0)