Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crcsmnky/weatherinfo
A simple app that displays the weather for single or multiple cities. Perfect for testing Kubernetes and/or Istio!
https://github.com/crcsmnky/weatherinfo
flask istio kubernetes python
Last synced: about 2 months ago
JSON representation
A simple app that displays the weather for single or multiple cities. Perfect for testing Kubernetes and/or Istio!
- Host: GitHub
- URL: https://github.com/crcsmnky/weatherinfo
- Owner: crcsmnky
- License: apache-2.0
- Created: 2019-03-21T18:46:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-16T03:09:54.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T13:28:09.725Z (3 months ago)
- Topics: flask, istio, kubernetes, python
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 20
- Watchers: 3
- Forks: 13
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What's the Weather?
This is a sample app meant for use with Kubernetes and/or Istio. It displays the weather from a single city (Austin, TX) or multiple cities (Austin, New York, San Francisco, Seattle).
## Building
The images can be built using [Docker](http://docker.com) or using [Cloud Build](http://cloud.google.com/cloud-build). To build an invidual image, refer to the following example:
`gcloud builds submit --tag gcr.io/[PROJECTID]/weather-frontend:1.0 frontend/`
Or to build all of the images, run `build-images.sh`.
## Deploying
There are deployment specifications for Kubernetes and Istio in `manifests`. Before proceeding, you will need an API key from [OpenWeatherMap](http://openweathermap.org/api).
Once you have your API key, add a `Secret` to your Kubernetes cluster:
- `kubectl create secret generic openweathermap --from-literal=apikey=[OPENWEATHERMAP-API-KEY]`### Kubernetes
To deploy the app to Kubernetes (without Istio), use the following commands:
- `kubectl apply -f manifests/weather-deployment.yaml`*Note*: the Services are not externally accessible (no Ingress resource is created) so to access `weather-frontend` you'll need to use port forwarding and open [http://localhost:5000](http://localhost:5000):
- `kubectl port-forward deployment/weather-frontend 5000:5000`### Kubernetes and Istio
Once you have created a Kubernetes cluster and installed Istio, you can deploy the sample app as follows.
First, enable auto-injection of the Envoy `istio-proxy`:
- `kubectl label ns default istio-injection=enabled`Then deploy the rules first and the app second:
- `kubectl apply -f manifests/weather-rules.yaml`
- `kubectl apply -f manifests/weather-deployment.yaml`Now grab the `istio-ingressgateway` Load Balancer IP address:
- `INGRESSGATEWAY=$(kubectl get svc -n istio-system istio-ingressgateway -o jsonpath="{.status.loadBalancer.ingress..ip}")`
- Open `http://$INGRESSGATEWAY` in a browser*Note:* If you do not want to enable auto-injection of `istio-proxy` for the `default` namespace, you can also use `istioctl` to include `istio-proxy` in your Pods:
- `kubectl apply -f <(istioctl kube-inject -f manifests/weather-deployment.yaml)`## Generating Load
This repo also contains a [Locust](http://locust.io) script to generate load against `weather-frontend`.
**IMPORTANT**
- The `loadgenerator` deployment is set to hit `weather-frontend.default:5000` and not `$INGRESSGATEWAY` therefore the traffic is coming from within the cluster
- The `loadgenerator` is configured as a single replica with `5` clients randomly generating requests every 1-5s. *Keep this in mind so you don't go over your OpenWeatherMap API Key quota*.To deploy `loadgenerator`, update `FRONTEND_HOST` in `manifests/loadgen.yaml` and then apply:
- `kubectl apply -f manifests/loadgen.yaml`