@@ -246,160 +246,57 @@ Ce certificat va être autaumatiquement être signé par Letsencrypt grace à ce
...
@@ -246,160 +246,57 @@ Ce certificat va être autaumatiquement être signé par Letsencrypt grace à ce
A l'issue de cette étape vous devriez pouvoir acccéder à votre application en HTTPS sur votre nom de domaine !!
A l'issue de cette étape vous devriez pouvoir acccéder à votre application en HTTPS sur votre nom de domaine !!
Si c'est le cas bravo ! Sinon vous pouvez vérifier que votre ingress apparaaisse bien sur ``https://traefik.test.viarezo.fr``
Si c'est le cas bravo ! Sinon vous pouvez vérifier que votre ingress apparaaisse bien sur ``https://traefik.test.viarezo.fr``
## 9. Make it fail: probes
### Why
A ce point de la formation vous devez avoir les fichiers suivants.
```
Our app is deployed, but is not very functional: we lack the redis for the storage! However, before deploying it, let's make it explicit that is does not work. When the redis is not set, the app should be failing. That way, someone can get the alert and fix the issue.
deploiment_front.yaml
deploiment_backt.yaml
That is the job of *Kubernetes probes*: often doing an HTTP request, it asks continuously the application if it is still running.
service_front.yaml
service_back.yaml
### What
ingress_front.yaml
ingress_back.yaml
This time we need to modify the manifest of our deployment! Read [this article from Padok blog](https://www.padok.fr/en/blog/kubernetes-probes) or [documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) to learn how to set them.
```
Afin d'éviter de flood la cluster pensez à supprimer vots ressources afin de passer à la suite.
Our app exposes its status at `/healthz`, if the application is not functional it will return a 5XX error.
Vous pouvez le faire avec la commande suivante.
## Helm le apt de kubernetes
### How
C'est bien sympatique tout ça mais c'est loooong. Heureusement helm est la.
Helm permet de templatiser les fichiers kubernetes. Une application Helm s'appelle une chart.
1. Modify your deployment and add probes to your main container. Which type of probes do you need ?
Une chart s'organise comme suis:
2. Apply it. Is your application still available on the URL? It should not but rolling updates protects your. Ask a teacher about it.
```
3. Remove the "zombie" pods. You can delete and apply back the deployment, but a more elegant solution is to _scale down_ the replica set under the deployment (`kubectl scale replicaset <my-rs> --replicas 0`). You don't know what is a replicat set? Ask!
VROUM
4. Is your website still available? Does the [HTTP error code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) makes sense?
│ Chart.yaml
│ values.yaml
### Checks
│
└───templates
- [ ] All my pods are "notReady" or "Failing"
│ deploiment_front.yaml
- [ ] The website is down
│ deploiment_backt.yaml
| service_front.yaml
<details>
| service_back.yaml
<summary>Compare your work to the solution before moving on. Are there differences? Is your approach better or worse? Why?</summary>
| ingress_front.yaml
| ingress_back.yaml
```yaml
apiVersion:apps/v1
```
kind:Deployment
Le fichier Chart.yml décrit l'application. Il permet aussi d'inclure d'autre charts en dépendance de la notre. Il s'écrit sous la forme :
metadata:
```
name:guestbook
apiVersion: v2
spec:
name: <nom>
replicas:3
description: <description>
selector:
type: application
matchLabels:
version: 0.1.1
app:guestbook
appVersion: "<version>"
project:dojo
template:
metadata:
labels:
app:guestbook
project:dojo
spec:
containers:
-name:guestbook
image:dixneuf19/guestbook:v0.1.0
ports:
-containerPort:3000
name:http
readinessProbe:
httpGet:
path:"/healthz"
port:http
livenessProbe:
httpGet:
path:"/healthz"
port:http
```
```
</details>
## 10. Install a complex Redis app with Helm
### Why
We wan't to fix our app and give it some persistent storage. However, Redis is a stateful application, a bit more complex than our simple webservice. You could write your own manifests for its deployment, but we would certainly make some mistakes. Let use what the community offers us!
Helm is tool which helps us
- Generate manifests from YAML templates. You can reduce the boilerplate of your code, reduce repetition etc...
- Manage our deployments as "packages", and distribute or use remote packages made by the community.
### What
The [Helm documentation](https://helm.sh/docs/intro/quickstart/) is quite good, but unless you have time, don't loose too much time on it.
Le values.yaml permet de passer en argument des paramètres aux templates.
On va remplacer dans les fichiers créés précedement les valeurs par de la templatisation de la forme:
We will only need one command, which installs or upgrades a _release_ (ie a deployment package). We will use the _redis_ chart from the _bitnami_ repository, identified by its URL. Lastly, we will set one specific option, using a `values.yaml` file.
Cette chaine de caractère va être remplacé par la valeur donnée dans le value.yaml :
1. We will use the _Bitnami_ Redis chart, you can find its [source code here](https://github.com/bitnami/charts/tree/master/bitnami/redis).
```yaml
2. Create your `values.yaml` file. You only need to set `architecture: standalone`, but you can explore other options in the `values.yaml` of the repository.
front:
3. Deploy your release with the `helm` command:
deployment:
- You can name your release as you want, but if you name it the same name as the chart, the name of the resources will be shorter.
name:coucou
- The chart you want to use is called redis
- The Helm repository URL is https://charts.bitnami.com/bitnami
- Don't forget to set your values file
4. Explore what has been create: pods, deployments (why is there none ?), services, etc...
### Checks
- [ ] I have 1 redis pod running
- [ ] I have one helm release deployed: `helm ls`
<details>
<summary><em>Compare your work to the solution before moving on. Are there differences? Is your approach better or worse? Why?</em></summary>
Well, you absolutely want to have a guestbook for yourself no?
### What
Your application use an Environment Variable to set the host to the Redis server, has you have done previously in the Docker-Compose file.
The [official documentation](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) is very clear! You just need to find the path to your Redis. Since it is an internal call, you need to use the *Service* created by the Helm chart.
Once it is set correctly, your app should be _Ready_ and you could access it from its public URL.
### How
1. Find the name of your Redis service. How should it be called from the pod?
2. Update your Deployment manifest and apply it.
3. Enjoy your application!
### Checks
- [ ] My pods are up and running
- [ ] I can actually use the guestbook from its public URL
<details>
<summary><em>Compare your work to the solution before moving on. Are there differences? Is your approach better or worse? Why?</em></summary>
You can find the complete solution [here](https://github.com/padok-team/dojo-guestbook/blob/feat/solution/manifests/deployment.yaml). Don't spoil yourself too much!
</details>
## 12. To go further
This dojo is already quite long, but here are some ideas to continue the exercise and learn more about Kubernetes! Ask your teacher for more details on where to start, what to look for, etc...
- Make your app resilient with [Pod Anti Affinities](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity)
- Scale your app with an [HorizontalPodAutoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/). You will need to generate some load on the application (adding a route could work).
- Deploy easily your own Kubernetes cluster with [`k0s`](https://k0sproject.io/) and [`k0sctl`](https://github.com/k0sproject/k0sctl)
- Automate your deployment with [ArgoCD](https://www.padok.fr/en/blog/kubernetes-cluster-gitops), the GitOps way
- Deploy a monitoring solution with [Prometheus and Grafana](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack)
- _Advanced_: [Make an app scale depending on a Redis queue](https://github.com/padok-team/dojo-kubernetes-prometheus)