Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 9 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"cSpell.words": [
"istio",
"kubectl",
"kustomization",
"kustomize"
],
"cSpell.ignoreWords": [
"istio"
]
}
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/.hg/store/**": true,
"**/mkdocs-site/**": true
},
"files.useExperimentalFileWatcher": true
}
45 changes: 3 additions & 42 deletions Labs/00-VerifyCluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@
- **`kubectl`** - short for Kubernetes Controller - is the CLI for Kubernetes cluster and is required in order to be able to run the labs.
- In order to install `kubectl` and if required creating a local cluster, please refer to [Kubernetes - Install Tools](https://kubernetes.io/docs/tasks/tools/)

<!-- inPage TOC start -->

---
## Lab Highlights:
- [01. Installing minikube](#01-Installing-minikube)
- [02. Start minikube](#02-Start-minikube)
- [03. Check the minikube status](#03-Check-the-minikube-status)
- [04. Verify that the cluster is up and running](#04-Verify-that-the-cluster-is-up-and-running)
- [05. Verify that you can &#34;talk&#34; to your cluster](#05-Verify-that-you-can-talk-to-your-cluster)
- [05.01. Verify that you can &#34;talk&#34; to your cluster](#0501-Verify-that-you-can-talk-to-your-cluster)

---

<!-- inPage TOC end -->

### 01. Installing minikube

- If you don't have an existing cluster you can use google cloud for the labs hands-on
Expand Down Expand Up @@ -96,12 +83,13 @@ Kubernetes control plane is running at https://192.168.49.2:8443
KubeDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
```

- Verify that `kubectl` is installed and configured (You should get something like the following)
- Verify that `kubectl` is installed and configured

```sh
kubectl config view
```

- You should get something like the following
```yaml
apiVersion: v1
clusters:
Expand Down Expand Up @@ -132,31 +120,4 @@ users:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 3m9s v1.20.0
```

### 05.01. Verify that you can "talk" to your cluster

```sh
# In this sample we have minikube pod running
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 3m9s v1.20.0
```

<!-- navigation start -->

---

<div align="center">
<a href="../01-Namespace">01-Namespace</a>
&nbsp; :arrow_right:</div>

---

<div align="center">
<small>&copy;CodeWizard LTD</small>
</div>

![Visitor Badge](https://visitor-badge.laobi.icu/badge?page_id=nirgeier)

<!-- navigation end -->
```
61 changes: 15 additions & 46 deletions Labs/01-Namespace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,13 @@
# Namespaces

- Kubernetes supports **multiple virtual clusters** backed by the same **physical cluster**.
- These virtual clusters are called namespaces.
- Namespaces are the default way for Kubernetes to separate resources.
- Using name spaces we can isolate the development, improve security and more.
- Kubernetes clusters has a build in namespace called **default** and might contain more namespaces like like `kube-system` for example.

<!-- inPage TOC start -->

---
## Lab Highlights:
- [K8S Hands-on](#k8s-hands-on)
- [Namespaces](#namespaces)
- [Lab Highlights:](#lab-highlights)
- [Pre-Requirements](#pre-requirements)
- [01. Create Namespace](#01-create-namespace)
- [01.01. Create Namespace](#0101-create-namespace)
- [02. Setting the default Namespace for `kubectl`](#02-setting-the-default-namespace-for-kubectl)
- [03. Verify that you've updated the namespace](#03-verify-that-youve-updated-the-namespace)
- [Note:](#note)
- These virtual clusters are called `namespaces`.
- `Namespaces` are the default way for Kubernetes to separate resources.
- Using `namespaces` we can isolate the development, improve security and much more.
- Kubernetes clusters has a builtin `namespace` called **default** and might contain more `namespaces`, like `kube-system`, for example.

---

<!-- inPage TOC end -->

### Pre-Requirements

Expand All @@ -43,17 +28,17 @@

### 01. Create Namespace

### 01.01. Create Namespace

```sh
# In this sample `codewizard` is the desired name space
# In this sample `codewizard` is the desired namespace
$ kubectl create namespace codewizard
namespace "codewizard" created
namespace/codewizard created

### !!! Try to create the following name space (with _ & -):
### !!! Try to create the following namespace (with _ & -), and see what happens:
$ kubectl create namespace my_namespace-
```

---

### 02. Setting the default Namespace for `kubectl`

- To set the default namespace run:
Expand All @@ -64,6 +49,8 @@ $ kubectl config set-context $(kubectl config current-context) --namespace=codew
Context minikube modified.
```

---

### 03. Verify that you've updated the namespace

```sh
Expand All @@ -74,32 +61,14 @@ CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* minikube minikube minikube codewizard
```

### Note:
---

- When using `kubectl` you can pass the `-n` flag in order to execute the `kubectl` command on a desired namespace
### 0.4 Using the `-n` Flag:

- When using `kubectl` you can pass the `-n` flag in order to execute the `kubectl` command on a desired `namespace`.
- For example:

```sh
# get resources of a specific workspace
$ kubectl get pods -n <namespace>
```

<!-- navigation start -->

---

<div align="center">

[:arrow_left: &nbsp; 00-VerifyCluster](../00-VerifyCluster)&nbsp;&nbsp;||&nbsp;&nbsp;
[02-Deployments-Imperative &nbsp; :arrow_right:](../02-Deployments-Imperative)
</div>

---

<div align="center">
<small>&copy;CodeWizard LTD</small>
</div>

![Visitor Badge](https://visitor-badge.laobi.icu/badge?page_id=nirgeier)

<!-- navigation end -->
93 changes: 35 additions & 58 deletions Labs/02-Deployments-Imperative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,39 @@
---
# Deployment - Imperative

### Pre-Requirements

- K8S cluster - <a href="../00-VerifyCluster">Setting up minikube cluster instruction</a>

[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://console.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://github.com/nirgeier/KubernetesLabs)
**<kbd>CTRL</kbd> + <kbd>click</kbd> to open in new window**

---

## Creating deployments using `kubectl create`

- We start with creating the following deployment
[praqma/network-multitool](https://github.com/Praqma/Network-MultiTool)
- This is a multitool for container/network testing and troubleshooting.

<!-- inPage TOC start -->

---
## Lab Highlights:
- [K8S Hands-on](#k8s-hands-on)
- [Deployment - Imperative](#deployment---imperative)
- [Pre-Requirements](#pre-requirements)
- [Creating deployments using `kubectl create`](#creating-deployments-using-kubectl-create)
- [Lab Highlights:](#lab-highlights)
- [01. Create namespace](#01-create-namespace)
- [02. Deploy multitool image](#02-deploy-multitool-image)
- [03. Test the deployment](#03-test-the-deployment)
- [03.01. Create a Service using `kubectl expose`](#0301-create-a-service-using-kubectl-expose)
- [03.02. Find the port \& the IP which was assigned to our pod by the cluster.](#0302-find-the-port--the-ip-which-was-assigned-to-our-pod-by-the-cluster)
- [03.03. Test the deployment](#0303-test-the-deployment)

### Pre-Requirements

- K8S cluster - <a href="../00-VerifyCluster">Setting up minikube cluster instruction</a>

[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://console.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://github.com/nirgeier/KubernetesLabs)
**<kbd>CTRL</kbd> + <kbd>click</kbd> to open in new window**

---

<!-- inPage TOC end -->

### 01. Create namespace
### 01. Create Namespace

- As completed in the previous lab, create the desired namespace [codewizard]:

```sh
# Create the desired namespace [codewizard]
$ kubectl create namespace codewizard
namespace/codewizard created
```

- In order to set this is as your default namespace refer to: <a href="../01-Namespace#2-setting-the-default-namespace-for-kubectl">set default namespace</a>
- In order to set this is as the default namespace, please refer to <a href="../01-Namespace#2-setting-the-default-namespace-for-kubectl">set default namespace</a>.

### 02. Deploy multitool image
---

### 02. Deploy Multitool Image

```sh
# Deploy the first container
Expand All @@ -60,10 +47,12 @@ deployment.apps/multitool created
```

- `kubectl create deployment` actually creating a replica set for us.
- We can verify it:
- We can verify it by running:

```
$ kubectl get all -n codewizard

## Expected output:
NAME READY UP-TO-DATE AVAILABLE
deployment.apps/multitool 1/1 1 1

Expand All @@ -74,21 +63,24 @@ NAME READY STATUS RESTARTS
pod/multitool-7885b5f94f-9s7xh 1/1 Running 0
```

## 03. Test the deployment
---

## 03. Test the Deployment

- The above deployment contains a container [`multitool`]
- In order of us to be able to access this `multitool` container we need to create a resource of type `Service` which will "open" the server for incoming traffic
- The above deployment contains a container named, `multitool`.
- In order for us to be able to access this `multitool` container, we need to create a resource of type `Service` which will "open" the server for incoming traffic.

### 03.01. Create a Service using `kubectl expose`
#### Create a service using `kubectl expose`

```sh
# "Expose" the desired port for incoming traffic
# This command is equivalent to declare a `kind: Service` im yaml file
# This command is equivalent to declare a `kind: Service` im YAML file

$ kubectl expose deployment -n codewizard multitool --port 80 --type NodePort
service/multitool exposed
```

- Verify that the service have been created
- Verify that the service have been created by running:

```sh
$ kubectl get service -n codewizard
Expand All @@ -97,12 +89,13 @@ $ kubectl get service -n codewizard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/multitool NodePort 10.102.73.248 <none> 80:31418/TCP 3s
```
<br>

### 03.02. Find the port & the IP which was assigned to our pod by the cluster.
#### Find the port & the IP which was assigned to our pod by the cluster.

- Grab the port from the previous output.
- Port: In the above sample its `31418` [`80:31418/TCP`]
- IP: we will need to gtrab the cluster ip using `kubectl cluster-info`
- IP: we will need to grab the cluster ip using `kubectl cluster-info`

```sh

Expand All @@ -125,10 +118,12 @@ NODE_PORT=$(kubectl get -o \

- In this sample the cluster-ip is `192.168.49.2`

### 03.03. Test the deployment
<br>

- Test to see if the deployment worked using the `ip & port` you got above
- Execute `curl` with the following prameters: `http://${CLUSTER_IP}:${NODE_PORT}`
#### Test the deployment

- Test to see if the deployment worked using the `ip address and port number` we have retrieved above.
- Execute `curl` with the following parameters: `http://${CLUSTER_IP}:${NODE_PORT}`

```sh
curl http://${CLUSTER_IP}:${NODE_PORT}
Expand All @@ -139,22 +134,4 @@ curl 192.168.49.2:30436
# The output should be similar to this:
Praqma Network MultiTool (with NGINX) ...
```
<!-- navigation start -->

---

<div align="center">
:arrow_left:&nbsp;
<a href="../01-Namespace">01-Namespace</a>
&nbsp;&nbsp;||&nbsp;&nbsp; <a href="../03-Deployments-Declarative">03-Deployments-Declarative</a>
&nbsp; :arrow_right:</div>

---

<div align="center">
<small>&copy;CodeWizard LTD</small>
</div>

![Visitor Badge](https://visitor-badge.laobi.icu/badge?page_id=nirgeier)

<!-- navigation end -->
- If you get the above output, congratulations! You have successfully created a deployment using imperative commands.
Loading