Skip to content

Commit

Permalink
- renamed files so that it indexes it on the search engines with mean…
Browse files Browse the repository at this point in the history
…ingful keywords

- added CNAME to redirect the site to kubernetes-tutorial.schoolofdevops.com
- misc changes and fixes  during the course run
  • Loading branch information
initcron committed Feb 27, 2020
1 parent 99fb3fd commit 1e8c68d
Show file tree
Hide file tree
Showing 20 changed files with 341 additions and 302 deletions.
8 changes: 4 additions & 4 deletions chapters/10_kubernetes_autoscaling.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Deploy metric server with the following commands,
```
cd ~
git clone https://github.com/kubernetes-incubator/metrics-server.git
kubectl apply -f metrics-server/deploy/1.8+/
kubectl apply -f metrics-server/deploy/kubernetes/
```

Validate
Expand Down Expand Up @@ -92,8 +92,8 @@ metadata:
name: vote
spec:
minReplicas: 4
maxReplicas: 15
targetCPUUtilizationPercentage: 40
maxReplicas: 45
targetCPUUtilizationPercentage: 70
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -138,7 +138,7 @@ spec:
containers:
- name: siege
image: schoolofdevops/loadtest:v1
command: ["siege", "--concurrent=5", "--benchmark", "--time=10m", "http://vote"]
command: ["siege", "--concurrent=5", "--benchmark", "--time=6m", "http://vote"]
restartPolicy: Never
backoffLimit: 4
```
Expand Down
76 changes: 0 additions & 76 deletions chapters/11_deploying_sample_app.md

This file was deleted.

185 changes: 0 additions & 185 deletions chapters/9-vote-configmaps_and_secrets.md
Original file line number Diff line number Diff line change
@@ -1,185 +0,0 @@
# Configurations Management with ConfigMaps and Secrets

Configmap is one of the ways to provide configurations to your application.

### Injecting env variables with configmaps
Create our configmap for vote app

file: projects/instavote/dev/vote-cm.yaml

```
apiVersion: v1
kind: ConfigMap
metadata:
name: vote
namespace: instavote
data:
OPTION_A: Visa
OPTION_B: Mastercard
```

In the above given configmap, we define two environment variables,

1. OPTION_A=EMACS
2. OPTION_B=VI


Lets create the configmap object

```
kubectl get cm
kubectl apply -f vote-cm.yaml
kubectl get cm
kubectl describe cm vote
```
In order to use this configmap in the deployment, we need to reference it from the deployment file.

Check the deployment file for vote add for the following block.

file: `vote-deploy.yaml`

```
...
spec:
containers:
- image: schoolofdevops/vote
imagePullPolicy: Always
name: vote
envFrom:
- configMapRef:
name: vote
ports:
- containerPort: 80
protocol: TCP
restartPolicy: Always
```

So when you create your deployment, these configurations will be made available to your application. In this example, the values defined in the configmap (Visa and Mastercard) will override the default values(CATS and DOGS) present in your source code.

```
kubectl apply -f vote-deploy.yaml
```

Watch the monitoring screen for deployment in progress.

```
kubectl get deploy --show-labels
kubectl get rs --show-labels
kubectl rollout status deploy/vote
```

![ConfigMap Dashboard.\label{fig:captioned_image}](images/Configmap.png)



### Note: Automatic Updation of deployments on ConfigMap Updates

Currently, updating configMap does not ensure a new rollout of a deployment. What this means is even after updading configMaps, pods will not immediately reflect the changes.

There is a feature request for this https://github.com/kubernetes/kubernetes/issues/22368

Currently, this can be done by using immutable configMaps.

* Create a configMaps and apply it with deployment.
* To update, create a new configMaps and do not update the previous one. Treat it as immutable.
* Update deployment spec to use the new version of the configMaps. This will ensure immediate update.


## Enabling HTTP Authentication for Traefik with Secrets

In this part of the lab, you will

* Create a secret with an existing file
* Modify a ingress rule to use that secret via annotations
* Validate if traefik, the ingress controller, automatically picks up the configurations and enables http auth s

Lets create htpasswd spec as Secret


```
apt install -yq apache2-utils
htpasswd -c auth devops
```


Or use [Online htpasswd generator](http://www.htaccesstools.com/htpasswd-generator/) to generate a htpasswd spec. if you use the online generator, copy the contents to a file by name `auth` in the current directory.

Then generate the secret as,

```
kubectl create secret generic mysecret --from-file auth
kubectl get secret
kubectl describe secret mysecret
```

And then add annotations to the ingress object so that it is read by the ingress controller to update configurations.

`file: vote-ing.yaml`

```
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: vote
annotations:
kubernetes.io/ingress.class: traefik
ingress.kubernetes.io/auth-type: "basic"
ingress.kubernetes.io/auth-secret: "mysecret"
spec:
rules:
- host: vote.example.com
http:
paths:
- path: /
backend:
serviceName: vote
servicePort: 82
- host: results.example.com
http:
paths:
- path: /
backend:
serviceName: results
servicePort: 81
```

where,

* *ingress.kubernetes.io/auth-type: "basic"* defines authentication type that needs to be added.
* *ingress.kubernetes.io/auth-secret: "mysecret"* refers to the secret created earlier.

apply

```
kubectl apply -f vote-ing.yaml
kubectl get ing/vote -o yaml
```

Observe the annotations field. No sooner than you apply this spec, ingress controller reads the event and a basic http authentication is set with the secret you added.


```bash

+----------+
+--update----> | traefik |
| | configs |
| +----------+
+----+----+--+ ^
| ingress | :
| controller | :
+----+-------+ :
| +-----+-------+
+---watch----> | ingress | <------- user
| annotations |
+-------------+
```



![Name Based Routing](../images/domain-name.png)
1 change: 1 addition & 0 deletions chapters/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubernetes-tutorial.schoolofdevops.com
File renamed without changes.
File renamed without changes.
Binary file added chapters/images/deployment_mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/images/service_mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/images/storage_mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions chapters/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Kubernetes Lab Guide
# Kubernetes Tutorial

Welcome to the Kubernetes Course by School of Devops
Welcome to the Kubernetes Tutorial by School of Devops

This is a Lab Guide which goes along with the Docker and Kubernetes courses conducted by School of Devops.
This document was originally created as a Lab Guide to go along with the [Kubernetes Course by School of Devops](http://www.schoolofdevops.com/). However, you could also use it on its own now to practice learning kubernetes topics.

For information about the devops trainign courses visit [schoolofdevops.net](http://schoolofdeovps.net).
If you still believe you could learn better and faster by audio visual means, definitely consider subscribing to our course at [schoolofdevops.com](http://schoolofdeovps.com).


## Team
Expand Down
File renamed without changes.
Loading

0 comments on commit 1e8c68d

Please sign in to comment.