teleren/devto huggingface dataset:
Navigating Services in Kubernetes
Tags: kubernetes, services, ckad, networking
Published: 2024-02-01 13:55:06

In Kubernetes, services play a crucial role in enabling communication between different components within the cluster or exposing applications to external users. Let's explore key commands and concepts related to managing services.

Key Operations
Create a Service
Apply a service definition from a YAML file:


```
kubectl apply -f <svc.yaml>

```
View Services
List all services in the current namespace:


```
kubectl get svc
```
Describe a Service
Get detailed information about a specific service, including ports and selectors:


```
kubectl describe svc <service-name>

```
Delete a Service
To delete a specific service:


```
kubectl delete svc <service-name>

```
Expose a Pod with a Service
Expose a pod by creating a ClusterIP service:


```
kubectl expose pod redis --port=6379 --name=redis-service --type=ClusterIP --dry-run=client -o yaml > svc.yaml

```
Or expose a deployment with a NodePort service:


```
kubectl expose deploy <deploy-name> --port=<service-port>

```
Edit a Service
Edit the configuration of a service:

```
kubectl edit svc <service-name>

```
Get Endpoints for a Service
View the endpoints associated with a service:

```
kubectl get ep <svc-name>

```
Additional Insights
Service Types:

`NodePort`: Exposes the service on each node's IP at a static port. Accessible externally.
`ClusterIP`: Exposes the service inside the cluster using a cluster-internal IP.
`LoadBalancer`: Creates an external IP and routes traffic to the service.

Ports in Services:
`NodePort`: Port on the node.
`Port`: Port on the service (exposed internally).
`TargetPort`: Port on the pod (container).

Service Selector:
Services, deployments, replica sets, and network policies use the selector property under spec to select pods using labels.

Accessing Services:
Pods can access services using the ClusterIP or service name.
Ensure proper configuration of services based on your use case, whether for internal communication or external access.

Happy Networking in Kubernetes!
Navigating Horizontal Pod Autoscaler (HPA) in Kubernetes
Tags: kubernetes, hpa, autoscaler, pods
Published: 2024-02-01 13:43:21

The Horizontal Pod Autoscaler (HPA) in Kubernetes allows for automatic scaling of the number of pods in a deployment or replica set based on observed CPU utilization or other custom metrics. Let's explore essential commands for managing HPAs in your Kubernetes cluster.

## Key Operations
View HPAs

To list all Horizontal Pod Autoscalers in the current namespace:


```
kubectl get hpa
```
Delete an HPA
To delete a specific Horizontal Pod Autoscaler:


```
kubectl delete hpa <hpa-name>
```
Create an HPA
Create an HPA for a deployment named "nginx" with minimum 5 and maximum 10 replicas, targeting 80% CPU utilization:

```
kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80
```
This command sets up an HPA for the "nginx" deployment to automatically adjust the number of replicas based on CPU utilization, keeping it between 5 and 10 replicas and targeting 80% CPU usage.

Additional Insights
`Desired Metrics`: The HPA monitors the metrics defined (CPU utilization in this example) and adjusts the number of replicas to meet the specified targets.

`Dynamic Scaling`: HPA enables dynamic scaling based on real-time resource demand, ensuring optimal resource utilization.

`Pod Metrics`: HPAs can also be configured to scale based on custom metrics, such as memory usage, or external metrics like requests per second.

`Scaling Behavior`: The scaling behavior is defined by the --cpu-percent parameter, determining when to scale in or out based on the specified CPU utilization threshold.

Ensure that the configuration and metrics defined in your HPA align with the requirements and behavior of your application to achieve efficient and automated scaling.

Happy Autoscaling!
Decoding Notice of Intimation (NoI) and Unveiling Home Loan Charges
Published: 2024-02-01 13:27:03

