Skip to content

Commit

Permalink
Update some solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
fireflycons committed Jan 20, 2023
1 parent 59d1d66 commit 816792c
Show file tree
Hide file tree
Showing 6 changed files with 356 additions and 319 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ These are notes from the [Certified Kubernetes Administrator Course](https://kod
- [02-Manual-Scheduling](docs/03-Scheduling/02-Manual-Scheduling.md)
- [03-Practice-Test-Manual-Scheduling](docs/03-Scheduling/03-Practice-Test-Manual-Scheduling.md)
- [04-Labels-and-Selectors](docs/03-Scheduling/04-Labels-and-Selectors.md)
- [05-Practice-Test-Scheduling](docs/03-Scheduling/05-Practice-Test-Scheduling.md)
- [05-Practice-Test-Labels-and-Selectors](docs/03-Scheduling/05-Practice-Test-Labels-and-Selectors.md)
- [06-Taints-and-Tolerations](docs/03-Scheduling/06-Taints-and-Tolerations.md)
- [07-Practice-Test-Taints-and-Tolerations](docs/03-Scheduling/07-Practice-Test-Taints-and-Tolerations.md)
- [08-Node-Selectors](docs/03-Scheduling/08-Node-Selectors.md)
Expand Down
83 changes: 49 additions & 34 deletions docs/03-Scheduling/03-Practice-Test-Manual-Scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,67 @@

Solutions to Practice Test - Manual Scheduling

- Run, **`kubectl create -f nginx.yaml`**

<details>
1. <details>
<summary>A pod definition file nginx.yaml is given. Create a pod using the file.</summary>

```
$ kubectl create -f nginx.yaml
```
</details>
```
kubectl create -f nginx.yaml
```
</details>
- Run the command 'kubectl get pods' and check the status column
1. <details>
<summary>What is the status of the created POD?</summary>
<details>
```
kubectl get pods
```
```
$ kubectl get pods
```
</details>
Examine the `STATUS` column
</details>
- Run the command 'kubectl get pods --namespace kube-system'
1. <details>
<summary>Why is the POD in a pending state?</br>Inspect the environment for various kubernetes control plane components.</summary>
<details>
```
kubectl get pods --namespace kube-system
```
```
$ kubectl get pods --namespace kube-system
```
</details>
There is a key pod missing here!
</details>
- Set **`nodeName`** property on the pod to node01 node
1. <details>
<summary>Manually schedule the pod on node01.</summary>
<details>
We will have to delete and recereate the pod, as the only property that may be edited on a running container is `image`
```
$ vi nginx.yaml
$ kubectl delete -f nginx.yaml
$ kubectl create -f nginx.yaml
```
</details>
```
vi nginx.yaml
```
Make the following edit
```yaml
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
nodeName: node01 # add this line
containers:
- image: nginx
name: nginx
```
- Set **`nodeName`** property on the pod to master node
```
kubectl delete -f nginx.yaml
kubectl create -f nginx.yaml
```
</details>
<details>
1. <details>
<summary>Now schedule the same pod on the controlplane node.</summary>
```
$ vi nginx.yaml
$ kubectl delete -f nginx.yaml
$ kubectl create -f nginx.yaml
```
Repeat the steps as per the previous question. Edit `nodeName` to be `controlplane`
</details>
67 changes: 67 additions & 0 deletions docs/03-Scheduling/05-Practice-Test-Labels-and-Selectors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Practice Test - Labels and Selectors
- Take me to [Practice Test](https://kodekloud.com/topic/practice-test-labels-and-selectors/)

Solutions to Practice Test - Labels and Selectors
1. <details>
<summary>We have deployed a number of PODs. They are labelled with tier, env and bu. How many PODs exist in the dev environment (env)?</summary>

Here we are filtering pods by the value olf a label

```
kubectl get pods --selector env=dev
```
Count the pods (if any)
</details>
1. <details>
<summary>How many PODs are in the finance business unit (bu)?</summary>
Similarly ...
```
kubectl get pods --selector bu=finance
```
Count the pods (if any)
</details>
1. <details>
<summary>How many objects are in the prod environment including PODs, ReplicaSets and any other objects?</summary>
```
kubectl get all --selector env=prod
```
Count everything (if anything)
</details>
1. <details>
<summary>Identify the POD which is part of the prod environment, the finance BU and of frontend tier?</summary>
We can combine label expressions with comma. Only items with _all_ the given label/value pairs will be returned, i.e. it is an `and` condition.
```
kubectl get all --selector env=prod,bu=finance,tier=frontend
```
</details>
1. <details>
<summary>A ReplicaSet definition file is given replicaset-definition-1.yaml. Try to create the replicaset. There is an issue with the file. Try to fix it.</summary>
```
kubectl create -f replicaset-definition-1.yaml
```
Note the error message.
Selector matchLabels should match with POD labels - Update `replicaset-definition-2.yaml`
The values for labels on lines 9 and 13 should match.
```
$ kubectl create -f replicaset-definition-2.yaml
```
</details>
49 changes: 0 additions & 49 deletions docs/03-Scheduling/05-Practice-Test-Scheduling.md

This file was deleted.

Loading

0 comments on commit 816792c

Please sign in to comment.