blog.gadfly.ai

Reader

Read the latest posts from blog.gadfly.ai.

from Vaishali Rawat

Introduction

Kubernetes, often abbreviated as K8s, is an open-source platform for automating the deployment, scaling, and management of containerized applications. Originally developed by Google and now maintained by the Cloud Native Computing Foundation (CNCF), Kubernetes has become the industry standard for managing applications in cloud environments.

If you're new to Kubernetes, don’t worry! This guide will break it down in a simple way so that even beginners can understand what it is, why it's important, and how to get started.

Why Do We Need Kubernetes?

Before Kubernetes, managing applications across multiple servers was a complicated task. Organizations used to run applications on physical servers or virtual machines, leading to inefficiencies such as:

  • Over-provisioning (allocating more resources than necessary to handle peak loads)

  • Under-utilization (wasting resources when demand is low)

  • Scaling challenges (difficulty in managing application traffic efficiently)

Kubernetes solves these problems by providing an intelligent orchestration system that efficiently manages workloads, ensuring applications run reliably across different environments.

Key Features of Kubernetes

1. Container Orchestration

Kubernetes automates the deployment and scaling of containers, ensuring applications run efficiently without manual intervention.

2. Automatic Scaling

It automatically increases or decreases application instances based on demand, optimizing resource usage.

3. Self-Healing

If a container crashes, Kubernetes automatically restarts or replaces it to maintain application availability.

4. Service Discovery & Load Balancing

Kubernetes efficiently distributes network traffic between application instances to ensure smooth performance.

5. Rolling Updates & Rollbacks

Kubernetes enables seamless application updates without downtime and allows reverting to previous versions if needed.

Core Components of Kubernetes

To understand how Kubernetes works, let's break down its key components:

  1. Cluster

A Kubernetes cluster consists of multiple machines (nodes) that work together to run applications.

  1. Nodes
  • Master Node: Controls the cluster and manages workload scheduling.

  • Worker Nodes: Run the application workloads.

  1. Pods

The smallest deployable unit in Kubernetes. A pod contains one or more containers that share resources.

  1. Deployments

Manage application rollouts, ensuring reliable and automated updates.

  1. Services

Provide a stable networking endpoint, allowing different parts of an application to communicate with each other.

  1. ConfigMaps & Secrets

Help manage configuration data and sensitive information securely.

Getting Started with Kubernetes

Step 1: Install Kubernetes Locally

For local development, you can use tools like:

  • Minikube: A lightweight Kubernetes cluster for local testing.

  • Kind: Runs Kubernetes clusters inside Docker containers.

Step 2: Deploy Your First Application

Run a simple Nginx web server using Kubernetes with these steps:

  1. Create a deployment:
kubectl create deployment nginx --image=nginx
  1. Expose the deployment as a service:
kubectl expose deployment nginx --type=LoadBalancer --port=80

3.Get the service details:

kubectl get services

Access your application using the provided URL.

Step 3: Learn Kubernetes Concepts in Depth

To deepen your understanding, check out online courses, YouTube playlists, and hands-on labs. The Kubernetes tutorial playlist is a great place to start.

Conclusion

Kubernetes is a powerful tool that simplifies container management, making it easier to deploy and scale applications efficiently. Whether you’re a beginner or an experienced developer, learning Kubernetes will open doors to cloud-native development and DevOps practices.

Start small, practice regularly, and soon you'll be managing Kubernetes like a pro!

 
Read more...

from sen

I just set up some fun nonsense today to handle images, so please enjoy this fun public domain picture of a waterfall:

public domain picture of Chōshi_Falls

Ok, so what is going on here?

The blog engine we use here is called writefreely, it's federated and generates the blogposts themselves from a markdown texteditor in the browser. images can be added via link syntax, so literally:

