FLOSS Project Planets

KDE Plasma 5.27.11, Bugfix Release for March

Planet KDE - Tue, 2024-03-05 19:00

Wednesday, 6 March 2024. Today KDE releases a bugfix update to KDE Plasma 5, versioned 5.27.11.

Plasma 5.27 was released in February 2023 with many feature refinements and new modules to complete the desktop experience.

The bugfixes are typically small but important and include:

  • Plasma Browser Integration: 🍒🍒Download Job: Truncate excessively long URLs. Commit.
  • KWin: Tabbox: match Shift+Backtab against Shift+Tab. Commit. Fixes bug #438991
  • Powerdevil: Kbd backlight: Fix double brightness restore on LidOpen-resume. Commit.
View full changelog
Categories: FLOSS Project Planets

GNUnet News: GNUnet 0.21.0

GNU Planet! - Tue, 2024-03-05 18:00
GNUnet 0.21.0 released

We are pleased to announce the release of GNUnet 0.21.0.
GNUnet is an alternative network stack for building secure, decentralized and privacy-preserving distributed applications. Our goal is to replace the old insecure Internet protocol stack. Starting from an application for secure publication of files, it has grown to include all kinds of basic protocol components and applications towards the creation of a GNU internet.

This release marks a noteworthy milestone in that it includes a completely new transport layer . It lays the groundwork for fixing some major design issues and may also already alleviate a variety of issues seen in previous releases related to connectivity. This change also deprecates our testbed and ATS subsystem.

This is a new major release. It breaks protocol compatibility with the 0.20.x versions. Please be aware that Git master is thus henceforth (and has been for a while) INCOMPATIBLE with the 0.20.x GNUnet network, and interactions between old and new peers will result in issues. In terms of usability, users should be aware that there are still a number of known open issues in particular with respect to ease of use, but also some critical privacy issues especially for mobile users. Also, the nascent network is tiny and thus unlikely to provide good anonymity or extensive amounts of interesting information. As a result, the 0.21.0 release is still only suitable for early adopters with some reasonable pain tolerance .

Download links

The GPG key used to sign is: 3D11063C10F98D14BD24D1470B0998EF86F59B6A

Note that due to mirror synchronization, not all links might be functional early after the release. For direct access try http://ftp.gnu.org/gnu/gnunet/

Changes

A detailed list of changes can be found in the git log , the NEWS and the bug tracker .

Known Issues
  • There are known major design issues in the CORE subsystems which will need to be addressed in the future to achieve acceptable usability, performance and security.
  • There are known moderate implementation limitations in CADET that negatively impact performance.
  • There are known moderate design issues in FS that also impact usability and performance.
  • There are minor implementation limitations in SET that create unnecessary attack surface for availability.
  • The RPS subsystem remains experimental.

In addition to this list, you may also want to consult our bug tracker at bugs.gnunet.org which lists about 190 more specific issues.

Thanks

This release was the work of many people. The following people contributed code and were thus easily identified: Christian Grothoff, t3sserakt, TheJackiMonster, Pedram Fardzadeh, dvn, Sebastian Nadler and Martin Schanzenbach.

Categories: FLOSS Project Planets

Lullabot: The New Storybook Module for Drupal

Planet Drupal - Tue, 2024-03-05 16:05

Component-based web development has become the de facto approach for new Drupal projects. Componentizing your UI has multiple advantages, like modular development, improved automated testing, easier maintenance, code reusability, better collaboration, and more.

Categories: FLOSS Project Planets

PyCoder’s Weekly: Issue #619 (March 5, 2024)

Planet Python - Tue, 2024-03-05 14:30

#619 – MARCH 5, 2024
View in Browser »

Duck Typing in Python: Writing Flexible and Decoupled Code

In this tutorial, you’ll learn about duck typing in Python. It’s a typing system based on objects’ behaviors rather than on inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that you can use together or individually.
REAL PYTHON

Using IPython Jupyter Magic Commands

“IPython Jupyter Magic commands (e.g. lines in notebook cells starting with % or %%) can decorate a notebook cell, or line, to modify its behavior.” This article shows you how to define them and where they can be useful.
STEFAN KRAWCZYK

Posit Connect - Make Deployment the Easiest Part of Your Data Science Workflow

Data scientists use Posit Connect to securely share insights. Automate time-consuming tasks & distribute custom-built tools & solutions across teams. Publish data apps, docs, notebooks, & dashboards. Deploy models as APIs, & configure reports to run & get distributed on a custom schedule →
POSIT sponsor

Monkeying Around With Python: A Guide to Monkey Patching

Monkey patching is the practice of modifying live code. This article shows you how its done and why and when to use the practice.
KARISHMA SHUKLA

DjangoCon US Call for Proposals

DJANGOCON

White House Recommends Use of Python

PYTHON SOFTWARE FOUNDATION

JupyterLab 4.1 and Notebook 7.1 Released

JUPYTER

Articles & Tutorials Requests Maintainer Reflects on the Project After a Decade

One of the oldest active maintainers of the popular requests libraries reflects on the project’s good and bad parts over the last several years. He posits things that would improve the project and maintenance thereof. He also talks about what’s holding the project back right now. Associated Hacker News discussion.
IAN STAPLETON CORDASCO • Shared by nah

Improve the Architecture of Your Python Using import-linter

For large Python projects, managing dependency relationships between modules can be challenging. Using import-linter, this task can be made easier. This article provides a simple introduction to the import-linter tool and presents 6 practical ways to fix inappropriate dependencies.
PIGLEI • Shared by piglei

We’re Building the Future of Humanity Using Python No Other Language Will Give You Better Results

