<commit_before># Creating and managing pods

At the core of Kubernetes is the Pod. Pods hold a collection of one or more containers and volumes and represent a logical application. In this lab you will learn how to:

* Write a Pod configuration file
* Create and delete Pods
* Interact with Pods remotely using kubectl

## Tutorial: Creating Pods

Explore the `monolith` pod configuration file:

```
cat pods/monolith.yaml
```

```
kubectl create -f pods/monolith.yaml
```

### Listing Pods

```
kubectl get pods
```

### Pod info

```
kubectl describe pods monolith
```

### Port Forwarding

```
kubectl port-forward monolith 10080:80
```

```
curl http://1172.16.17.32:10080
```

### Logs

```
kubectl logs monolith
```

### Exec

```
kubectl exec monolith --stdin --tty -c monolith /bin/sh
```

### Delete

```
kubectl delete pods monolith
```<commit_msg>update labs<commit_after># Creating and managing pods

At the core of Kubernetes is the Pod. Pods hold a collection of one or more containers and volumes and represent a logical application. In this lab you will learn how to:

* Write a Pod configuration file
* Create and delete Pods
* Interact with Pods remotely using kubectl

## Tutorial: Creating Pods

Explore the `monolith` pod configuration file:

```
cat pods/monolith.yaml
```

Create the `monolith` pod using kubectl:

```
kubectl create -f pods/monolith.yaml
```

## Exercise: View Pod details

Use the `kubectl get` and `kubect describe` commands to view details for `monolith` Pod:

Hints

```
kubectl get pods <pod-name>
```

```
kubectl describe pods <pod-name>
```

* What is the IP address of the `monolith` pod?
* What node is the `monolith` pod running on?

## Exercise: Interact with a Pod remotely

Pods are allocated a private IP address by default and cannot be reached outside of the cluster. In this exercise use the `kubectl port-forward` command to map a local port to a port inside the `monolith` pod. 

Hints 

```
kubectl port-forward monolith 10080:80
```

```
curl http://127.0.0.1:10080
```

```
curl http://127.0.0.1:10080/secure
```

```
curl http://127.0.0.1:10080/login
```

```
curl http://127.0.0.1:10080/secure
```

## Exercise: View the logs of a Pod

Use the `kubectl logs` command to view the logs for the `monolith` Pod:

```
kubectl logs monolith
```

> Use the -f flag and observe what happens.

## Exercise: Run an interactive shell inside a Pod

Use the `kubectl exec` command to run an interactive shell inside the `monolith` Pod:

```
kubectl exec monolith --stdin --tty -c monolith /bin/sh
```
{'fraction_non_alphanumeric': 0.11437524481002742, 'fraction_numerical': 0.028593811202506855, 'mean_word_length': 3.978557504873294, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6419101', 'n_tokens_mistral': 966, 'n_tokens_neox': 828, 'n_words': 340}