Skip to content

Commit

Permalink
Added basic setup for the new k8s example (#163)
Browse files Browse the repository at this point in the history
* Added basic setup for the new k8s example

* Updated example to include two services

* Updated setup

* Updated code
  • Loading branch information
ulises-jeremias authored Dec 4, 2023
1 parent 09e2397 commit 3064170
Show file tree
Hide file tree
Showing 50 changed files with 11,314 additions and 0 deletions.
89 changes: 89 additions & 0 deletions examples/kubernetes-tilt-dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Tilt + Minikube Development Environment 🚀

Welcome to a seamless, efficient, and developer-friendly Kubernetes development experience! This repository combines the power of [Tilt](https://tilt.dev/) and [Minikube](https://minikube.sigs.k8s.io/) to supercharge your microservices development. Say goodbye to complex configurations and hello to streamlined development!

## Why This Demo Matters

This demo isn't just about showcasing two impressive microservices. It's about empowering developers to harness the agility of Kubernetes without the steep learning curve. We've crafted an environment that's easy to set up, intuitive to navigate, and accelerates your development workflow.

## What's Inside? 🏗️

In this repository, you'll find two remarkable microservices waiting for you:

1. **Node.js with Nest.js** 🟢
A beautifully crafted Nest.js API, complete with Swagger integration for effortless exploration.

2. **Python with FastAPI** 🐍
Dive into FastAPI's high-performance world! Another RESTful API flaunting a Swagger interface for swift exploration.

### Directory Structure 📁

```txt
.
├── apps
│ ├── node-nestjs-app
│ │ ├── ...
│ │ ├── Dockerfile
│ │ └── README.md
│ └── python-fastapi-app
│ ├── ...
│ ├── Dockerfile
│ └── README.md
├── k8s
│ ├── node-nestjs-app
│ │ ├── deployment.yml
│ │ └── service.yml
│ ├── python-fastapi-app
│ │ ├── deployment.yml
│ │ └── service.yml
│ ├── ingress.yml
│ └── namespaces.yml
├── README.md
└── Tiltfile
```

## Getting Started 🚦

1. **Clone This Repository**
2. **Install Minikube**: Follow [Minikube's installation guide](https://minikube.sigs.k8s.io/docs/start/) if you haven't already.
3. **Install Tilt**: Refer to [Tilt's installation guide](https://docs.tilt.dev/install.html).

### Starting Minikube and Tilt

```sh
minikube start
tilt up
```

Once initiated, visit [http://localhost:10350/](http://localhost:10350/) to explore the Tilt dashboard.

### Enable Ingress and Tunnel

To access your microservices, you'll need to enable Ingress and tunnel to your cluster. Run the following commands to do so:

```sh
minikube addons enable ingress
minikube tunnel
```

## Explore the Microservices

Use the Tilt dashboard to explore your microservices, view logs, and more. Click the `View` button next to each service to access its Swagger UI.

## Understanding Kubernetes ⚙️

### Ingress

The `k8s/ingress.yml` routes traffic to the microservices. Enable it with:

### Namespaces

Organize microservices using the `k8s/namespaces.yml` file, making management a breeze.

### Microservices

Each microservice in `k8s/` has a Deployment and Service resource, handling deployment and exposure.

## Tiltfile 📜

The `Tiltfile` configures Tilt. Customize your dev environment and add more microservices here.
21 changes: 21 additions & 0 deletions examples/kubernetes-tilt-dev/Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version_settings(constraint='>=0.22.2')

k8s_yaml(['k8s/namespace.yml'])

docker_build(
'k8s-tilt-dev-example-node-nestjs-app',
'apps/node-nestjs-app/',
target='development',
)

k8s_yaml(['apps/node-nestjs-app/k8s/deployment.yml', 'apps/node-nestjs-app/k8s/service.yml'])

docker_build(
'k8s-tilt-dev-example-python-fastapi-app',
'apps/python-fastapi-app/',
target='development',
)

k8s_yaml(['apps/python-fastapi-app/k8s/deployment.yml', 'apps/python-fastapi-app/k8s/service.yml'])

k8s_yaml('k8s/ingress.yml')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
build
dist
tools
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions examples/kubernetes-tilt-dev/apps/node-nestjs-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
};
10 changes: 10 additions & 0 deletions examples/kubernetes-tilt-dev/apps/node-nestjs-app/.eslitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# /node_modules/* in the project root is ignored by default
# build artefacts
dist/*
coverage/*
node_modules/*
logs/*
prod/*
.husky/*
.github/*
tools/
Loading

0 comments on commit 3064170

Please sign in to comment.