Today, you can build AI & data apps using only Python! This open-source Python end-to-end app builder helps you with it. Similar to Steamlit but designed to build production-ready apps, it offers some differences: scales as more users hit the app, can work with huge datasets, and is multi-user →
TAIPY sponsor

How to Read User Input From the Keyboard in Python

Reading user input from the keyboard is a valuable skill for a Python programmer, and you can create interactive and advanced programs that run on the terminal. In this tutorial, you’ll learn how to create robust user input programs, integrating error handling and multiple entries.
REAL PYTHON

Tracing System Calls in Python

This article shows you how to trace the system calls made when you run your Python program. It includes how you can use the Perfetto trace viewer to visualize the interactions.
MATT STUCHLIK

The Most Important Python News in 2023

Vita has put together a site using data from the PyCoder’s newsletter. The site itself is built using Python tools. If you missed something in 2023, you might find it here.
VITA MIDORI • Shared by Vita Midori

Django Login, Logout, Signup, Password Change and Reset

Learn how to implement a complete user authentication system in Django from scratch, consisting of login, logout, signup, password change, and password reset.
WILL VINCENT • Shared by Will Vincent

Why Python’s Integer Division Floors

This article on the Python History blog talks about why the decision was made to have integer division use floors, instead of truncation like C.
GUIDO VAN ROSSUM

Falsehoods Junior Developers Believe About Becoming Senior

This opinion piece by Vadim discusses how newer developers perceive what it means to be a senior developer, and how they’re often wrong.
VADIM KRAVCENKO

What’s in a Name?

An article about names in Python, and why they’re not the same as objects. The article discusses reference counts and namespaces.
STEPHEN GRUPPETTA • Shared by Stephen Gruppetta

Reduce, Reuse, Recycle: McDonald’s Reusable Workflows

This post on McDonald’s technology blog talks about how they take advantage of reusable workflows with GitHub Actions.
MICHAEL GORELIK

Popular git Config Options

This post covers some of the more popular options you can use when configuring git, and why you might choose them.
JULIA EVANS

Projects & Code logot: Test Whether Your Code Is Logging Correctly

GITHUB.COM/ETIANEN

hypofuzz: Adaptive Fuzzing of Hypothesis Tests

GITHUB.COM/ZAC-HD

cantok: Implementation of the “Cancellation Token” Pattern

GITHUB.COM/POMPONCHIK • Shared by Evgeniy Blinov

xonsh: Python-Powered, Cross-Platform, Unix-Gazing Shell

GITHUB.COM/XONSH

django-queryhunter: Find Your Expensive Queries

GITHUB.COM/PAULGILMARTIN • Shared by Paul

Events Eclipse Insights: How AI Is Transforming Solar Astronomy

March 5, 2024
MEETUP.COM • Shared by Laura Stephens

Weekly Real Python Office Hours Q&A (Virtual)

March 6, 2024
REALPYTHON.COM

Canberra Python Meetup

March 7, 2024
MEETUP.COM

Sydney Python User Group (SyPy)

March 7, 2024
SYPY.ORG

PyCon Pakistan 2024

March 9 to March 11, 2024
PYCON.PK

Django Girls CDO Workshop 2024

March 9 to March 10, 2024
DJANGOGIRLS.ORG

PyCon SK 2024

March 15 to March 18, 2024
PYCON.SK

Happy Pythoning!
This was PyCoder’s Weekly Issue #619.
View in Browser »

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

Categories: FLOSS Project Planets

ImageX: Unlocking Customer Management Efficiency: A Deep Dive into CRM Integration with Drupal Websites

Planet Drupal - Tue, 2024-03-05 13:15

Authored by: Nadiia Nykolaichuk.

Managing customer interactions touches on many aspects. Luckily, instead of using endless spreadsheets, notes, emails, chats, and form fills, you can rely on just one application — a CRM, or customer management system. A CRM will help you easily consolidate, manage, track, and analyze all customer interactions at every step of their journey throughout your sales funnel. 

Categories: FLOSS Project Planets

Chapter Three: Chapter Three is a Certified Drupal 7 Migration Partner!

Planet Drupal - Tue, 2024-03-05 12:17
Happy March! If you’re reading this blog post on the day of publication, you now have exactly eight months to migrate out of Drupal 7 before it reaches end of life on January 5, 2025. After numerous extensions, this date is final and there will be no further extensions.
Categories: FLOSS Project Planets

Matt Glaman: Improving the Drupal theme starterkit and theme generation experience

Planet Drupal - Tue, 2024-03-05 09:18

Wanting to follow up on our work at MidCamp 2023 with the Development Settings form, Mike Herchel wanted to jam on another issue to improve the life of frontend developers. Drupal provides a way to generate themes from starterkit themes. Drupal core provides the Starterkit theme, and contributed themes can also mark themselves as a starterkit theme. All a theme has to do is have starterkit: true in their info.yml file. And that's it! Optionally, a specifically named PHP file can be provided in the theme for specific processing to finish generating the new theme. Unfortunately, the experience of creating starterkit themes currently involves writing a lot of PHP code to make the required file alterations.

Categories: FLOSS Project Planets

Real Python: Creating Asynchronous Tasks With Celery and Django

Planet Python - Tue, 2024-03-05 09:00

You’ve built a shiny Django app and want to release it to the public, but you’re worried about time-intensive tasks that are part of your app’s workflow. You don’t want your users to have a negative experience navigating your app. You can integrate Celery to help with that.

Celery is a distributed task queue for UNIX systems. It allows you to offload work from your Python app. Once you integrate Celery into your app, you can send time-intensive tasks to Celery’s task queue. That way, your web app can continue to respond quickly to users while Celery completes expensive operations asynchronously in the background.

