Code Monkey home page Code Monkey logo

nginx-kubernetes-lb's Introduction

This is not an official Google product.

Load Balancing Kubernetes Services with NGINX+

This app demonstrates how to make use of NGINX+ Layer 7 load balancing with Kubernetes services.

The app

Kubernetes Services

The app consists of four Kubernetes services written in Ruby, Python, Node, and Go. The services run in Docker containers, and each one does string manipulation based on a request to an endpoint with a str parameter. They each have a replication controller (rc.yaml), which configures the number of pods running in the container.

NGINX+ Load Balancer

The load balancer routes all requests to our backend services through one external IP, and is configured in nginx.conf. There is an upstream server for each of the four services. In the first server block, requests to the four endpoints are proxied to the correct upstream via proxy_pass. The second server block configures a status page listening on port 8080 to make use of NGINX+ live monitoring.

Load Testing with Seige

The app uses Siege to load test the nginxplus service. The code for this can be found in the load-generator directory.

Deploying

  1. Create a project in the Google Cloud Developer console.

  2. Install Docker, then create a Docker instance and host it on Google Compute Engine in your Cloud project.

  3. Register for NGINX+ and copy your certificate and license key into the nginx-repo.crt and nginx-repo.key files.

  4. Deploy the four Kubernetes services by running make deploy inside each services directory: arrayify, reverse, to_lower, and to_upper. To verify that 3 replicas are running for each service, run kubectl get pods.

  5. Deploy the nginxplus service by running make deploy from the nginx directory. Then run kubectl get svc to get the external IP address for your nginxplus service.

  6. When you navigate to this IP in the browser, you should see the "Nginx is running!" page. Next, verify that each service is running correctly: YOUR-IP/reverse/?str=teststring.

  7. Try out NGINX+ live monitoring by visiting the status page: YOUR-IP:8080/status.html. When you make a request to one of the services, you should see the requests and connections count update in realtime on the status page.

  8. Load test your service by running the Seige load generator.

nginx-kubernetes-lb's People

Contributors

sararob avatar thesandlord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nginx-kubernetes-lb's Issues

Anti-pattern: No security context for pods

Dear Colleague,

We are looking to find ways to help developers find security misconfigurations, i.e., violation of security best practices in Kubernetes manifests. We have noticed an instance of no security context in one of your Kubernetes manifests. The recommended practice is use of security context for pods. without defining a security context for the pod, a container may run with root privilege and write permission into the root file system, making the Kubernetes cluster vulnerable. For examples of Kubernetes security anti-patterns we are following our peer-reviewed publication on Kubernetes security best practices (https://arxiv.org/pdf/2006.15275.pdf).

Location:

- image: <CONTAINER>

Please use securityContext to fix this misconfiguration. We would like to hear if you agree to fix this misconfiguration or have fixed the misconfiguration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.