fix typos

This commit is contained in:
Rémy-Christophe Schermesser 2018-10-03 12:12:07 +02:00
parent c73ed21d30
commit 969eb5c9ab
7 changed files with 48 additions and 25 deletions

View File

@ -37,9 +37,9 @@ Let's have a look a the fields:
* `kind`: what resource this object represents
* `metadata`: some metadata about this pod, more on it later
* `spec`: specification of the desired behavior of this pod
* `containers`: the list of containers to start in this pod
* `name`: the name of the this container
* `image`: which image to start
* `containers`: the list of containers to start in this pod
* `name`: the name of the this container
* `image`: which image to start
Let's `apply` this configuration k8s. This will tell k8s to create the pod and run it.
@ -90,7 +90,7 @@ IP: 172.17.0.1
Look at the information provided. Get the field `IP`, it's the internal ip for this pod
Connect to the cluster, and try to `curl` this ip - `172.17.0.4` in the exemple.
Connect to the cluster, and try to `curl` this ip - `172.17.0.4` in the example.
```bash
$ minikube ssh
@ -105,7 +105,7 @@ K8s has a useful add-on, a web dashboard. It's included by default in minikube.
$ minikube dashboard
```
## Exercices
## Exercises
1. Deploy a pod containing nginx. The image name is `nginx`, see: https://hub.docker.com/_/nginx/
2. Try accessing the pod `simple-service` from outside of k8s, without changing the configuration. Do you manage to do it?

View File

@ -4,11 +4,11 @@
In this section we will learn how to name things in k8s, and how to find them again.
Labels are the way to organise objects in kubernetes. The labels are a list of key/value.
Labels are the way to organize objects in kubernetes. The labels are a list of key/value.
Annotations are a way to mark objects in kubernetes, it's also a list of key/value.
They seem the same. The major difference is that you can query k8s based on labels.
On the other hand, annontations are not limited on characters used for labels.
On the other hand, annotations are not limited on characters used for labels.
Valid label keys have two segments: an optional prefix and name, separated by a slash `/`. The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character `[a-z0-9A-Z]` with dashes `-`, underscores `_`, dots `.`, and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots `.`, not longer than 253 characters in total, followed by a slash `/`.
@ -17,10 +17,12 @@ Valid label values must be 63 characters or less and must be empty or begin and
## Labels in action
Apply the pod `05-label-annotation/01-simple-service.yml`. It is the same as `04-pods/01-simple-service.yml` but with 2 labels:
* `env`: `production`
* `tier`: `backend`
Apply the pod `05-label-annotation/02-nginx.yml`. It is a simple nginx with 2 labels:
* `env`: `production`
* `tier`: `frontend`
@ -45,7 +47,7 @@ nginx 1/1 Running 0 1m
Those queries we call them `selector` in the k8s jargon. We will use them later on with deployments.
## Exercices
## Exercises
Nothing to see here.

View File