In this video course, you’ll learn how to:

  • Recognize effective use cases for Celery
  • Differentiate between Celery beat and Celery workers
  • Integrate Celery and Redis in a Django project
  • Set up asynchronous tasks that run independently of your Django app
  • Refactor Django code to run a task with Celery instead

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

January and February in KDE PIM

Planet KDE - Tue, 2024-03-05 07:00

Here's our bi-monthly update from KDE's personal information management applications team. This report covers progress made in the months of January and February 2024.

Since the last report, 34 people contributed approximately 1742 code changes, focusing on bugfixes and improvements for the coming 24.02 release based on Qt6.

Akonadi

The database migration tool to help users easily switch between different database engines has been completed and merged. The tool can be used like this to migrate from the current engine to SQLite, however migration between any combinations of the supported database engines works.

akonadi-db-migrator --newengine sqlite

Unfortunately, the migrator is not available in the 24.02 megarelease, as some big fixes came too late to be safely merged into a stable branch. It will be included in the next feature release.

We also tried to improve handling of a race condition when syncing a very large IMAP folder, where if user marked an email as read in KMail while the folder was syncing, the change got reverted by the sync.

There were also some additional code improvements, test fixes and some last-minute fixes due to changes betwene Qt5 and Qt6 that we missed.

Thank's to g10 Code GmbH for sponsoring part of Dan's work on Akonadi improvements.

KOrganizer

A long-standing issue with un-answered and declined invitations not showing in KOrganizer was fixed. It's common when using enterprise calendar solutions (Google, EWS, etc.) that when a user is invited into a meeting, the invitation is automatically added to their calendar. KOrganizer used to filter those out and instead implemented special "Open Invitations" and "Declined Invitations" meta-calendars that were supposed to show those. Unfortunately this feature never really worked properly and so users were confused where are their meetings. This "feature" has been removed in 24.02 and KOrganizer will show all invites without any filter. In 24.05 release, KOrganizer will also have a checkbox in its Settings to let users to choose whether to hide declined invitations globally.

  • Fixed syncing of Google contacts not working if the sync token has expired.
  • Prepared for upcoming changes in Google Calendar API behavior.
  • Calendar colors not matching configured colors in Google or DAV has been fixed.
  • When creating a recurrence exception, KOrganizer now uses correct timezone #481305.
  • Fixed 'Create sub-todo' action in KOrganizer being always disabled #479351.
  • Fixed iCal resource getting stuck in a loop and consuming lots of CPU when syncing specific calendars #384309.

Dan's work on improving KOrganizer and calendaring was sponsored by g10 Code GmbH.

KMail

Big new feature is support for OAuth login for personal Outlook365 accounts via IMAP and SMTP. The OAuth login is more reliable than standard username+password authentication and it means that users with Two Factory Authentication for their Outlook365 accounts no longer have to set up an app-specific password. Note that users who have account as part of their school or work organizations should use the EWS resource, which already supports OAuth login.

The account wizard rewrite using QML is progressing and aside from some edge cases, the automatic configuration of your account based on the Thunderbird online configuration should work again. The UI also received some improvements:

In addition a lot of bugs were fixed. This includes:

  • Fixed encrpyted attachments not showing in email header even after decrypting the email.
  • Fixed EWS configuration dialog asking for both an username and an email address
  • Changed the default encryption of new IMAP and SMTP connections to the more secure SSL/TLS transport
Itinerary

With the Qt 6 transition completed Itinerary has gotten a new journey map view, public transport data coverage for more countries and many more improvements. See Itinerary's bi-monthly status update for more details.

Kleopatra

For large files the performance of encryption, decryption, signing, and signature verification has been improved (by making gpg read and write the files directly). This is most noticeable on Windows. T6351

The usability was improved in a few places:

  • The configuration of certificate groups is now much easier because changes are applied directly. T6662
  • Users can now change the name of the decryption result if a file with the same name already exists. T6851
  • The workflow of moving a key to a smart card was streamlined. T6933
  • Kleopatra now reads certificates automatically from certain smart cards. T6846

Additionally, a few bugs affecting the Windows builds have been fixed:

  • A wrong permission check when writing the decryption result to a network drive was fixed. (Technical details: Qt allows to enable expensive ownership and permissions checking on NTFS file systems. Unfortunately, these checks seem to give wrong results for network drives.) T6917
  • Kleopatra now displays all icons also in dark mode. Previously, some icons, most noteably the system tray icon, were missing when dark mode was enabled. T6926

Related to Kleopatra, pinentry-qt, the small program that asks for the password to unlock your OpenPGP keys also received some love:

  • pinentry-qt can now be built for Qt 6. T6883
  • pinentry-qt now supports external password managers (via libsecret), but only outside of KDE Plasma to avoid deadlocks with KWallets using GnuPG to encrypt the passwords. T6801
  • pinentry-qt now has better support for Wayland. T6887
Categories: FLOSS Project Planets

PyCharm: Deploying Django Apps in Kubernetes

Planet Python - Tue, 2024-03-05 05:55

As an open-source container orchestration platform that automates deployment, scaling, and load balancing, Kubernetes offers unparalleled resilience and flexibility in the management of your Django applications.

Whether you’re launching a small-scale project or managing a complex application, Kubernetes provides a robust environment to enhance your Django application, ensuring it’s ready to meet the demands of modern web development.

By automating the deployment, scaling, and operation of containerized applications, Kubernetes (or K8s) provides numerous benefits for organizations in the fast-paced tech industry.

Whether you’re a Django developer looking to enhance your deployment skills or a Kubernetes enthusiast eager to explore Django integration, this guide has something for everyone.

