๐ณ Setting Up a Local Kubernetes Cluster with K3s and Traefik Proxy ๐

Experienced, creative, and motivated software engineer with a solid background in full stack software development and 18+ years of experience, acculturated in devsecops.
Search for a command to run...

Experienced, creative, and motivated software engineer with a solid background in full stack software development and 18+ years of experience, acculturated in devsecops.
No comments yet. Be the first to comment.
XSS injection is a serious security issue that can leave web applications vulnerable to attacks. While there are various methods to detect XSS vulnerabilities, one unconventional approach involves the use of a simple JavaScript code snippet. To perfo...

You may have entered a 6-digit code from a 2FA app like Google Authenticator ๐ฌ, but where did this code come from? The answer lies within the QR code and the inner workings of the Time-based One-time Password algorithm (TOTP) ๐. In this article, we...

In today's world, digital security is more important than ever. With more and more of our personal and financial information stored online, protecting that information has become a top priority. Two-Factor Authentication (2FA) is an essential tool fo...

Are you planning to migrate your MongoDB replica set between Kubernetes clusters with zero downtime? This can be a challenging task, but with the right approach and tools, it's possible to achieve a seamless migration. ๐ก Here are some tips to help y...

Kubernetes has become the standard for managing containerized applications, but setting up a development environment can be complex. However, with K3s and Traefik Proxy, it's possible to create a local Kubernetes cluster quickly and easily.
๐งโ๐ป Setting Up K3s Cluster
To begin, download and install K3s. K3s is a lightweight Kubernetes distribution that's easy to install and configure. After installing, start the K3s server:
sudo k3s server
๐ Setting Up Traefik Proxy
Traefik is a popular reverse proxy and load balancer that integrates with Kubernetes. It's used to route traffic to the correct service or pod. To install Traefik, use the following command:
sudo kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v2.3/examples/k8s/traefik-deployment.yaml
๐ง Configuring Traefik Proxy
Next, configure Traefik by applying the necessary settings. Traefik can be configured using Kubernetes annotations. For example, to configure SSL, use the following annotation:
traefik.ingress.kubernetes.io/router.tls=true
๐ Securing Services with Traefik Proxy
Traefik can also be used to secure services with HTTPS. To do this, create a Kubernetes secret with your SSL certificate and key:
css
kubectl create secret tls my-secret --key tls.key --cert tls.crt
Then, apply the secret to your service:
apiVersion: v1
kind: Service
metadata:
name: my-service
annotations:
traefik.ingress.kubernetes.io/router.tls=true
traefik.ingress.kubernetes.io/router.tls.certresolver=my-resolver
spec:
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 80
selector:
app: my-app
๐ Congratulations!
You've now set up a local Kubernetes cluster with K3s and Traefik Proxy. This setup is ideal for testing and development, and can easily be scaled up for production use.