@ -32,6 +32,7 @@ spec:
```
Let's have a look a the configuration:
* `apiVersion`: Deployments are in "beta" (think google beta) in k8s so `apps/v1beta1`
* `kind`: A `deployment` has the kind `Deployment`
* `spec`:
@ -44,6 +45,7 @@ Let's have a look a the configuration:
* `containerPort`: The kind of port we want to expose, here a `containerPort`. So our container will expose one port `9876` in the cluster.
Apply the deployment:
```bash
$ kubectl apply -f 06-deployment/01-simple-deployment.yml
deployment.apps "simple-deployment" created
@ -73,7 +75,7 @@ The `deployment` created 2 pods for us, the number we put in `replicas`. We see
Did k8s created something else for us? Let's have a look
```
```bash
$ kubectl get all
NAME READY STATUS RESTARTS AGE
@ -88,6 +90,7 @@ replicaset.apps/simple-deployment-5f7c895db4 2 2 2 4m
```
We see 3 things, you might have a section `ClusterIP` ignore it for now:
* `pod`: named `pod/[...]`
* `deployment`: named `deployment.apps/[...]`
* `replicaset`: named `replicaset.apps/[...]`
@ -98,7 +101,7 @@ We won't go into details of what a [`ReplicaSet`](https://kubernetes.io/docs/con
## Scale up
Let's play with our deployment now.
Update the number of `replicas` in the yaml, to a reasonnable number - say `5`.
Update the number of `replicas` in the yaml, to a reasonable number - say `5`.
```bash
$ kubectl apply -f 06-deployment/01-simple-deployment.yml
@ -134,10 +137,10 @@ deployment.apps "simple-deployment" image updated
Again, see what is happening.
Remember the command `kubectl describe deployment`.
## Exercices
## Exercises
1. Deploy multiple nginx. The image name is `nginx`, see: https://hub.docker.com/_/nginx/
2. Play with the scalling up/down & the deployment of new versions
2. Play with the scaling up/down & the deployment of new versions
3. Try accessing your deployment of nginx from outside of k8s, without changing the configuration. Do you manage to do it?
* If yes, how did you manage to do it?
* If no, what do you think is missing?

View File