The introduction to this tutorial explores the symbiotic relationship between Django and Kubernetes, enabling you to seamlessly containerize your web application, distribute workloads across clusters, and ensure high availability.

Django

The Django framework, a high-level Python web framework, stands as a beacon of efficiency and simplicity in the world of web development. Born out of the need to create rapid, robust, and maintainable web applications, Django has become a go-to choice for developers and organizations.

At its core, Django embraces the “batteries-included” philosophy, offering an extensive array of built-in tools, libraries, and conventions that facilitate the development process. It simplifies complex tasks like URL routing, database integration, and user authentication, allowing developers to focus on building their applications.

One of Django’s foremost benefits is its adherence to the “Don’t repeat yourself” (DRY) principle, reducing redundancy and enhancing code maintainability. It also follows the model-view-controller (MVC) architectural pattern, making applications structured and easy to manage.

Django also prioritizes security, making it less prone to common web vulnerabilities. It includes features like cross-site scripting (XSS) and cross-site request forgery (CSRF) protection out of the box. Offering a potent combination of speed, simplicity, and security, Django is an ideal choice for developers looking to create robust, feature-rich web applications with minimal effort.

Container orchestrators

Container orchestrators are essential tools for managing and automating the deployment, scaling, and operation of containerized applications. There are several container orchestrators available on the market, the most popular of which include:

1. Kubernetes, the top open-source container orchestration platform, offers a robust and adaptable environment for handling containerized applications. It automates tasks such as scaling, load balancing, and container health checks, with a broad extension ecosystem.

2. Docker Swarm is a container orchestration solution provided by Docker. Designed to be simple to set up and use, it’s a good choice for smaller applications or organizations already using Docker as it uses the same command-line interface and API as Docker.

3. OpenShift is an enterprise Kubernetes platform developed by Red Hat. It adds developer and operational tools on top of Kubernetes, simplifying the deployment and management of containerized applications.

4. Nomad, developed by HashiCorp, is a lightweight and user-friendly orchestrator capable of managing containers and non-containerized applications.

5. Apache Mesos is an open-source distributed system kernel, and DC/OS (data center operating system) is an enterprise-grade platform built on Mesos. DC/OS extends Mesos with additional features for managing and scaling containerized applications.

Software teams primarily work with managed platforms offered by well-known cloud providers such as AWS, Google Cloud Platform, and Azure. These cloud providers offer services like Amazon EKS, Google GKE, and Azure AKS, all of which are managed Kubernetes solutions. These services streamline the setup, expansion, and administration of Kubernetes clusters and seamlessly integrate with the respective cloud environments, ensuring efficient container orchestration and application deployment.

Creating a Django Application in PyCharm

In this tutorial, we’ll start by generating a minimal Django application. We’ll then containerize the application and, in the final step, deploy it to a local Kubernetes cluster using Docker Desktop.

If you’re new to working with the Django framework but are eager to create a Django application from scratch, read this blog post.

You can access the source code used in this tutorial here.

Let’s begin by creating a new Django application in PyCharm.

To create your project, launch PyCharm and click New Project. If PyCharm is already running, select File | New Project from the main menu.

Furnish essential details such as project name, location, and interpreter type, utilizing either venv or a custom environment.

Then, click Create.

PyCharm will do the heavy lifting by setting up your project and creating the virtual environment.

Gunicorn

Once the project has been created, install Gunicorn – a popular Python web server gateway interface (WSGI) HTTP server. A pre-fork worker model web server used to serve Python web applications, Gunicorn is often used in combination with web frameworks like Django, Flask, and others to deploy web applications and make them accessible over the internet.

The Python Packages tool window provides the quickest and easiest way to preview and install packages for the currently selected Python interpreter.

You can open the tool window via View | Tool Windows | Python Packages.

Psycopg 2

Psycopg 2 is a Python library used to connect to and interact with PostgreSQL databases. It provides a Python interface for working with PostgreSQL, one of the most popular open-source relational database management systems. Psycopg 2 allows Python developers to perform various database operations, such as inserting, updating, and retrieving data, as well as executing SQL queries, and managing database connections from within Python programs.

Before installing psycopg2, you need to install the system-level dependencies, brew install libpq for macOS, and apt-get install libpq-dev for Linux.

Reference: postgresql.org/docs/16/libpq.html

libpq is the client library for PostgreSQL. It’s a C library that provides the necessary functionality for client applications to connect to, interact with, and manage PostgreSQL database servers. 

After completing the particular modifications, update the section within settings.py related to DATABASES.

Always make sure to pass your secret credentials through environment variables.

STATIC_ROOT

In Django, STATIC_ROOT is a configuration setting used to specify the absolute file system path where collected static files will be stored when you run the collectstatic management command. Static files typically include CSS, JavaScript, images, and other assets used by your web application. The STATIC_ROOT setting is an essential part of serving static files in a production environment.

Set an environment variable for STATIC_ROOT at line 127. This variable will point to a file path that leads to a Kubernetes persistent volume. I’ll explain later how to configure this setup.

To collect static files, run the following command:

python manage.py collectstatic

This command will gather the static files and place them in the STATIC_ROOT directory. You can then serve these assets directly through an NGINX or Apache web server – a more efficient approach for production environments.

Dockerfile

A Dockerfile is a straightforward textual document containing directives for constructing Docker images.

1. FROM python:3.11: This line specifies the base image for the Docker image using the official Python 3.11 image from Docker Hub. The application will be built and run on top of this base image, which already has Python pre-installed.

2. ENV PYTHONUNBUFFERED 1: This line sets an environment variable PYTHONUNBUFFERED to 1. It’s often recommended to set this environment variable when running Python within Docker containers to ensure that Python doesn’t buffer the output. This helps in getting real-time logs and debugging information from the application.

