Skip to content

Commit 762a8d1

Browse files
committed
added ingress for docker-k8s-otel workshop to work with k3d
1 parent 0c6c932 commit 762a8d1

File tree

2 files changed

+59
-23
lines changed

2 files changed

+59
-23
lines changed

content/en/ninja-workshops/8-docker-k8s-otel/8-deploy-app-k8s.md

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,36 @@ spec:
128128
> [!tip]- What is a Service in Kubernetes?
129129
> A Service in Kubernetes is an abstraction layer, working like a middleman, giving you a fixed IP address or DNS name to access your Pods, which stays the same, even if Pods are added, removed, or replaced over time.
130130

131+
Then, create a second file in the same directory named `service.yaml`:
132+
133+
``` bash
134+
vi /home/splunk/ingress.yaml
135+
```
136+
137+
And paste in the following:
138+
139+
``` yaml
140+
apiVersion: networking.k8s.io/v1
141+
kind: Ingress
142+
metadata:
143+
name: helloworld-ingress
144+
annotations:
145+
traefik.ingress.kubernetes.io/router.entrypoints: web
146+
spec:
147+
ingressClassName: traefik
148+
rules:
149+
- host: helloworld.localhost
150+
http:
151+
paths:
152+
- path: /
153+
pathType: Prefix
154+
backend:
155+
service:
156+
name: helloworld
157+
port:
158+
number: 8080
159+
```
160+
131161
We can then use these manifest files to deploy our application:
132162

133163
{{< tabs >}}
@@ -139,6 +169,9 @@ kubectl apply -f deployment.yaml
139169
140170
# create the service
141171
kubectl apply -f service.yaml
172+
173+
# create the ingress
174+
kubectl apply -f ingress.yaml
142175
```
143176

144177
{{% /tab %}}
@@ -154,30 +187,10 @@ service/helloworld created
154187

155188
## Test the Application
156189

157-
To access our application, we need to first get the IP address:
158-
159-
{{< tabs >}}
160-
{{% tab title="Script" %}}
190+
Use the following command to access the application:
161191

162192
``` bash
163-
kubectl describe svc helloworld | grep IP:
164-
```
165-
166-
{{% /tab %}}
167-
{{% tab title="Example Output" %}}
168-
169-
``` bash
170-
IP: 10.43.102.103
171-
```
172-
173-
{{% /tab %}}
174-
{{< /tabs >}}
175-
176-
Then we can access the application by using the Cluster IP that was returned
177-
from the previous command. For example:
178-
179-
``` bash
180-
curl http://10.43.102.103:8080/hello/Kubernetes
193+
curl http://helloworld.localhost/hello/Kubernetes
181194
```
182195

183196
## Configure OpenTelemetry
@@ -260,7 +273,11 @@ deployment.apps/helloworld configured
260273
{{% /tab %}}
261274
{{< /tabs >}}
262275

263-
Then use `curl` to generate some traffic.
276+
Then use the following command to generate some traffic:
277+
278+
``` bash
279+
curl http://helloworld.localhost/hello/Kubernetes
280+
```
264281

265282
After a minute or so, you should see traces flowing in the o11y cloud. But, if you want to see your trace sooner, we have ...
266283

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: helloworld-ingress
5+
annotations:
6+
traefik.ingress.kubernetes.io/router.entrypoints: web
7+
spec:
8+
ingressClassName: traefik
9+
rules:
10+
- host: helloworld.localhost
11+
http:
12+
paths:
13+
- path: /
14+
pathType: Prefix
15+
backend:
16+
service:
17+
name: helloworld
18+
port:
19+
number: 8080

0 commit comments

Comments
 (0)