Skip to content

otus-devops-2019-05/bars83_microservices

Repository files navigation

bars83_microservices

Build Status

Homework #23 - Kubernetes-5

  1. Install nginx-ingress with helm chart
  2. Fetch Prometheus helm chart and set custom values
  3. Play with Prometheus targets
  4. Set to collect data from kube-state-metrics, node-exporters
  5. Set service discovery for reddit microservices pods
  6. Play with relabels
  7. Install Grafana with helm chart
  8. Play with Grafana dashboards
  9. Using Grafana templating capabilities
  10. (*) - set Alermanager parameter in custom_values.yml to send notifications to Slack when nodes or api-server is unavailable
  11. (*) - install Prometheus Operator, set ServiceMonitor to post endpoint
    • helm install --namespace monitoring --name prom-operator stable/prometheus-operator
    • kubectl apply -f kubernetes/prometheus-operator-servicemonitors/post-servicemonitor.yml
  12. Bootstrap EFK stack
  13. (*) bootstrap EFK stack using helm charts
    • helm repo add elastic https://helm.elastic.co
    • helm install --namespace logging --name elasticsearch -f kubernetes/Charts/EFK/elasticsearch_custom_values.yaml elastic/elasticsearch
    • helm install --namespace logging --name kibana -f kubernetes/Charts/EFK/kibana_custom_values.yaml elastic/kibana
    • helm install --namespace logging --name fluend stable/fluentd

Homework #22 - Kubernetes-4

  1. Helm - charts, templates, helpers, dependencies
  2. Tiller plugin
  3. Helm3
  4. GitLab - bootsrap from helm chart
  5. Push reddit microservices repos to GitLab
  6. GitLab CI
  7. (*) - use pipline triggering by call curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master $CI_API_V4_URL/projects/1/trigger/pipeline in end of release joib of each microservice

Homework #21 - Kubernetes-3

  1. Services, kube-dns, nodePort, LoadBalancer, Ingress
  2. Secret, TLS Termination)
  3. (*) manifest with secret for UI Ingress - kubernetes/reddit/ui-ingress-secret.yml
  4. Network Policy
  5. Volumes, PV, PVC, StorageClass

Homework #20 - Kubernetes-2

  1. Install kubectl
  2. Install Minikube
  3. Start Minikube cluster
  4. Inspect kubectl context
  5. Prepare reddit-app k8s mainfests - deployments, services
  6. Play with namespaces
  7. Setup Kubernetes Dashboard
  8. Start GKE cluster
  9. (*) - bootstrap GKE cluster using Terraform (kubernetes/terraform)
  10. (*) - access to Kubernetes Dashboard:
    • install Dashboard - kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
    • create ServiceAccount and ClusterRoleBinding kubectl apply -f dashboard/dashboard-adminuser.yaml
    • Get dasboard access token - kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Homework #19 - Kubernetes-1

  1. Describe reddit-app in Kubernetes manifests
  2. Walked through Kubernetes The Hard Way
  3. (*/2) - try not so hard way, using prepared ansible playbooks:
    • git clone [email protected]:zlbabe/Kubernetes-the-hard-way-with-Ansible.git
    • cd Kubernetes-the-hard-way-with-Ansible
    • vagrant up
    • ansible-playbook k8s.yml

Docker images placed in https://hub.docker.com/u/bars83/

Homework #18 - Logging

  1. Update reddit-app to looging-ready code
  2. Add docker-compose-logging.yml to describe EFK (Elasticsearch+Fluentd+Kibana) services
  3. Play with EFK structured logs
  4. Set unstructured logs parsing
  5. (*) - add fluentd grok pattern to parse UI service logs
  6. Using Zipkin distributed tracing system
  7. (*) - on bugged-code Zipin traicing shows 3sec delay while getting post in post service. It seem that developer forget to remove time.sleep(3) on line 167 of post-py/post_app.py. Zipkin tracing was very helpful to find this botleneck.

Homework #17 - Monitoring-2

  1. Separate docker-compose-monitoring.yml from base docker-compose file
  2. Using cAdvisor to monitor docker containers
  3. Using Grafana to metrics visualization - using dashboards from grafana.com, building custom dashboards
  4. Using Alermanager for metrics alerting in Slack channel
  5. (*) - update Makefile with new services
  6. (*) - get Docker daemon metrics https://medium.com/p/e02a6a5745a/responses/show), add Grafana dashboard (id=1229)
  7. (*) - using Telegraf to export Docker daemon metrics
  8. (*) - set up Alertmanager rule to fire on too high response latency of UI service by 95th percentile
  9. (**) - provision Grafana datasource and dashboards on container startup
  10. (***) - proxy Grafana to Prometheus requests with Trickster for caching

Homework #16 - Monitoring-1

  1. Run Prometheus container
  2. Monitoring Reddit microsevices with Prometheus
  3. Using Node Exporter to get host metrics
  4. (*) - MongoDB monitoring using https://github.com/percona/mongodb_exporter
  5. (*) - play with Blackbox exporter (https://github.com/prometheus/blackbox_exporter)
  6. (*) - play with Cloudprober exporter
  7. (*) - add Makefile to automate images preparing, building and pushing

Homework #15 - Gitlab CI

  1. Bootsrap Gitlab with docker-compose
  2. Setup Gitlab - create group and projects
  3. Add Gitlab as remote for our microservices projects
  4. Play with CI pipelines
  5. Play with gitlab environments (static and dynamic)
  6. (* task) - edit "build" job for docker image building
  7. (** task) - provision gitlab runner with ansible using gcp inventory (iaac in gitlab-ci/infra)
  8. (** task) - configure Slack notifications for Gitlab pipeline events

Homework #14 - docker #4

  1. Working with different docker network types - none, host, bridge
  2. Use docker-compose to run containerized reddit app
  3. Docker compose default project name use current folder and folder with service description names. To set docker-compose project name use -p parameter, e.g.: docker-compose -p reddit up -d
  4. Write docker-compose.override.yml to override some service parameters (e.g. volumes, commands)

Homework #13 - docker #3

  1. Write Dockerfile for each service
  2. Using ENV (-e) on docker run command
    • e.g. docker run -d --network=reddit --network-alias=my_comment -e COMMENT_ DATABASE_HOST=my_comment_db <your-dockerhub-login>/comment:2.0
  3. Use apline-based images to optimize srvices images
  4. Use docker volume to store state
  5. Use hadolint for Dockerfile's linting:
    • e.g. docker run --rm -i hadolint/hadolint < ./comment/Dockerfile

Homework #12 - docker #2

  1. Playing with docker
  2. Using docker-machine with GCE
      • IaaC using Ansible+Packer+Terrafor to start dockerized reddit-app in GCE

About

bars83 microservices repository

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published