Code Monkey home page Code Monkey logo

kubernetes-workshop's Introduction

Kubernetes Cluster Creation and FastAPI Deployment

This project facilitates the automated creation of a Kubernetes cluster on Google Cloud Platform (GCP) using Terraform and deploys a FastAPI application using Helm.

Architecture

Prerequisites

  1. Google Cloud SDK: You must have the Google Cloud SDK installed and configured with appropriate permissions.

  2. Terraform: Terraform version 0.13 or newer must be installed.

  3. kubectl: Kubernetes command-line tool, kubectl, must be installed.

  4. Helm: Helm version 3 or newer must be installed.

  5. Docker: If you want to build the container image locally, you will need Docker installed. Code can be found here

Setup

1. Google Cloud Configuration

Ensure you have the appropriate permissions and set the necessary environment variables:

gcloud auth login
gcloud auth application-default login

2. Terraform Variable Configuration

Navigate to the vars directory then copy and update the tfvars file

cd vars
cp example.tfvars dev.tfvars

3. Terraform Initialisation and Cluster Creation

Navigate to the Terraform directory and run the following commands to initialise and create the cluster:

cd ../terraform
terraform init
terraform apply -var-file=../vars/dev.tfvars

By following these commands, Terraform will initialse the configuration within the directory and apply the defined plan. It will create a Kubernetes cluster on Google Cloud Platform using the specifications defined in your Terraform files. Ensure that the variables within the Terraform vars files are properly set up to match your desired cluster configuration.

4. Helm Chart Configuration

Make sure your Kubernetes cluster is configured as the current context for kubectl, then navigate to the Helm chart directory, copy and update the helm values to match your configuration (Redis IP, SQL IP, etc).

cd ../helm/charts/
cp values.yaml.example values.yaml

5. FastAPI Deployment

Deploy the FastAPI application using Helm:

helm install firney-workshop .

Usage

Your FastAPI application will be available at the load balancer's IP address, which you can find using.

kubectl get ingress -n workshop

If you would like to test your new api you can downlaod our postman collection here

Customisation

You can customise various parameters of both the Kubernetes cluster and the FastAPI application by modifying the respective Terraform and Helm configuration files.

Cleaning Up

To destroy the created resources:

helm uninstall firney-workshop
cd ../../terraform
terraform destroy -var-file=../vars/dev.tfvars

kubernetes-workshop's People

Contributors

ashleymaloney 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.