3. WORKDIR /app: This line sets the working directory within the Docker container to /app. All subsequent commands will be executed in this directory.

4. COPY . /app: This line copies the contents of the current directory (the directory where the Dockerfile is located) to the /app directory within the container. This includes your application code and any files needed for the Docker image.

5. RUN pip install -r requirements.txt: This line runs the pip install command to install the Python dependencies listed in a requirements.txt file located in the /app directory. This is a common practice for Python applications as it allows you to manage the application’s dependencies.

6. EXPOSE 8000: This line informs Docker that the container listens on port 8000. It doesn’t actually publish the port. It’s a metadata declaration to indicate which ports the container may use.

7. CMD ["gunicorn", "django_kubernetes_tutorial.wsgi:application", "--bind", "0.0.0.0:8000"]: This line specifies the default command to run when the container starts. It uses Gunicorn to serve the Django application and binds Gunicorn to listen on all network interfaces (0.0.0.0) on port 8000 using the WSGI application defined in django_kubernetes_tutorial.wsgi:application.

DockerHub

Visit hub.docker.com and proceed to either log in or sign up on the platform.

Click on Create repository.

Next, provide the repository name and make the visibility public. If you’re working with sensitive or confidential information, set the visibility to Private.

Once the repository has been created, you need to build the docker image and then push the image to the registry.

Before executing the command, ensure that your requirements.txt file is current by running the following command:

pip freeze > requirements.txt

To construct an image, execute the following command: 

docker build -t mukulmantosh/django-kubernetes:1.0 .

docker build -t <USERNAME>/django-kubernetes:1.0 .

This command will vary depending on your specific circumstances, and you will need to utilize your personal username.

You then need to authenticate with Docker Hub to push the image to the registry.

Type the following command in the terminal:

docker login

Enter your username and password. Once they have been successfully authenticated, you can push the image by running:

docker push mukulmantosh/django-kubernetes:1.0 

docker push <USERNAME>/django-kubernetes:1.0 

Once the image has been successfully pushed, you can observe changes in Docker Hub.

If you don’t plan to push any more images to the registry, you can log out by running the following command:

docker logout

If you want to pull this image locally, visit hub.docker.com/r/mukulmantosh/django-kubernetes.

Kubernetes Configuration: Writing YAML Files

This section of the tutorial describes the deployment of applications to local Kubernetes clusters.

For this tutorial, we will be using Docker Desktop, but you could also use minkube or kind.

Namespaces

In Kubernetes, namespaces is a virtual partition within a cluster that is used to group and isolate resources and objects. It’s a way to create multiple virtual clusters within a single physical cluster. 

You can create and manage namespaces using kubectl, the Kubernetes command-line tool, or by defining them in YAML manifests when deploying resources. 

  • If you’ve chosen Docker Desktop as your preferred platform for running Kubernetes, be sure to enable Kubernetes in the settings by clicking the Enable Kubernetes checkbox.

Run the following command in the terminal to create namespace:

kubectl create ns django-app

Deploying databases with K8s

To begin, let’s establish a PostgreSQL instance in our Kubernetes cluster on the local environment.

PersistentVolume

In Kubernetes, a persistent volume (PV) is a piece of storage in the cluster that an administrator has provisioned. By storing data in a way that is independent of a pod’s life cycle, PVs allow for a more decoupled and flexible management and abstraction of storage resources. This means data can persist even if the pod that uses it is deleted or rescheduled to a different node in the cluster.

Let’s create a persistent volume and name it pv.yml.

This YAML configuration defines a PersistentVolume resource named postgres-pv with a capacity of 1 gigabyte, mounted using the ReadWriteOnce access mode, and provided by a local path on the node’s file system located at /data/db. This PV can be used to provide persistent storage for pods that need access to a directory on the node’s file system and is suitable for applications like PostgreSQL or other stateful services that need persistent storage.

For production, we recommend either using cloud solutions like AWS RDS or Google CloudSQL, or use Kubernetes StatefulSets.

PersistentVolumeClaim

In Kubernetes, a PersistentVolumeClaim (PVC) is a resource object used by a pod to request a specific amount of storage with certain properties from a PV. PVCs act as a way for applications to claim storage resources without needing to know the details of the underlying storage infrastructure.

By creating and using PVCs, Kubernetes provides a way to dynamically allocate and manage storage resources for applications while abstracting the underlying storage infrastructure, making it easier to work with and manage stateful applications in containerized environments.

Let’s create a PVC and name it pvc.yml.

A PVC requests storage resources and is bound to a PV that provides the actual storage. 

This YAML configuration defines a PersistentVolumeClaim named postgres-pvc within the django-app namespace. It requests a gigabyte of storage with the ReadWriteOnce access mode, and it explicitly specifies the manual StorageClass. This PVC is intended to be bound to an existing PV with the name postgres-pv, effectively reserving that volume for use by pods within the django-app namespace that reference this PVC.

ConfigMap

In Kubernetes, a ConfigMap is an API object that is used to store configuration data in key-value pairs. ConfigMaps provides a way to decouple configuration data from the application code, making it easier to manage and update configurations without modifying and redeploying containers. They are especially useful for configuring applications, microservices, and other components within a Kubernetes cluster.

Let’s create a ConfigMap and name it cm.yml.

Although this tutorial uses ConfigMaps, for security considerations, it’s recommended to store sensitive credentials in Kubernetes Secrets or explore alternatives like Bitnami Sealed Secrets, AWS Parameter Store, or HashiCorp Vault.

Deployment