@ -6,7 +6,8 @@ In this section you will learn how to access your application from outside your
## Prerequisites
If it's not already done install the `minikube` addon `coredns` & `ingress`
If it's not already done install the `minikube` addon `coredns` & `ingress`:
```bash
$ minikube addons enable coredns
coredns was successfully enabled
@ -19,29 +20,33 @@ ingress was successfully enabled
You are able to deploy an image with multiple replicas, but it is not very convenient to access it. You need to know the IP of a `pod` to be able to target your application. And it's not accessible from the outside of the cluster.
What we need is a `service`. It'll allow us to acces our pods internally or externally.
What we need is a `service`. It'll allow us to access our pods internally or externally.
First apply the deployment:
```bash
$ kubectl apply -f 07-service/01-simple-deployment.yml
deployment.apps "simple-deployment" created
```
Now start another container. We will use it to see what we can access internaly inside k8s:
Now start another container. We will use it to see what we can access internally inside k8s:
Apply the pod:
```bash
$ kubectl apply -f 07-service/02-bash.yml
pod "bash" created
```
And connect to it
And connect to it:
```bash
$ kubectl exec -it bash -- /bin/bash
root@bash:/#
```
Install `dnsutils` & `curl` in the container, you will need them:
```bash
root@bash:/# apt update && apt install dnsutils curl
[...]
@ -66,25 +71,30 @@ spec:
```
Let's have a look a the configuration:
* `kind`: A `service` has the kind `Service`
* `spec`:
* `ports`: the list of ports to expose. Here we export `port` `1234`, but redirect internally all traffic to the `targetPort` `9876`
* `selector`: which pods to give access to
The selector part,
The selector part
```yml
selector:
app: simple-service
```
is central to k8s. It is with this field that you will tell k8s which pods to give access through this `service`.
Apply the service:
```bash
$ kubectl apply -f 07-service/03-internal-service.yml
service "simple-internal-service" created
```
Your service is now accessible internaly, try this in your `bash` container
Your service is now accessible internally, try this in your `bash` container:
```bash
root@bash:/# nslookup simple-internal-service
Server: 10.96.0.10
@ -104,7 +114,7 @@ The answer is no, it's not possible. To do this you need an `ingress`. Ingress m
You need to connect internet to the ingress that'll connect it to a service:
```
```txt
internet
|
[ ingress ]
@ -139,12 +149,14 @@ Let's have a look at the configuration:
* `servicePort`: the port of the service
Apply the ingress:
```bash
$ kubectl apply -f 07-service/04-ingress.yml
ingress.extensions "simple-ingress" created
```
Get the IP of your minikube cluster:
```bash
$ minikube ip
192.168.99.100
@ -154,7 +166,7 @@ Open a browser on `http://192.168.99.100/info`
With this configuration we have a `deployment` that manages pods. A `service` that gives access to the pods, and an `ingress` that gives access to the pod to the external world.
## Exercices
## Exercises
1. Deploy an nginx and expose it internally
2. Read [this](https://kubernetes.io/docs/concepts/services-networking/ingress/#simple-fanout) and modify the ingress to have:

View File

@ -32,6 +32,7 @@ spec:
* `command`: the command to run, here compute the first 100 digits of π.
Let's apply it:
```bash
$ kubectl apply -f 08-cronjob/01-simple-cronjob.yml
cronjob.batch "simple-cronjob" created
@ -61,6 +62,7 @@ spec:
They configuration is fairly close to a `CronJob`.
Apply it and see what is happening. Does it restarts?
```bash
$ kubectl apply -f 08-cronjob/02-simple-job.yml
job.batch "simple-job" created
@ -68,7 +70,7 @@ job.batch "simple-job" created
If you have a long running background process - like a consumer of a queue - you can use a `deployment` without a `service`.
## Exercices
## Exercises
1. Transform the `simple-job` to a cron job running every 2 minutes
2. Transform the `simple-cronjob` in a deployment of `1` replica, and compute the 1_000 first digits of π. What is happening when the container finishes?

View File

@ -10,7 +10,7 @@ So how can we deploy a stateful application with a persistent storage in k8s? Le
## Volumes
We need to review what a volume is before continuing with the deployment of our mysql. As stated above, the disk of a pod is detroyed with it, so it's lost. For a database it'll nice if we could keep the data between restarts of the pods. Here comes the `volume`.
We need to review what a volume is before continuing with the deployment of our mysql. As stated above, the disk of a pod is destroyed with it, so it's lost. For a database it'll nice if we could keep the data between restarts of the pods. Here comes the `volume`.
We can see a `pod` as something that requests CPU & RAM. We can see a `volume` as something that requests a storage on disk. K8s handles a lot of different kind of volumes - 26 has this file hands on is written - from local disk storage to s3.
@ -45,6 +45,7 @@ Let's review some configuration:
* `hostPath`: where the storage will be stored on the host, here `/mnt/data/`
Apply it:
```bash
$ kubectl apply -f 09-stateful-set/01-simple-mysql-pv.yml
```
@ -64,7 +65,7 @@ spec:
storage: 1Gi
```
The configuration is pretty similiar to the `PersistentVolume`.
The configuration is pretty similar to the `PersistentVolume`:
```bash
$ kubectl apply -f 09-stateful-set/02-simple-mysql-pvc.yml
@ -117,12 +118,14 @@ mysql> show databases;
```
Create a new database in mysql:
```bash
mysql> CREATE DATABASE testing;
Query OK, 1 row affected (0.01 sec)
```
Now delete the service and the deployment
Now delete the service and the deployment:
```bash
$ kubectl delete service,deployment
```

View File

@ -51,6 +51,7 @@ If this topic interests you see [Kubernetes the hard way](https://github.com/kel
Kubernetes is an open source system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications.
Kubernetes has a number of features. It can be thought of as:
* a container platform
* a microservices platform
* a portable cloud platform and a lot more.
@ -58,6 +59,7 @@ Kubernetes has a number of features. It can be thought of as:
Kubernetes provides a container-centric management environment. It orchestrates computing, networking, and storage infrastructure on behalf of user workloads. This provides much of the simplicity of Platform as a Service (PaaS) with the flexibility of Infrastructure as a Service (IaaS), and enables portability across infrastructure providers.
## Glossary
* **yml/yaml**
A markup language that relies on spaces & tabulation. All k8s configuration is written using yaml.
@ -79,7 +81,6 @@ A software technology providing operating-system-level virtualization also known
Docker uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and a union-capable file system such as OverlayFS and others to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines (VMs).
* **kubectl**
The standard cli to interact with k8s, we will use it a lot.