{"id":18612474,"url":"https://github.com/alejandro945/kubernetes","last_synced_at":"2026-05-18T09:08:38.964Z","repository":{"id":43079785,"uuid":"471843993","full_name":"alejandro945/kubernetes","owner":"alejandro945","description":"Project with the objective of familiarizing the community about the importance of Kubernetes in microservices applications","archived":false,"fork":false,"pushed_at":"2023-02-15T23:06:46.000Z","size":3293,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-27T02:21:27.904Z","etag":null,"topics":["docker","kubernetes","microservices"],"latest_commit_sha":null,"homepage":"","language":"Smarty","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alejandro945.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-20T00:32:58.000Z","updated_at":"2023-03-01T15:49:45.000Z","dependencies_parsed_at":"2024-12-27T02:20:32.671Z","dependency_job_id":"55e60e3d-9f64-4675-999a-309a1b75e4cb","html_url":"https://github.com/alejandro945/kubernetes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro945%2Fkubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro945%2Fkubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro945%2Fkubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro945%2Fkubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alejandro945","download_url":"https://codeload.github.com/alejandro945/kubernetes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239403618,"owners_count":19632621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","kubernetes","microservices"],"created_at":"2024-11-07T03:17:35.118Z","updated_at":"2025-10-04T17:14:36.262Z","avatar_url":"https://github.com/alejandro945.png","language":"Smarty","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes Course 🫰\n\nIn this course we will manage some basic concepts about container orchestation tool.\n\n## Minikube configuration 🍷\n\nMinikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes. All you need is Docker (or similarly compatible) container or a Virtual Machine environment\n\n## Installation 🐙\n\nTo install the latest minikube stable release on x86-64 Linux using binary download. Check the following link on case of diferent machine architecture https://minikube.sigs.k8s.io/docs/start/\n\n```\ncurl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64\nsudo install minikube-linux-amd64 /usr/local/bin/minikube\n```\n\n## Machine minimum resources 🎁\n\n- 2 CPUs or more\n- 2GB of free memory\n- 20GB of free disk space\n- Internet connection\n- Container or virtual machine manager, such as: Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation\n\n## Start your cluster 🚀\n\n```\nminikube start\n```\n\n## Finish your kubernetes services 💀\n\n```yaml\nkubectl delete all --all\n## From an especific namespace\nkubectl delete all --all -n namespace\n```\n\n## 1- Monitoring and notifications to an Slack channel 🎠\n\nPrometheus server is responsible for send alerts of monitoring to the alert manager and this one is in charge to alert to our different integrations suach send email or slack etc.\n\nThe first file is our namespace that are a way to organize clusters into virtual sub-clusters. (1-monitoring/namespaces.yaml)\n\n```yaml\nkubectl appliy -f namespace.yaml\n# namespace/monitoring created ✅\n```\n\n### Prometheus Pod  🚂\n\nThen we must create some role or permissions in that monitoring subcluster that we have already created. This with the objective that prometheus can access to system files such as **extract metrics**.\n\n```yaml\nkubectl apply -f prometheus-cluster-role.yaml\n#clusterrole.rbac.authorization.k8s.io/prometheus created ✅\n#clusterrolebinding.rbac.authorization.k8s.io/prometheus created ✅\n```\n\nAlso, we need to deploy our prometheus pod server that it will create our container instance base on the following image **prom/prometheus:v2.1.0** in ``monitoring``namespace and it will attach some config and storage volume in the root cluster.\n\n```yaml\nkubectl apply -f prometheus-cluster-role.yaml\n# deployment.apps/prometheus-deployment created ✅\n```\n\nCheck what we have at this moment:\n\n```\nkubectl -n monitoring get all\n```\n\n|NAME                                  | READY|   STATUS           |RESTARTS|   AGE|\n|-------------------------------------|------|--------------------|--------|------|\n|pod/prometheus-deployment-5875b79765-nzpjp|   0/1|     ContainerCreating|   0|          2m31s|\n|deployment.apps/prometheus-deployment|   0/1|     1|           0|          2m31s|\n|replicaset.apps/prometheus-deployment-5875b79765|   1|         1|         0|       2m31s|\n\n\n*Config maps* are manifiest that you inject to an specific namespace and then whatever container running on this ns can read those configuration maps and generated its configuration base on that template (Global Enviroment Namespaces)\n\n**Basic Check of Memory Use**\n```yaml\nrules:\n      - alert: High Pod Memory\n        expr: sum(container_memory_usage_bytes) \u003e 1\n        for: 1m\n        labels:\n          severity: critical\n        annotations:\n          summary: High Memory Usage\n```\n\nApplying Map Configuration:\n\n```yaml\nkubectl apply -f prometheus-configmap.yaml\n# configmap/prometheus-server-conf created ✅\n```\n\nCreation of a service to expose our prometheus pods using a node port that basically open a port in the workers nodes that redirects the traffic to the pod with specific label or selector.\n\n```yaml\nkubectl apply -f prometheus-service.yaml \n# service/prometheus-service created ✅\n```\n\n### Alert Manager Pod 🪝\n\n- Service creation (Cluster Ip because we want that prometheus can access to that container assigning an specific ip in the cluster)\n\n    ```yaml\n    kubectl apply -f alert-manager-service.yaml\n     #service/alertmanager created ✅\n    ```\n\n- Deployment in this case we have a pod that will have two containers, the firts one is the alert manager and the second one a **side car** that will be watching for changes in global config map. Also, we have a Persistent Volume Claim that is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources, claims can request specific size and access modes.\n\n    ```yaml\n      kubectl apply -f alert-manager-configmap.yaml \n      # service/alertmanager created ✅\n\n      kubectl apply -f alert-manager-pvc.yaml \n      # persistentvolumeclaim/alertmanager created ✅\n\n      kubectl apply -f alert-manager-deployment.yaml \n      # deployment.apps/alertmanager created ✅\n    ```\n\n### Checking all infrastructure 🏗️\n\n- Pods\n\n|NAME                                  | READY|   STATUS           |RESTARTS|   AGE|\n|-------------------------------------|------|--------------------|--------|------|\n|pod/alertmanager-85bc4f4759-s25c5|            2/2|     Running|   0|         23m|\n|pod/prometheus-deployment-5875b79765-nzpjp|   1/1|     Running|   0|         91m|\n\n- Services\n\n|NAME                         |TYPE        |CLUSTER-IP |    EXTERNAL-IP|   PORT(S)|          AGE|\n|-------------------------------------|------|--------------------|--------|------|--------------|\n|service/alertmanager|         ClusterIP|   10.110.82.83|   \u003cnone\u003e|        9093/TCP|         59m|\n|service/prometheus-service|   NodePort|    10.100.0.75|    \u003cnone\u003e |       8080:30000/TCP|   79m|\n\n- Deployments\n\n|NAME                                  |  READY  | UP-TO-DATE |  AVAILABLE |  AGE|\n|-------------------------------------|------|--------------------|--------|------|\n|deployment.apps/alertmanager|            1/1 |    1    |        1   |        23m|\n|deployment.apps/prometheus-deployment|   1/1 |    1  |          1  |         91m|\n\n### Considerations 🚦\n\nDue to we are using minikube for our local kubernetes cluster we just have one node and for accesing externally we must use the following command:\n\n```yaml\nminikube -n monitoring service prometheus-service --url\n# http://192.168.49.2:30000 ⚠️\n```\n\nHowever i have my minikube configuration inside an ec2 vm hosted in aws cloud provider 😅. That is why i must port forward my vm local entry set in 31000 port and the service port 8080 of the prometheus node port:\n\n```yaml\nkubectl port-forward --address 0.0.0.0 service/prometheus-service --namespace monitoring 31000:8080\n# Forwarding from 0.0.0.0:31000 -\u003e 9090\n# Handling connection for 31000\n```\n\n### Evidences 🚧\n\n![Graphs](./0-assets/graph-prometheus.png)\n\n![Alerts](./0-assets/alerts-prometheus.png)\n\n![Slack-Configuration](./0-assets/slack-config.png)\n\n![Slack-Evidence](./0-assets/slack-evidence.png)\n\n## 2- Helm 🎠\n\nIt's a package manager that makes it possible to download charts, which are pre-packaged collections of all the necessary versioned, pre-configured resources required to deploy a container. Helm charts are written in YAML and contain everything your developers need to deploy a container to a Kubernetes cluster.\n\n### Installation\n\n```bash\nsudo snap install helm --classic\n```\n\n### Hosting your own charts\n\nHelm chart creation \u003cvarelachart\u003e : *chart_name*\n```bash\nhelm create varelachart\n```\n\n![Creation](./0-assets/helm_init.png)\n\nDebugging the manifiests that helm will install in our cluster\n```bash\nhelm install --dry-run debug .\n```\n\n![Debug](./0-assets/helm_debug.png)\n\nSome linter guardians or constraints in our yamls files\n```bash\nhelm lint\n```\n\nCreating a package of this helm chart due to we need other repositorios can use it.\n```bash\nhelm package varelachart/\nmv ./varelachart-0.1.0.tgz charts/\n```\n\n![Package](./0-assets/helm_package.png)\n\nAdding your custom configurations in values.yaml file.\n\n```yaml\nhealthcheck:\n  readinessProbe:\n    path: /\n    port: http\n  livenessProbe:\n    path: /\n    port: http\n```\n\n```yaml\n  path: {{.Values.healthcheck.readinessProbe.path}}\n  port: {{.Values.healthcheck.readinessProbe.path}}\n```\n\nCreation of the index file use for helm repository to know what charts are inside this package. It will look for all tgz inside the current folder and map ot into this index entrypoint. \n```bash\nhelm repo index .\n```\n\nPush your changes to your github or distributed version management and for using repository:\n```bash\nhelm repo add varela https://alejandro945.github.io/kubernetes/2-helm\n```\n\nValidation of repository creation\n```bash\nhelm search repo varela\n```\n\nInstallation on your kubernetes cluster\n```bash\nhelm install test varela/varelachart\n```\n\nDelete a helm chart or list them\n```bash\nhelm list\nhelm delete test\n```\n\n## 3- Logging using grafana and loki 📌\n\nLoki is a log database developed by Grafana Labs. In this repo we will deploy Loki on a Kubernetes cluster, and we will use it to monitor the log of our pods.\n\n### Deployment of app service\n\n```yaml\nkubectl apply -f app.yaml\n```\n\n2. Port forward service from 30000:80\n\n```yaml\nkubectl port-forward --address 0.0.0.0 service/hello-kubernetes 30000:80\n```\n\n### Deployment of grafana service\n\nGrafana is an open source interactive data-visualization platform, developed by Grafana Labs, which allows users to see their data via charts and graphs that are unified into one dashboard (or multiple dashboards!) for easier interpretation and understanding.\n\n1. Apply yaml files using kustomize\n\n```yaml\nkubectl apply -k .\n```\n\n2. Port forward service from 31000:80\n\n```yaml\nkubectl port-forward --address 0.0.0.0 service/grafana-service 31000:80\n```\n\n3. Authentication credentials\n\nUsername: admin\nPassword: admin\n\n### Deployment of loki service \n\n**Definition:**\nLoki is a log aggregation system designed to store and query logs from all your applications and infrastructure.\n\nAnother concept to have in mind is a fully qualified domain name (FQDN) that is the complete address of an internet host or computer. It provides its exact location within the domain name system (DNS) by specifying the hostname, domain name and top-level domain (TLD).\n\n**Contextualization:**\nLoki is a great database that is easy to create and the only thing we will do is describe that it will need a volume so that it is persistent between service drops (pod)\n\n\n1. Apply all YAML files in order and wait\n\n```yaml\nkubectl apply -k .\n```\n\n2. Remember the FQDN\n```bash\nhttp://loki-service.kube-logging.svc.cluster.local:3100\n```\n\n### Deployment of fluentd service\n\nService capable of monitoring the system logs and processing it in the way that we tell it in this case for loki, we will use **daemon set** to deploy a copy of fluentd in each of the nodes to centralize this information in the loki database to view them in grafana.\n\nUsing **configmap** to grab the logs and insert them into loki, for this a fluentd configuration is injected into its container, here we tell you where those logs are, how we parse that information (automation core)\n\n1. Apply all YAML files in order and wait\n\n```yaml\nkubectl apply -k .\n```\n\n### Evidences 🚧\n\n![Dashboard](./0-assets/grafana.png)\n\n![Datasource](./0-assets/ds.png)\n\n![Graphic](./0-assets/graphic.png)\n\n![Logs](./0-assets/logs.png)\n\n![Application](./0-assets/app.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandro945%2Fkubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandro945%2Fkubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandro945%2Fkubernetes/lists"}