npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

kubernetes-env

v1.0.0

Published

first pipeline test in project

Downloads

6

Readme

Deploying a Flask API and MySQL server on Kubernetes

This repo contains code that

  1. Deploys a MySQL server on a Kubernetes cluster
  2. Attaches a persistent volume to it, so the data remains contained if pods are restarting
  3. Deploys a Flask API to add, delete and modify users in the MySQL database

Prerequisites

  1. Have Docker and the Kubernetes CLI (kubectl) installed together with Minikube (https://kubernetes.io/docs/tasks/tools/)

Getting started

  1. Clone the repository
  2. Configure Docker to use the Docker daemon in your kubernetes cluster via your terminal: eval $(minikube docker-env)
  3. Pull the latest mysql image from Dockerhub: Docker pull mysql
  4. Build a kubernetes-api image with the Dockerfile in this repo: Docker build . -t flask-api

Secrets

Kubernetes Secrets can store and manage sensitive information. For this example we will define a password for the root user of the MySQL server using the Opaque secret type. For more info: https://kubernetes.io/docs/concepts/configuration/secret/

  1. Encode your password in your terminal: echo -n super-secret-passwod | base64
  2. Add the output to the flakapi-secrets.yml file at the db_root_password field

Deployments

Get the secrets, persistent volume in place and apply the deployments for the MySQL database and Flask API

  1. Add the secrets to your kubernetes cluster: kubectl apply -f flaskapi-secrets.yml
  2. Create the persistent volume and persistent volume claim for the database: kubectl apply -f mysql-pv.yml
  3. Create the MySQL deployment: kubectl apply -f mysql-deployment.yml
  4. Create the Flask API deployment: kubectl apply -f flaskapp-deployment.yml

You can check the status of the pods, services and deployments.

Creating database and schema

The API can only be used if the proper database and schemas are set. This can be done via the terminal.

  1. Connect to your MySQL database by setting up a temporary pod as a mysql-client: kubectl run -it --rm --image=mysql --restart=Never mysql-client -- mysql --host mysql --password=<super-secret-password> make sure to enter the (decoded) password specified in the flaskapi-secrets.yml
  2. Create the database and table
    1. CREATE DATABASE flaskapi;
    2. USE flaskapi;
    3. CREATE TABLE users(user_id INT PRIMARY KEY AUTO_INCREMENT, user_name VARCHAR(255), user_email VARCHAR(255), user_password VARCHAR(255));

Expose the API

The API can be accessed by exposing it using minikube: minikube service flask-service. This will return a URL. If you paste this to your browser you will see the hello world message. You can use this service_URL to make requests to the API

Start making requests

Now you can use the API to CRUD your database

  1. add a user: curl -H "Content-Type: application/json" -d '{"name": "<user_name>", "email": "<user_email>", "pwd": "<user_password>"}' <service_URL>/create
  2. get all users: curl <service_URL>/users
  3. get information of a specific user: curl <service_URL>/user/<user_id>
  4. delete a user by user_id: curl -H "Content-Type: application/json" <service_URL>/delete/<user_id>
  5. update a user's information: curl -H "Content-Type: application/json" -d {"name": "<user_name>", "email": "<user_email>", "pwd": "<user_password>", "user_id": <user_id>} <service_URL>/update