In Kubernetes, a Deployment is a resource object used to manage the deployment and scaling of applications. It’s part of the Kubernetes API group and provides a declarative way to define and manage the desired state of your application.

A Deployment is a higher-level Kubernetes resource used for managing and scaling application pods. 

This YAML configuration defines a Deployment named postgres in the django-app namespace. It deploys a single replica of a PostgreSQL database (version 16.0) with persistent storage. The database pod is labeled as app: postgresdb, and the storage is provided by a PVC named postgres-pvc. Configuration and credentials for the PostgreSQL container are provided via a ConfigMap named db-secret-credentials.

Service

In Kubernetes, a Service is a resource object used to expose a set of pods as a network service. Services enable network communication between different parts of your application running in a Kubernetes cluster and provide a stable endpoint for clients to access those parts. Services abstract the underlying network infrastructure, making it easier to connect and discover the components of your application.

This YAML configuration defines a NodePort Service named postgres-service within the django-app namespace. It exposes the PostgreSQL service running in pods labeled with “app: postgresdb” on port 5432 within the cluster. External clients can access the Service on any node’s IP address using port 30004. This Service provides a way to make the PostgreSQL database accessible from outside the Kubernetes cluster.

Creating YAML configurations for a Django application PersistentVolume

This YAML defines a PersistentVolume named staticfiles-pv with a 1 GB storage capacity, allowing multiple pods to read and write to it simultaneously. The storage is provided by a local host path located at /data/static. The Django static files will be stored at this location.

PersistentVolumeClaim

This YAML defines a PVC named staticfiles-pvc in the django-app namespace. It requests storage with a capacity of at least 1 GB from a PV with the “manual” StorageClass, and it specifies that it needs ReadWriteMany access. The claim explicitly binds to an existing PV named staticfiles-pv to satisfy its storage needs. This allows pods in the django-app namespace to use this PVC to access and use the storage provided by the associated PV.

ConfigMap

This YAML defines a ConfigMap named app-cm in the django-app namespace, and it contains various key-value pairs that store configuration data. This ConfigMap can be used by pods or other resources within the django-app namespace to access configuration settings, such as database connection information and static file paths.

Deployment

This YAML defines a Deployment named django-app-deploy in the django-app namespace. It creates one replica (pod) running a container with a specific Docker image and configuration. The pod is associated with two volumes, postgres-db-storage and staticfiles, which are backed by PVCs. The container is configured to use environment variables from a ConfigMap named app-cm and listens on port 8000. The volumes are mounted at specific paths within the container to provide access to database storage and static files. This Deployment is a common way to run a Django application using Kubernetes.

If you are interested in pulling images from a private registry, then read here

Service

The Service listens on port 8000 and directs incoming traffic to pods labeled with app: django-application. This is a common configuration for exposing and load-balancing web applications in a Kubernetes cluster where multiple instances of the same application are running. The Service ensures that traffic is distributed evenly among them.

NGINX

NGINX is a high-performance web and reverse proxy server known for its speed, reliability, and scalability. It efficiently handles web traffic, load balancing, and content delivery, making it a popular choice for serving websites and applications.

ConfigMap

This YAML defines a Kubernetes ConfigMap named nginx-cm in the django-app namespace, and it contains a key-value pair where the key is default.conf and the value is a multiline NGINX configuration file that proxies the request to the backend server. 

Deployment

This YAML defines a Deployment that creates and manages pods running an NGINX container with specific volumes and configurations. The Deployment ensures that one replica of this pod is always running in the django-app namespace. It also overrides the default NGINX configuration by replacing it with the nginx-cm ConfigMap.

Service

This YAML configuration creates a Kubernetes Service named nginx-service in the django-app namespace. It exposes pods with the label app:nginx on port 80 within the cluster and also makes the Service accessible on NodePort 30005 on each cluster node. This allows external traffic to reach the pods running the NGINX application via the NodePort service.

Managing batch workloads with Kubernetes jobs

In Kubernetes, a Job is a resource object that represents a single unit of work or a finite task. Jobs are designed to run tasks to completion, with a specified number of successful completions. 

Database migration

This YAML configuration defines a Kubernetes Job named django-db-migrations in the django-app namespace. The Job runs a container using a custom Docker image for Django migrations and mounts a PVC to provide storage for database-related files. If the Job fails, it can be retried up to 15 times, and it will retain its pod for 100 seconds after completion. This Job will create new tables in PostgreSQL.

Static files

This YAML configuration defines a Kubernetes Job named django-staticfiles in the django-app namespace. The Job runs a container using a custom Docker image for collecting static files for a Django application and mounts a PVC to provide storage for the static files. If the Job fails, it can be retried up to three times, and it will retain its pod for 100 seconds after completion for debugging purposes. This Job will copy the static files to the mountPath, which is /data/static.

Launching the Application

To launch the application, navigate to the k8s directory and execute the following command:

After deploying the application, use the following command to verify the status of running pods:

kubectl get pods -n django-app -w

Creating a superuser in Django

Once all your applications are up and running, create a superuser to login into the Django admin.

Run the following command to get the list of running pods:

kubectl get pods -n django-app

To get inside the container shell, run:

kubectl exec -it <POD_NAME> -n django-app -- sh

Then, run:

python manage.py createsuperuser

Once you’ve successfully created the superuser, open http://127.0.0.1:30005 in a browser. You will be directed to the default welcome page.

Then, head over to the Django admin via http://127.0.0.1:30005/admin.

Enter the username and password that you’ve just created. 

Once authenticated, you will be redirected to the Django administration page. 

If you try logging through localhost:30005/admin, you might receive a 403 Forbidden (CSRF) error.

You can resolve this in the settings.py file under CSRF_TRUSTED_ORIGINS.

