Kunal Verma
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # How to Deploy a Django Full-stack Application with Kubernetes ### Introduction Welcome to another blog from the Devtron ecosystem! In this tutorial, you'll learn to deploy a Django Full-stack Application over Kubernetes using Devtron. The best part is, you don't need to worry about working with K8s configuration files or setting up a CI/CD pipeline manually. Everything would be seamlessly done by the Devtron platform with a few button clicks. Let's see how we can achieve this! ### Pre-requisites Before moving forward, let's have a look at all the things you'll require to follow along: 1. **A full-stack Django Application on GitHub** For this tutorial, we'll be using a simple To-Do List application with PostgreSQL as the database. The application can be accessed from the [repo](https://github.com/devtron-labs/django-todo-app). 2. **Devtron installed and configured on your machine** If you haven't installed Devtron, feel free to check out the well-managed [documentation](https://docs.devtron.ai/) and join the [discord community](https://discord.devtron.ai/) for any help! ### Setting up the database - PostgreSQL Our application is using PostgreSQL as the database, so the very first step would be to deploy that. Here, we'll be using a community Helm Chart And deploy it with the help of the helm dashboard by Devtron. **`Step 1:`** Navigate to the Chart Store on the Devtron Dashboard and search for "postgresql". For this tutorial, we'll be using the `bitnami/postgresql(12.1.6)` chart, as shown below: ![](https://i.imgur.com/sgxT6mI.png) **`Step 2:`** Click on the preferred chart where you may refer to the README to know more about the helm chart. Head over to `Configure & Deploy` where you'll be further setting up your chart configurations. ![](https://i.imgur.com/esG1Jtx.png) **`Step 3:`** In the configuration window, the following details must be provided: - App Name - Project - Environment You can directly make changes in the chart's configuration file (`values.yaml`) here as per your requirements. For this tutorial, please add the following details: ``` auth: postgresPassword: "<root_password>" username: "<new_user>" password: "<user_password>" database: "<database_name>" ``` Once these parameters are properly set, you are ready to deploy your chart. Click `Deploy Chart` ![](https://i.imgur.com/XDRDLT7.png) Congratulations! Your postgreSQL database is up and running! You can now view the chart details by heading over to `Helm Apps/postgresql` on the dashboard. You will be able to check out all the resources it has deployed, including: - status of the application - chart version and many more as shown below. ![](https://i.imgur.com/sBCbwOD.png) > NOTE: Please note down the **service name** from here as that will be used while configuring the Django application. > In this case, it's `postgresql-2-devrel` ### Configuring the Application - Database Settings Before we dive into deploying our app using Devtron, we have to make some changes to the database settings. Head over to [`settings.py`](https://github.com/devtron-labs/django-todo-app/blob/main/TodoApp/settings.py) of our Django application, which contains the configuration for your SQL database. Make sure the configurations in `settings.py` matches the ones of the postgreSQL Helm Chart, that we have deployed in the steps above. > In this case, we are providing all the root user's details. ``` DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': '<database_name>', 'USER': '<root_username>', 'PASSWORD': '<root_password>', 'HOST': '<service_name>', } } ``` Once we have configured these settings, we are ready to deploy the application using Devtron ### Deploying the Application It's interesting to know that Devtron is capable of deploying any kind of application irrespective of the language or tech-stack chosen for the project. Before we move forward with creating an application, make sure your **Global Configurations** are set and properly validated. For more information on different sections of Global Configurations available in Devtron, please refer to the [documentation](https://docs.devtron.ai/global-configurations). **`Step 1:`** Head over to the `Create` dropdown on the Devtron dashboard and select `Custom app`. Provide the necessary details asked in the prompt window and click `Create App` ![](https://i.imgur.com/kCSwPtw.png) **`Step 2:`** After creating an app, you will be redirected to the `App Configuration` tab where you need to provide the following details: 1. **Git Repository:** The link to your project on GitHub - In this case, we are using a simple [To-Do app](https://github.com/devtron-labs/django-todo-app) 2. **Build Configuration:** Provide all the docker related information to build and push docker images of your app - Provide the details for the container repository to store your image - We are using a Dockerfile for our application, so will give the path to the same - You can also choose `buildpacks` as an option to deploy your application, if you don't have a Dockerfile. For more information, please refer the [documentation](https://docs.devtron.ai/usage/applications/creating-application/docker-build-configuration#build-docker-image-without-dockerfile) ![](https://i.imgur.com/tWFxyR0.png) 3. **Base Deployment Template:** The main deployment configuration goes here. The beauty of using the Deployment template is that you don't need to manually configure things like pod specs, hpa, service, ingress, etc. All these come pre-configured with the template and you just have to tweak some values as per the requirements. Following are the steps to configure the deployment of our app: - **`Step 1:`** Select a chart type from the following options: - Deployment (Recommended) - Rollout Deployment - Job & CronJob - **`Step 2:`** Configuring the `ingress` controller parameters as follows: ``` ingress: annotations: {} className: "nginx" enabled: true hosts: - host: <YOUR_DOMAIN> pathType: ImplementationSpecific paths: - /<END_POINTS> ``` - You can also refer to the README for the specific Deployment Chart, provided on the platform itself to configure more parameters as per your requirements. - Feel free to check out [this](https://devtron.ai/blog/setup-ingress-for-an-application-with-devtron/) blog to configure the `ingress` controller using Devtron. ![](https://i.imgur.com/Fq9M79N.png) 4. **Workflow Editor:** Here, you can set up a simple CI/CD pipeline for the application in no time using the platform itself. There are mainly 3 types pipelines that can be created here: (More information in the [documentation](https://docs.devtron.ai/usage/applications/creating-application/workflow)) - Continuous Integration - Linked CI Pipeline - Incoming Webhook Furthermore, the CI pipeline may also include Pre and Post-build stages to validate and introduce checkpoints in the build process. These can either be configured using some preset plugins like k6, Sonarqube etc. (as shown below) or using custom scripts as well. For more information on **Pre-build/Post-build tasks**, please refer to the [documentation](https://docs.devtron.ai/usage/applications/creating-application/ci-pipeline/ci-build-pre-post-plugins). ![](https://i.imgur.com/FOtw7B6.png) Let's move onto creating a CI/CD pipeline for our Django Application. - **`Step 1:`** For creating a CI pipeline, click on `+ New Workflow` --> `Build & deploy from source code` - In the "Create Pipeline" window, provide the necessary details as shown below and click on `Create Pipeline`: ![](https://i.imgur.com/WoiemQa.png) - **`Step 2:`** For creating the deployment pipeline, click the `+` icon corresponding to the CI. Configure the details as required, and click on `Create Pipeline`. ![](https://i.imgur.com/M6bxUdD.png) Awesome! You now have a fully configured CI/CD pipeline for your application. ![](https://i.imgur.com/Qphnesz.png) To know more about using the Workflow Editor, refer the [documentation](https://docs.devtron.ai/v/v0.6/usage/applications/creating-application/workflow). As we don’t have any `ConfigMaps` or `Secrets` for this application, let’s move to the **`Build & Deploy`** tab and trigger the CI Build. **`Step 3:`** In the `Build & Deploy` tab, click `Select Material` and then select the commit against which you want to build an image, then click `Start Build`. ![](https://i.imgur.com/X0XtbHa.png) This will start building your image. You can also view runtime logs, commit details for the particular build, security results (if enabled), and artifacts. Once the build is **successful**, the status will be updated accordingly! ![](https://i.imgur.com/ewd2kX8.png) **`Step 4:`** Now is the time to deploy the application using the image we built in the previous step. ![](https://i.imgur.com/2qzXr0n.png) Now, we can check the status of our deployment on the `App Details` tab. Once the the deployment is successful, it would reflect the **Application Status: Healthy**. Furthermore, you can view all additional information about your deployed application such as: - The deployment environment - K8s resources like pods, services, etc - Manifests of individual resources - logs and much more ![](https://i.imgur.com/ftMaUNl.png) **`Step 5:`** We have successfully deployed our Django app over Kubernetes 🎉 To check whether our application and database are running successfully, we can view this in our browser. The syntax is: `http://<hostname>/<path>` > "hostname" & "path" would be the ones given in ingress while configuring the Deployment Template (refer the steps above) ![](https://i.imgur.com/PgBcgI1.png) `NOTE:` An additional step here could be mapping your `domain_name` with the load balancer IP address, which can be found in the manifest of ingress (as shown below) ``` status: loadBalancer: ingress: - ip: <IP_ADDRESS> ``` ### Conclusion We have successfully deployed our Django Application over Kubernetes using Devtron. If you like Devtron, do give us a ⭐️ on github and feel free to join the [discord community](https://discord.devtron.ai/) for all the latest updates.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully