Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions content/en/tko/session-5/docs/deploy-apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Domain Name System (DNS) is a mechanism for linking various sorts of informa

Most Kubernetes clusters include an internal DNS service configured by default to offer a lightweight approach for service discovery. Even when Pods and Services are created, deleted, or shifted between nodes, built-in service discovery simplifies applications to identify and communicate with services on the Kubernetes clusters.

In short the DNS system for Kubernetes will create a DNS entry for each Pod and Service. In general a Pod has the following DNS resolution:
In short, the DNS system for Kubernetes will create a DNS entry for each Pod and Service. In general, a Pod has the following DNS resolution:

``` text
pod-name.my-namespace.pod.cluster-domain.example
Expand All @@ -32,7 +32,13 @@ More information can be found here : [DNS for Service and Pods](https://kubernet

## 2. Review OTel receiver for PHP/Apache

Inspect the YAML file `~/workshop/k3s/otel-apache.yaml` and validate the contents. This file contains the configuration for the OpenTelemetry agent to monitor the PHP/Apache deployment.
Inspect the YAML file `~/workshop/k3s/otel-apache.yaml` and validate the contents using the following command:

``` bash
cat ~/workshop/k3s/otel-apache.yaml
```

This file contains the configuration for the OpenTelemetry agent to monitor the PHP/Apache deployment.

{{< tabpane >}}
{{< tab header="~/workshop/k3s/otel-apache.yaml" lang="yaml" >}}
Expand All @@ -54,7 +60,7 @@ agent:

The above file contains an observation rule for Apache using the OTel `receiver_creator`. This receiver can instantiate other receivers at runtime based on whether observed endpoints match a configured rule.

The configured rules will be evaluated for each endpoint discovered. If the rule evaluates to true then the receiver for that rule will be started as configured against the matched endpoint.
The configured rules will be evaluated for each endpoint discovered. If the rule evaluates to true, then the receiver for that rule will be started as configured against the matched endpoint.

In the file above we tell the OpenTelemetry agent to look for Pods that match the name `apache` and have port `80` open. Once found, the agent will configure an Apache receiver to read Apache metrics from the configured URL. Note, the K8s DNS based URL in the above YAML for the service.

Expand All @@ -79,7 +85,7 @@ helm upgrade splunk-otel-collector --set="splunkObservability.realm=$REALM" --se
{{< /tabpane >}}

{{% alert title="Note" color="info" %}}
The **REVISION** number of the deployment has changed (a way to keep track of your changes).
The **REVISION** number of the deployment has changed, which is a helpful way to keep track of your changes.

``` text
Release "splunk-otel-collector" has been upgraded. Happy Helming!
Expand All @@ -95,9 +101,9 @@ TEST SUITE: None

## 4. Kubernetes ConfigMaps

A ConfigMap is an object in Kubernetes consisting of key-value pairs which can be injected into your application. With a ConfigMap you can separate configuration from your Pods.
A ConfigMap is an object in Kubernetes consisting of key-value pairs which can be injected into your application. With a ConfigMap, you can separate configuration from your Pods.

This way, you can prevent hardcoding configuration data. ConfigMaps are useful for storing and sharing non-sensitive, unencrypted configuration information.
Using ConfigMap, you can prevent hardcoding configuration data. ConfigMaps are useful for storing and sharing non-sensitive, unencrypted configuration information.

The OpenTelemetry collector/agent uses ConfigMaps to store the configuration of the agent and the K8s Cluster receiver. You can/will always verify the current configuration of an agent after a change by running the following commands:

Expand All @@ -123,9 +129,15 @@ Is the content of `otel-apache.yaml` saved in the ConfigMap for the collector ag

## 5. Review PHP/Apache deployment YAML

Inspect the YAML file `~/workshop/k3s/php-apache.yaml` and validate the contents. This file contains the configuration for the PHP/Apache deployment and will create a new StatefulSet with a single replica of the PHP/Apache image.
Inspect the YAML file `~/workshop/k3s/php-apache.yaml` and validate the contents using the following command:

``` bash
cat ~/workshop/k3s/otel-apache.yaml
```

This file contains the configuration for the PHP/Apache deployment and will create a new StatefulSet with a single replica of the PHP/Apache image.

A stateless application is one that does not care which network it is using, and it does not need permanent storage. Examples of stateless apps may include web servers (Apache, Nginx, or Tomcat).
A stateless application is one that does not care which network it is using, and it does not need permanent storage. Examples of stateless apps may include web servers such as Apache, Nginx, or Tomcat.

{{< tabpane >}}
{{< tab header="~/workshop/k3s/php-apache.yaml" lang="yaml" >}}
Expand Down Expand Up @@ -176,7 +188,7 @@ spec:

## 6. Deploy PHP/Apache

Save the above file and deploy the PHP/Apache application to the cluster.
Create an apache namespace then deploy the PHP/Apache application to the cluster.

Create the `apache` namespace:

Expand Down
18 changes: 14 additions & 4 deletions content/en/tko/session-5/docs/fix-apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ weight: 4
---
## 1. Kubernetes Resources

Especially in Production Kubernetes Clusters, CPU and Memory are considered precious resources. And the Cluster operators will normally require you to specify in the deployment the amount of CPU and Memory your Pod or Service will require, so they can have the Cluster automatically manage on which Node(s) your solution will be placed.
Especially in Production Kubernetes Clusters, CPU and Memory are considered precious resources. Cluster Operators will normally require you to specify the amount of CPU and Memory your Pod or Service will require in the deployment, so they can have the Cluster automatically manage on which Node(s) your solution will be placed.

You do this by placing a Resource section in the deployment of you application/Pod

Expand Down Expand Up @@ -37,7 +37,11 @@ Before we start, let's check the current status of the PHP/Apache deployment. Un

{{% /alert %}}

To fix the PHP/Apache StatefulSet, edit `~/workshop/k3s/php-apache.yaml` and reduce the CPU resources further:
To fix the PHP/Apache StatefulSet, edit `~/workshop/k3s/php-apache.yaml` using the following commands to reduce the CPU resources:

``` bash
vim ~/workshop/k3s/php-apache.yaml
```

Find the resources section and reduce the CPU limits to **1** and the CPU requests to **0.5**:

Expand All @@ -51,12 +55,15 @@ resources:
memory: "4Mi"
```

Save the above changes. Now, we must delete the existing StatefulSet and re-create it. StatefulSets are immutable, so we must delete the existing one and re-create it with the new changes.
Save the changes youhave made. (Hint: Use `Esc` followed by `:wq!` to save your changes).

Now, we must delete the existing StatefulSet and re-create it. StatefulSets are immutable, so we must delete the existing one and re-create it with the new changes.

``` bash
kubectl delete statefulset php-apache -n apache
```

```
Now, deploy your changes:
``` bash
kubectl apply -f ~/workshop/k3s/php-apache.yaml -n apache
```
Expand All @@ -83,6 +90,8 @@ Another Auto-Detect Detector has fired, which one is it this time?

## 4. Fix memory issue

Let's edit the stateful set and increase the memory to what is shown in the image below:

``` bash
kubectl edit statefulset php-apache -n apache
```
Expand All @@ -96,6 +105,7 @@ resources:
cpu: "0.5"
memory: "12Mi"
```
Save the changes youhave made. (Hint: Use `Esc` followed by `:wq!` to save your changes).

Because the StatefulSet is immutable, we must delete the existing Pod and let the StatefulSet re-create it with the new changes.

Expand Down