Among the essential documents required, such as identity proofs like PAN and Aadhaar, and income statements, there’s one critical piece of documentation that often goes overlooked but plays a vital role in [safeguarding the Current home loan interest](https://apkgossip.com/notice-of-intimationand-unveiling-home-loan-charges/) of all parties involved – the Notice of Intimation (NoI).
Affordable Housing Schemes in India
Published: 2024-02-01 13:25:50

From Vision to Reality: The Affordable Housing Schemes in India

Affordable housing has been a longstanding vision for India, where millions aspire to own their own homes. To transform this vision into reality, the Indian government has implemented [various affordable housing schemes](https://technotrolls.com/affordable-housing-schemes-in-india/). 

These initiatives aim to provide low and middle-income families with access to quality housing while promoting economic growth. This article will explore the key aspects of affordable housing schemes in India and their impact on individuals and communities.
Day 22 of My Learning Journey: Setting Sail into Data Excellence! Today's Focus: Mathematics for Data Analysis (Stats Day 1)
Tags: statistics, datasciecne, analyst, dataengineering
Published: 2024-02-01 13:16:41

STATISTICS FOR DATA ANALYTICS - 1



Material which I have taken to learn ➖
Vlearn ( Statistics) implementation in Excel .
Krish Naik ( live playlist - statistics) implementation in Python.
Paid course ( Intelliphat - Advanced in Business Analytics) implementation in Python.
Paid course ( Data Science - pw skills) implementation in Python.

Books ➖
An Introduction to Statistical Learning: With Python

Whatever I will learn in this course will be shared as per my experience.

A branch of applied mathematics that involves the collection, organising,description, presentation, analysis and interpretation of numerical data.


TYPE OF STATISTICS ➖

DESCRIPTIVE STATISTICS 

INFERENTIAL STATISTICS 


Descriptive statistics :- It describes the property of the dataset.

Inferential statistics :- To get results from the dataset ( it uses a dataset to get the result.)


TYPE OF DATA ➖

QUANTITATIVE  DATA
QUALITATIVE DATA


LEVEL OF MEASUREMENT ( scale of measurement )

Nominal scale data.
Ordinal scale data.
Interval scale data.
Ratio scale data.
	





DESCRIPTIVE STATISTICS 

BASIC :- 
SUMMARISING 
ORGANISING.


Based on Variable ➖

Univariate -       Everything about that variable
One variable 
Ex :- mean, median , mode.



BiVariate -
Two variable 
Ex :- Scatter plot 
MultiVariate -
More than One variable 
Ex:- Heat map


Types of Descriptive Statistics :- 

Measure of Frequency 
	Grouped Frequency
	Ungrouped Frequency

Measure of Central Tendency
	Mean, Median, Mode


Measure of Dispersion or Variation
Variance
Range, 
Standard & Absolute Deviation
Coefficients of Variation	

Measure of Position
	Percentile & Quartile

Measure of Shape 
	Skewness
	Kurtosis
	Box & Whisker Plot



Common terms :- 

Population :- complete dataset is called population.

Sample :- it is a dataset which has resemblance of the population in a small proportion which can be used for Analytics.



These functions are fundamental for various tasks in Excel, including text manipulation, logical operations, conditional formatting, and data analysis.

Follow me on this where every day will be added if i learn something new about it  :- https://dev.to/nitinbhatt46



Thank you for your time.
Migrate MySQL Database to Any Target: How to Do It Quick and Easy
Tags: mysql, mariadb, database
Published: 2024-02-01 13:15:20

How unnerving is it to migrate a MySQL database to another location?

If you did it before, how does it feel after the migration? Is it like you were dropped in a war-torn place? Explosions here and there? Guns blazing? With all the screaming, trauma, and losses, you may not want to do this again.

If it’s like a place you don’t want to come back ever again, hope is not gone. You probably need to iron out a few more stuff before you migrate a MySQL database again.

There’s an easy way, a road not taken. You may have made a wrong turn. This time, it won’t be horror and dread. It will be calm and cheerful. This article will make you wear the hero cape again.

We’ll do this in baby steps, but I promise it will be a walk in the park in the end.

We will start with an overview and the things you need to know first. Then, we’ll proceed to the easy steps.

- MySQL Database Migration Overview: To Migrate is Like a Digital Circus Act
- How Would You Know It’s Time to Migrate Your MySQL Database?
- Do’s and Don’ts in MySQL Database Migration
- MySQL GUI Migration Tool: The Key to Quick and Easy Way to 
Migrate MySQL Database
- How to Backup a MySQL Database GUI Style
- How to Restore a MySQL Database to the Target via GUI

Read in full to get more info: https://www.cpomagazine.com/digital/migrate-mysql-database-to-any-target-how-to-do-it-quick-and-easy/
Unlock Your Brand's Potential with Kriosk Creata: Masterful Logo Design Services & Creative Branding Solutions
Tags: branding, design, logodesign, agency
Published: 2024-02-01 13:12:47

At Kriosk Creata, we redefine your brand identity with precision and creativity. Our Logo Design Services craft iconic symbols that speak volumes, while our Creative [**Branding Design Agency**](https://www.krioskcreata.com/service/branding/) goes beyond aesthetics, telling compelling stories through captivating visuals. Elevate your brand experience with Kriosk Creata – where every design is a masterpiece, and every brand narrative is strategically crafted for lasting impact. Choose us for a transformative journey in branding excellence.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/375b9exp2881s96xjeg1.png)
Automated Backups Made Easy: & Lessons Learned From This Project
Tags: bash, ssh, cronjobs, automation
Published: 2024-02-01 13:09:16

**Table of Contents:**
1. [Introduction](#introduction)
2. [Project Overview](#project-overview)
3. [Discoveries and Resolutions](#discoveries-and-resolutions)
   - [Use Full Paths in Crontabs](#use-full-paths-in-crontabs)
   - [Specify Full Paths for Rsync and SSH Key](#specify-full-paths-for-rsync-and-ssh-key)
4. [Conclusion](#conclusion)

## Introduction:
In the ever-evolving world of technology, ensuring the safety of our data is paramount. Recently, I completed a project that automates backup tasks, aiming to simplify the process and enhance data security. While the project proved successful, I encountered a stumbling block that led me on a troubleshooting journey. In this blog post, I'll share the project overview and the valuable lessons learned from resolving a crucial issue.

## Project Overview:
The project (GitHub link: [Auto-Backup Project](https://github.com/stanleyogada/auto-backup-project)) automates the addition of backup tasks to the crontab for daily, weekly, and monthly backups. All compressions (.tar.gz) are stored in a designated backup directory, and SSH key authentication is required for remote hosts. The script intelligently manages backup files, retaining only the most recent ones to optimize storage usage.

## Discoveries and Resolutions:
While developing the project, a significant challenge surfaced when incorporating the rsync command into the script for scheduled execution via crontab. Here are the two major discoveries that solved the issue:

### Use Full Paths in Crontabs:
   - Crontab entries should include the full path to scripts. Correct example:
     ```vim
     * * * * * /usr/local/bin/backup.sh
     ```

### Specify Full Paths for Rsync and SSH Key
   - In the script, provide the full path to the rsync program and explicitly specify the SSH key for the remote system.
     ```bash
     /usr/bin/rsync -a -e "ssh -i /home/user/.ssh/vps-1-private-key" /home/user/backups user@vps-1.com
     ```
   - To troubleshoot, add verbose logging with the `-vv` option to the rsync in the script and redirect the crontab output to a file for monitoring.
     ```vim
     * * * * * /usr/local/bin/backup.sh >> /home/user/.backup.cron.log 

     ```

## Conclusion:
Developing the Auto-Backup Project was a rewarding experience, and overcoming the challenge highlighted the importance of attention to detail. By sharing these discoveries, I hope to assist fellow developers facing similar issues. Remember, the devil is in the details, and providing full paths can make all the difference in the world of scheduled tasks. Explore the [GitHub repository](https://github.com/stanleyogada/auto-backup-project) for more details and project documentation.

Check out a related problem posted on [StackOverFlow](https://stackoverflow.com/a/77915389/14889311)

Also, connect with me on [LinkedIn](https://www.linkedin.com/in/stanley-ogada/)

Happy hacking!
Was ist Software-Testing?
Published: 2024-02-01 08:47:46


**Software-Testing** ist eine Methode zur Überprüfung, ob das tatsächliche Softwareprodukt den erwarteten Anforderungen entspricht und um sicherzustellen, dass das Softwareprodukt fehlerfrei ist. Dabei werden Software-/Systemkomponenten mithilfe manueller oder automatisierter Tools ausgeführt, um eine oder mehrere interessierende Eigenschaften zu bewerten. Das Ziel des Software-Testings ist es, Fehler, Lücken oder fehlende Anforderungen im Gegensatz zu den tatsächlichen Anforderungen zu identifizieren.

**Die Wichtigkeit des Software-Testings liegt** darin, dass bei vorhandenen Fehlern oder Bugs in der Software diese frühzeitig erkannt und vor der Auslieferung des Softwareprodukts behoben werden können. Ein ordnungsgemäß getestetes Softwareprodukt gewährleistet Zuverlässigkeit, Sicherheit und hohe Leistung, was zu Zeitersparnis, Kosteneffizienz und Kundenzufriedenheit führt.

**Software-Bugs** können teuer oder sogar gefährlich sein, weshalb Testing wichtig ist. Beispiele für Auswirkungen von Softwarefehlern reichen von einem Absturz des Bloomberg-Terminals in London bis zur Rückrufaktion von Nissan-Autos aufgrund eines Softwareversagens in den Airbag-Sensoren. Kostenersparnis, Sicherheit, Produktqualität und Kundenzufriedenheit sind einige der Vorteile von Software-Testing. Es gibt verschiedene Arten von Tests, darunter funktionales Testing, nicht-funktionales Testing (Leistungs- und Wartungstests) sowie verschiedene Teststrategien wie Einheitstests, Integrationstests und Systemtests. Insgesamt ist Software-Testing ein entscheidender Schritt im Softwareentwicklungsprozess.

Quelle: [What is Software Testing?](https://www.guru99.com/software-testing-introduction-importance.html)
Navigating Replicaset Operations in Kubernetes
Tags: kubernetes, kubectl, replicaset, scalable
Published: 2024-02-01 13:06:15

Managing scalable and resilient applications in Kubernetes often involves working with ReplicaSets. In this guide, we'll explore essential commands and operations related to ReplicaSets to empower your Kubernetes journey.

## Key Operations
Create a ReplicaSet
Apply a ReplicaSet definition file to create a new ReplicaSet:

```
kubectl apply -f <replicaset-definition.yaml>
```
View ReplicaSets
To see a list of ReplicaSets in the current namespace:


```
kubectl get rs
```
For a more detailed view, including additional information like pod distribution:


```
kubectl get rs -o wide
```
Delete a ReplicaSet
To delete a specific ReplicaSet:


```
kubectl delete rs <replicaset-name>
```
Scale a ReplicaSet
Scale a ReplicaSet to a desired number of replicas:

```
kubectl scale rs <replicaset-name> --replicas=6
```
Edit a ReplicaSet

There are two ways to edit a ReplicaSet. Either delete and re-create the ReplicaSet, or update the existing ReplicaSet and then delete all pods:

```

kubectl edit rs <replicaset-name>
kubectl delete po <replicaset-pod-name>
```
Alternatively:


```
kubectl get rs <replicaset-name> -o yaml > rs.yaml
vi rs.yaml
kubectl apply -f rs.yaml
kubectl delete po <replicaset-pod-name>
```
ReplicaSet Labels

Ensure that the values for labels in spec.selector and spec.template.metadata match in the ReplicaSet.

Viewing All Objects
To see all objects at once in the current namespace:

```
kubectl get all

```
ReplicaSet Template

> Remember that a ReplicaSet has a template, specifying the pod template for creating new pods.

These commands and considerations are essential for effectively managing ReplicaSets in Kubernetes. Incorporate them into your workflow to ensure scalable and reliable applications.

Happy Replicating!
Demystifying Commands and Arguments in Kubernetes
Tags: kubernetes, ckad, cmdkubectl, args
Published: 2024-02-01 12:58:45


Understanding how commands and arguments work in Kubernetes is crucial for optimizing your containerized applications. In this guide, we'll explore the nuances of defining commands and arguments, providing examples and insights to enhance your container orchestration skills.

## Basic Concepts
A container's lifespan is tied to the process inside it. When the process finishes or crashes, the container exits.
Define commands and arguments in the pod configuration file to override defaults provided by the container image.
Use the command and args fields to specify the executable and arguments for a container.
If you define args without specifying a command, the default command is used with your new arguments.

Examples

Example 1: Executing Commands

```
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
```

Example 2: Running a Command in a Shell

```
spec:
  containers:
  - name: shell-command-demo
    image: alpine
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10; done"]
```
Example 3: Specifying a Command and Arguments

```
spec:
  containers:
  - name: sleep-container
    image: busybox
    command: ["sleep"]
    args: ["5000"]
```
Example 4: Using a Dockerfile

```
FROM python:3.6-alpine
RUN pip install flask
COPY . /opt/
EXPOSE 8080
WORKDIR /opt
ENTRYPOINT ["python", "app.py"]
CMD ["--color", "red"]
```

Example 5: Dockerfile with Entry Point

```

FROM python:3.6-alpine
RUN pip install flask
COPY . /opt/
EXPOSE 8080
WORKDIR /opt
ENTRYPOINT ["python", "app.py"]
```
Important Considerations

> If you supply only args, the default ENTRYPOINT in the Docker image is run with the provided args.
> If you supply a command and args, the default ENTRYPOINT and CMD in the Docker image are ignored.

If you supply a command without args, only the supplied command is used, and the default ENTRYPOINT and CMD are ignored.
These principles apply when working with Kubernetes pods and containers. Understanding these nuances empowers you to fine-tune your applications for optimal performance and behavior within a Kubernetes environment.



Happy Kuberneting!
Start with a failing test
Published: 2024-02-03 08:05:24

---
title: Start with a failing test
published: true
date: 2024-02-01 00:00:00 UTC
tags: 
canonical_url: https://www.oliverdavies.uk/archive/2024/02/01/start-with-a-failing-test
---

When fixing a bug or adding a new feature using test-driven development, it's important to see the test fail first.

You should write your test so it doesn't pass by default or accidentally.

When creating data, such as users or nodes within tests, do so in a way that will force the test to fail, such as explicitly setting the title or published date into a non-default order.

When fixing a bug, write a test that represents the expected outcome when the bug is fixed. This confirms the bug exists and can be replicated.

Then, once the tests pass, you know the feature or fix is working and that it's because of your changes and not for any other reason.

 P.S. Need help or want another pair of eyes on your code? Book a [1-on-1 consulting call](https://www.oliverdavies.uk/call) or an [online pair programming session](https://www.oliverdavies.uk/pair) with a 100% money-back guarantee.
4 Python hints
Tags: python, beginners, tutorial
Published: 2024-02-01 12:43:34

> Cover image by <a href="https://pixabay.com/users/atulcodex-8240447/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=4101998">atul prajapati</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=4101998">Pixabay</a>

Sometimes I discover new things Python can do. These are 4 hints that help you in small ways to improve your code.

## Print overwrite
Python print function can overwrite the previous print if end=”\r” is added.
{% gist https://gist.github.com/wagenrace/b681e0ed64ed68b3f8cee0aa7ae8e067.js %}
![On the left a print statement in a for-loop without end=\r, it prints out a hundred lines. On the right the same for-loop but now the print statement has end=\r, it now only shows the last printed line.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgy6edh62kfpnmcezxdf.png)
> On the left a print statement in a for-loop without end=\r, it prints out a hundred lines. On the right the same for-loop but now the print statement has end=\r, it now only shows the last printed line.

## Parameters with limited options
You might be in a situation where you have a limited set of options. You can do nothing and hope this goes okay, this is technically an option. However, a more elegant solution is the Literal type. This type can have multiple options and editors can pick these up to give you good type hints.
{% gist https://gist.github.com/wagenrace/941f975bf9b12813fe5cb0897a07e8c6.js %}
![Vscode auto-completing with the options red, green, and blue that were given in the Literal type hint.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aseq2bwtqq7gcvefbnii.png)
> Vscode auto-completing with the options red, green, and blue that were given in the Literal type hint.

I am not a huge fan of Literal given it still allows you to fill wrong values and sharing the options is a bit clumsy. [Enum](https://docs.python.org/3/library/enum.html) is an easy way to create a simple object that can do the same.
{% gist https://gist.github.com/wagenrace/4fd54f6e78906798cd2f37edcc2cb925.js %}

## Json pretty dump
Normally json dump puts everything on one line. This is great if file size is a concern but it is not great for readability. By adding `indent` to `dump` or `dumps` you can make the json readable for humans.
{% gist https://gist.github.com/wagenrace/52641997c2ea1865b990d4d9a7bf0068.js %}

```json
    {
      "hello": "world",
      "goodbye": "Mars"
    }
```

## Very big or small numbers
If you have a number with a lot of digits you can split it up by using underscores. You can place it anywhere in the number. If you have a number with a lot of leading zeros you can use scientific notation. Scientific notation for a million, a 1 with 6 zeros, is 1e6. Scientific notation can also be used for very small numbers, 2e-2 equals 0.02.
{% gist https://gist.github.com/wagenrace/93061a45b3e0ddd66267d3b12cc246a0.js %}
I hope some of these hints help you make your Python code even prettier!