CSRF_TRUSTED_ORIGINS is a setting in Django that is used to specify a list of trusted origins for cross-site request forgery (CSRF) protection. CSRF is a security vulnerability that can occur when an attacker tricks a user into unknowingly making an unwanted request to a web application. To prevent this, Django includes built-in CSRF protection.

CSRF_TRUSTED_ORIGINS allows you to define a list of origins (websites) from which CSRF-protected requests are accepted. Any request originating from an origin not included in this list will be considered potentially malicious and duly blocked.

This setting can be used to allow certain cross-origin requests to your Django application while maintaining security against CSRF attacks. It’s particularly helpful in scenarios where your application needs to interact with other web services or APIs that are hosted on different domains.

If you are using GUI tools like Kubernetes Dashboard, you can easily visualize your running pods, deployments, persistent volumes, etc.

Kubernetes Support in PyCharm 

PyCharm offers an enhanced editor and runtime support tailored for Kubernetes, bringing a host of features to streamline your Kubernetes management, including:

  • Browsing cluster objects, extracting and editing their configurations, and describing them.
  • Viewing events.
  • Viewing and downloading pod logs.
  • Attaching the pod console.
  • Running shell in pods.
  • Forwarding ports to a pod.
  • Applying resource YAML configurations from the editor.
  • Deleting resources from the cluster.
  • Completion of ConfigMap and Secret entries from the cluster.
  • Configuring paths to kubectl.
  • Configuring custom kubeconfig files globally and per project.
  • Switching contexts and namespaces.
  • Using API schema (including CRD) from the active cluster to edit resource manifests.

Watch this video to learn more about working with Kubernetes in PyCharm Professional.

Try PyCharm for your Kubernetes tasks for free!

DOWNLOAD PYCHARM References

Already have a solid understanding of Kubernetes? Then, take the next step in your programming journey by exploring cloud solutions, and check out our tutorials on AWS EKS and Google Kubernetes Engine.

Categories: FLOSS Project Planets

Python Bytes: #373 Changing Directories

Planet Python - Tue, 2024-03-05 03:00
<strong>Topics covered in this episode:</strong><br> <ul> <li><a href="https://github.com/ajeetdsouza/zoxide"><strong>zoxide</strong></a></li> <li><a href="https://rahulpai.co.uk/smart-clis-with-typer.html"><strong>Smart CLIs with Typer</strong></a></li> <li><a href="https://twitter.com/samuel_colvin/status/1763339372361814187?s=12&t=RL7Nk7OAFSptvENxe1zIqA"><strong>Python recommended officially by the US Government</strong></a></li> <li><a href="https://www.blog.pythonlibrary.org/tag/tui/"><strong>Textual tutorials at Mouse vs Python</strong></a></li> <li><strong>Extras</strong></li> <li><strong>Joke</strong></li> </ul><a href='https://www.youtube.com/watch?v=AbCuv0wuzP0' style='font-weight: bold;'data-umami-event="Livestream-Past" data-umami-event-episode="373">Watch on YouTube</a><br> <p><strong>About the show</strong></p> <p>Sponsored by ScoutAPM: <a href="https://pythonbytes.fm/scout"><strong>pythonbytes.fm/scout</strong></a></p> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@mkennedy@fosstodon.org</strong></a></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@brianokken@fosstodon.org</strong></a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes"><strong>@pythonbytes@fosstodon.org</strong></a></li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/live</strong></a> to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.</p> <p><strong>Michael #1:</strong> <a href="https://github.com/ajeetdsouza/zoxide"><strong>zoxide</strong></a></p> <ul> <li>zoxide is a smarter cd command, inspired by z and autojump.</li> <li>It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.</li> <li>zoxide works on all major shells and platforms.</li> </ul> <p><strong>Brian #2:</strong> <a href="https://rahulpai.co.uk/smart-clis-with-typer.html"><strong>Smart CLIs with Typer</strong></a></p> <ul> <li>Rahul Pai</li> <li>Lots of TILs here, even though I’ve been using Typer for years.</li> <li>Examples of <ul> <li>Auto-detection of arguments and types based on type hints</li> <li>Help text is a smidge clunkier</li> <li>Prompting for missing arguments </li> <li>Defaulting to an enviromental variable for missing args</li> <li>Print help if no args given</li> <li>Explicit app and subcommands with a comparison to argparse</li> <li>Reusable commands with result_callback </li> </ul></li> <li>Several topics covered in comparison with argparse</li> <li>See also <a href="https://pythontest.com/testing-argparse-apps/">Testing argparse Applications</a></li> </ul> <p><strong>Michael #3:</strong> <a href="https://twitter.com/samuel_colvin/status/1763339372361814187?s=12&t=RL7Nk7OAFSptvENxe1zIqA"><strong>Python recommended officially by the US Government</strong></a></p> <ul> <li>The US government explicitly recommends memory safe languages.</li> <li>Python is one of them</li> <li>The comparison to big tech by Samuel is interesting</li> </ul> <p><strong>Brian #4:</strong> <a href="https://www.blog.pythonlibrary.org/tag/tui/"><strong>Textual tutorials at Mouse vs Python</strong></a></p> <ul> <li>Mike Driscoll</li> <li>Most recently <a href="https://www.blog.pythonlibrary.org/2024/02/06/creating-a-modal-dialog-for-your-tuis-in-textual/">Creating a Modal Dialog For Your TUIs in Textual</a></li> <li>Textualize already has some pretty great documentation at <a href="https://textual.textualize.io">textual.textualize.io</a></li> <li>But it’s cool to see some different tutorials on it.</li> </ul> <p><strong>Extras</strong> </p> <p>Brian: </p> <ul> <li><a href="https://www.youtube.com/watch?v=_FdjW47Au30">Is UV the FUTURE of Python PACKAGING? 🐍📦</a> - Hynek <ul> <li>Nice context on how uv fits into all of the existing packaging challenges and some hope for the future.</li> </ul></li> <li>venmo feed is public by default</li> </ul> <p>Michael:</p> <ul> <li><a href="https://ngrok.com/blog-post/ngrok-python">ngrok Python SDK</a></li> <li><a href="https://talkpython.fm/episodes/show/451/djangonauts-ready-for-blast-off">Djangonauts on Talk Python</a></li> <li>Maybe <a href="https://python-bytes-static.nyc3.digitaloceanspaces.com/yellow-phone.jpg">just a new case</a> and <a href="https://support.apple.com/iphone/repair/battery-replacement">battery</a> for your phone?</li> </ul> <p><strong>Joke:</strong> <a href="https://workchronicles.com/narrator-they-did-not-in-fact-delegate-maintenance/">Ship it</a>!</p>
Categories: FLOSS Project Planets