![public domain picture of Chōshi_Falls](https://cdn.gadfly.ai/Chōshi_Falls.jpg)

Now we uh, just have to host the pictures somehow.

enter the CDN

The folks behind writefreely maintain a hosted version called write.as and if you are a Write.as Pro member you can use their snap.as service which is, you guessed it, a hosted version of their picture hosting project called snapfreely, so we just head on over to the repo and...

A screenshot of the snapfreely repository on github, its EMPTY.

oh.

Well the good news is that we already have a perfectly good webserver (several actually, most of the backdoor backend services used by The Gadfly Horde™ here at HQ use nginx as a reverse proxy, the others ARE just nginx) that we use to serve our main site gadfly.ai.

Now we just need to put the files there somehow.

TBQH I am a big fan of scp but I also live in the terminal, guzzle litres of pourover and read man pages voluntarily(ok that last one was a lie, but you get my point)

but I don't always have a console at hand, or it's not always convenient and neither is giving everyone shell access to a machine so it wold actually be nice if I could upload files the same way I am writing this blogpost, with several million lines of C++ a web browser.

The Rabbithole

this actually was one of the shallower ones I went down but still I learned a few things.

I had 3-ish main goals, I wanted to:

  1. upload files thru the browser (duh)
  2. use nginx
  3. have authentication (for upload)

More specifically I wanted the files in a bare dir so I could write an nginx config pointing to it as the document root, easy peasy.

This proved difficult.

lots of photohosty and other cdn things do cool image re-encoding stuff, but they also store things in databases and I already have enoughofthosethankyouverymuch.

awesome-selfhosted was a good resource to look thru all this stuff, and after I sort of learned that what i wanted was a web file manager I took to the high seas.⛵

and returned to port immediately.

I found DAMS or “Digital Asset Management Software” which reeks of Enterprise™ so I avoided it, and most of the big FTP clients were desktop based, so bit of a no-go.

back to the awesome-selfhosted list again there were some cool small things but they either used their own server, database or both.

The outliers though,

sigh

were written in PHP.

here we go

I actually pivoted at the last minute (hour, day, whatever).

originally i was going to use IFM but I finally chickened out because the authentication infra was uh... barebones.

I then somehow stumbled across filebrowser(inspired name, I know), and actually manged to wrestle an nginx config into shape for it.

Wound up having to install a bunch more packages (go figure) and then mess with permissions and ownership around unix sockets and php_fpm (did you know nginx runs as nginx:nginx on debian things now? what a time to be alive...) but I got it up and running behind a subdomain.

We still have a problem tho.

The cdn (no really)

For my own sake (and others) I wanted to make it really easy to find and copy a link to the bare image file for use in the blog, and uh now maybe I'm just not up on my nginx-fu when it comes to url rewriting (ok face it, I'm not) and also not willing to deeply mess with the internals of the file browsers routes so their arent any collisons, but this means I probably can't (easily) host the filemanager interface on the same subdomain as the files themselves.

This means I need 2 subdomains (which is fine) and to somehow have the file browser UI give me a link to that same file, but from the other subdomain. That should be straightforward at least.

Well, the jokes on me bc i downloaded the release tarball of “file manager” and so I was met with a blob of post-masticated JS, this caused me to retreat into the sources where I learned...

that “file browser” was just a fork of FileGator

sigh

I had talked myself into using “file browser” even though it hadn't been updated in 2 years bc it had the best auth infrastructure of anything I could find. and here's filegator that just got a new release last week

queue the fury of me ripping up /var/www/filebrowser and installing /var/www/filegator, the good news is that all the work I put into the nginx configs was still valid, I just had to do a find-replace. it of course didn't start up and I had once again installed a release tarball. Then I did some more stuff that didn't work until I pulled down the main git branch and followed the install instructions, then it worked. Hooray!!!

Ok now uh where was I...

Oh yeah, cdn link.

Now I have the source so I can dig through and look for pieces of user interface to modify.

HERE!

<b-dropdown-item v-if="props.row.type == 'file' && can('download')" v-clipboard:copy="getDownloadLink(props.row.path)" aria-role="listitem"> <b-icon icon="clipboard" size="is-small" /> {{ lang('Copy link') }}

its the bit of code responsible for the “copy link” button from the per file dropdown menu on the filegator ux.

The "Copy Link" button from the per file dropdown menu on the filegator ux

queue some trepidation about plumbing the depths of vue.js docs and second-guessing myself about JS syntax, oh and several npm run build errors before I got something workable.

<b-dropdown-item v-if="props.row.type == 'file' && can('download')" v-clipboard:copy="'https://cdn.gadfly.ai/' + props.row.name" aria-role="listitem"> <b-icon icon="clipboard" size="is-small" /> {{ lang('Copy cdn link') }}

taa-daa!

Now I have another button in the drop down, that says “Copy cdn Link” which uh, does that. There are certainly more elegant, more configurable ways of doing this that I would implement if i wanted to get this code upstreamed, but it works for now. Also, you still have to write the markdown around the link when using it on the blog. Who knows maybe I will add a “Copy markdown Link” button in the future.

until next time... EOL.

 
Read more...

from sen

lots of fun and exciting things have been happening over here at gadfly ai HQ, we have added a bunch of services, both public and private facing.

 
Read more...