Giter Club home page Giter Club logo

generator-k8s-simple's Introduction

Simple generator for Kubernetes resources

This generator creates a Kubernetes Service and Deployment Resource to deploy a Spring Boot application. It also can create the Kubernetes resources for deploying a MySQL database or a small Kafka cluster, should the application need it.

If you used the starter service, then the generator has already been executed and you can deploy it's required services and then build and deploy the application.

Deploy required services

If your application needs services such as a database or message broker, this section shows you how to deploy these services to Kubernetes

MySQL

Step 1: Create a secret:

kubectl create secret generic mysql \
  --from-literal=mysql-root-password=$(echo $RANDOM) \
  --from-literal=mysql-password=$(echo $RANDOM)

Step 2: Deploy the database:

kubectl apply -f kubernetes/services/mysql

Deleting Resources

To recreate the secret, first delete the existing secret:

kubectl delete secret mysql

To delete the database storage, delete the persistent volume:

kubectl delete pvc mysql

To delete the MySQL service and deployment in addition to the persistent volume:

kubectl delete deployment,services,pvc -l app=mysql

Kafka

Deploy the cluster:

kubectl apply -f kubernetes/services/kafka

Deleting Resources

To delete the Kafka cluster and Zookeeper:

kubectl delete deployment,services -l app=kafka

Building and deploying the application

This generator relies on using the new buildpack support added in Spring Boot version 2.3 to create a container image.

If you are using Minikube you should configure your terminal to use the same Docker environment:

eval $(minikube docker-env)

Step 1: Build the project and create the container image:

./mvnw -DskipTests clean package spring-boot:build-image

Step 2: Deploy the app to Kubernetes

kubectl apply -f kubernetes/app

Use kubectl get all to verify that the resources created.

Accessing the application's endpoint varies based on the type of Kubernetes cluster you are using. For example, if minikube is being used, look for the endpoint to access using the command minikube service list. For othetr Kubernetes clusters, you can use port-forwarding to access the service. Run kubectl port-forward service/<name-of-service> 8080:80 to forward the service port to localhost:8080.

The README.md file from the code repository for the appliation should include a few curl commands to exercise the application.

Generator Information

This generator creates the Kubernetes service and deploymnet resources files to deploy a Spring Boot application using kubectl

To use the generator you will need to install the following command line tool:

Generator Commands

These commands use the tss CLI.

tss k8s-simple new creates

  • A kubernetes directory with a service.yaml and deployment.yaml

tss k8s-simple new-services creates

  • A kubernetes/services/<service-name> directory with Kubernetes resource files for various services. Currently only mysql service name is supported.

Generator installation

tss generator install --go-getter-url=github.com/markpollack/generator-k8s-simple

To use the install command you need to install go-getter CLI.

generator-k8s-simple's People

Contributors

markpollack avatar trisberg avatar

Watchers

 avatar

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.