Skip to content

Commit

Permalink
Add k8s questions
Browse files Browse the repository at this point in the history
Updated CKA page as well.
  • Loading branch information
abregman committed Oct 21, 2022
1 parent ad66a50 commit 422a48a
Show file tree
Hide file tree
Showing 5 changed files with 551 additions and 76 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE

:bar_chart:  There are currently **2354** exercises and questions
:bar_chart:  There are currently **2406** exercises and questions

:books:  To learn more about DevOps and SRE, check the resources in [devops-resources](https://github.com/bregman-arie/devops-resources) repository

Expand Down
41 changes: 41 additions & 0 deletions topics/circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Use the CLI to access advanced tools locally.
Get flaky test detection with test insights."
</b></details>

<details>
<summary>Explain the following:

* Pipeline
* Workflow
* Jobs
* Steps
</summary><br><b>

* Pipeline: the entire CI/CD configuration (.circleci/config.yaml)
* Workflow: primarily used when there is more than one job in the configuration to orchestrate the workflows
* Jobs: One or more steps to execute as part of the CI/CD process
* Steps: The actual commands to execute
</b></details>

<details>
<summary>What is an Orb?</summary><br><b>
Expand All @@ -41,4 +55,31 @@ They can come from the public registry or defined privately as part of an organi
<summary>Where (in what location in the project) Circle CI pipelines are defined?</summary><br><b>

`.circleci/config.yml`
</b></details>

<details>
<summary>Explain the following configuration file


```
version: 2.1
jobs:
say-hello:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Say hello"
command: "echo Hello, World!"
workflows:
say-hello-workflow:
jobs:
- say-hello
```
</summary><br><b>

This configuration file will set up one job that will checkout the code of the project will run the command `echo Hello, World!`.
It will run in a container using the image `cimg/base:stable`.
</b></details>
98 changes: 98 additions & 0 deletions topics/kubernetes/CKA.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [Labels and Selectors](#labels-and-selectors)
- [Node Selector](#node-selector)
- [Taints](#taints)
- [Resources Limits](#resources-limits)

## Setup

Expand Down Expand Up @@ -255,6 +256,12 @@ Note: create an alias (`alias k=kubectl`) and get used to `k get no`
`k get nodes -o json > some_nodes.json`
</b></details>

<details>
<summary>Check what labels one of your nodes in the cluster has</summary><br><b>

`k get no minikube --show-labels`
</b></details>

## Services

<details>
Expand Down Expand Up @@ -450,6 +457,42 @@ The selector doesn't match the label (cache vs cachy). To solve it, fix cachy so

</b></details>

<details>
<summary>Create a deployment called "pluck" using the image "redis" and make sure it runs 5 replicas</summary><br><b>

`kubectl create deployment pluck --image=redis`

`kubectl scale deployment pluck --replicas=5`

</b></details>

<details>
<summary>Create a deployment with the following properties:

* called "blufer"
* using the image "python"
* runs 3 replicas
* all pods will be placed on a node that has the label "blufer"
</summary><br><b>

`kubectl create deployment blufer --image=python --replicas=3 -o yaml --dry-run=client > deployment.yaml`

Add the following section (`vi deployment.yaml`):

```
spec:
affinity:
nodeAffinity:
requiredDuringSchedlingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: blufer
operator: Exists
```

`kubectl apply -f deployment.yaml`
</b></details>

### Troubleshooting Deployments

<details>
Expand Down Expand Up @@ -671,4 +714,59 @@ Exit and save. The pod should be in Running state now.
<summary>Remove an existing taint from one of the nodes in your cluster</summary><br><b>
`k taint node minikube app=web:NoSchedule-`
</b></details>
## Resources Limits
<details>
<summary>Check if there are any limits on one of the pods in your cluster</summary><br><b>
`kubectl describe po <POD_NAME> | grep -i limits`
</b></details>
<details>
<summary>Run a pod called "yay" with the image "python" and resources request of 64Mi memory and 250m CPU</summary><br><b>
`kubectl run yay --image=python --dry-run=client -o yaml > pod.yaml`
`vi pod.yaml`
```
spec:
containers:
- image: python
imagePullPolicy: Always
name: yay
resources:
requests:
cpu: 250m
memory: 64Mi
```
`kubectl apply -f pod.yaml`
</b></details>
<details>
<summary>Run a pod called "yay2" with the image "python". Make sure it has resources request of 64Mi memory and 250m CPU and the limits are 128Mi memory and 500m CPU</summary><br><b>
`kubectl run yay2 --image=python --dry-run=client -o yaml > pod.yaml`
`vi pod.yaml`
```
spec:
containers:
- image: python
imagePullPolicy: Always
name: yay2
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 250m
memory: 64Mi
```
`kubectl apply -f pod.yaml`
</b></details>
Loading

0 comments on commit 422a48a

Please sign in to comment.