The Drop Times: Drupal.org: A New Initiative for Improved User Onboarding and Role Identification

Planet Drupal - Tue, 2024-03-05 02:14
Delve into Alex Moreno's initiative to revolutionize Drupal.org by capturing user roles to tailor the onboarding experience. This in-depth look discusses community collaboration, sustainability, and innovation, aiming to enhance contributions and user engagement within the Drupal ecosystem. Join the discussion on future strategies for a sustainable Drupal and the community's role in driving change.
Categories: FLOSS Project Planets

Capellic: Add a facade image for YouTube videos to improve performance

Planet Drupal - Tue, 2024-03-05 00:00
In this demonstration we look at what happens when we embed a YouTube video on a web page and then how to fix the performance problems that it brings. You'll be surprised by how much embedded YouTube videos hurt performance and how easy it is to solve it.
Categories: FLOSS Project Planets

Icon Updates for March, 2024

Planet KDE - Mon, 2024-03-04 20:43

Hey all,

I have been away for a minute but wanted to give you an update on the work so far in updating and adapting Breeze icons to the 24px grid. Check out the video below.

Categories: FLOSS Project Planets

KDE Plasma 6.0.1, Bugfix Release for March

Planet KDE - Mon, 2024-03-04 19:00

Tuesday, 5 March 2024. Today KDE releases a bugfix update to KDE Plasma 6, versioned 6.0.1.

This release adds a week's worth of new translations and fixes from KDE's contributors. The bugfixes are typically small but important and include:

View full changelog
Categories: FLOSS Project Planets

KDE Plasma 6.0.1, Bugfix Release for March

Planet KDE - Mon, 2024-03-04 19:00

Tuesday, 5 March 2024. Today KDE releases a bugfix update to KDE Plasma 6, versioned 6.0.1.

This release adds a week's worth of new translations and fixes from KDE's contributors. The bugfixes are typically small but important and include:

View full changelog
Categories: FLOSS Project Planets

Liip: Easier content creation means better content: Meet blökkli

Planet Drupal - Mon, 2024-03-04 18:00

To give users a true power tool in their daily work, the most important thing is, that editors must be able to see at all times, what their content will look like in real life. At the same time, the interface must be intuitive and easy to understand.

blökkli offers exactly that. The content looks exactly as it will ultimately appear on the website. With a click on the respective sections, they can be edited and improved immediately.

Liip developed the blökkli editor for the relaunch of bs.ch, the website of the Canton of Basel-Stadt, and published it as an open-source project.

Live editing of the site

In the blökkli editor, editors can place the page sections directly on the page using drag & drop and insert the content. You can immediately see what the content looks like.
To change a title, simply click on it and change the text.

In addition, the editor offers many functions that support the content creation and editing process. Images can be inserted directly from the computer, a mobile preview can be displayed or accessed directly via a QR code on the smartphone.
In addition, a search function can be used to link directly to other pages or insert images and documents.

There is also a function for viewing a live preview on the smartphone. This can be opened via a QR code and dynamically displays the current status of the page.

Flexible and clear design options

The appearance of the page sections can be changed directly in the page. This makes it easy for editors to design versatile pages and see directly how they look. The display follows the defined design, but at the same time offers editors the flexibility to design their content in a visually appealing way.

In many page builders or editors currently available on the market, users have too many options. They can change colors and font sizes, which unfortunately often leads to content becoming confusing or even illegible. blökkli solves this problem with pre-defined design options that are easy to find. This gives editors flexibility, but the content is still consistent and fits the brand.

blökkli also supports drag & drop of images. Images can therefore simply be dragged into the page and are placed directly in the content. In addition, links (for example to YouTube) can be inserted directly. blökkli recognizes these and embeds the corresponding content directly into the page.

Efficient team processes and easy onboarding of new users

With its comment function, the blökkli editor offers an optimal basis when content is edited by multiple people. blökkli also offers a visual timeline that allows the last changes to be undone.

For websites with many editors, it is always a challenge to introduce new people to a system. At blökkli, the most important functions are explained interactively with a 'tour'. This helps editors to quickly find their way around and reduce their anxiety.
Numerous keyboard shortcuts are available for editors who frequently edit content on the site. This makes work even faster and more intuitive.

Compatible with Drupal and any other CMS

blökkli already works excellently with the open-source CMS Drupal. The Paragraphs blökkli module is available for Drupal. Based on Nuxt.js, however, blökkli can be used with any CMS system if an appropriate adapter is available.

Try it yourself!

You can try blökkli yourself on the website:
https://blokk.li/

Categories: FLOSS Project Planets

Pages