teleren/devto huggingface dataset:
Multi-node local kubernetes cluster with loadbalancer and private registry
Tags: kubernetes, k8s, docker
Published: 2022-11-08 11:50:22

---
title: Multi-node local kubernetes cluster with loadbalancer and private registry
published: true
description: Multi-node local kubernetes cluster with loadbalancer 
tags: kubernetes, k8s, docker
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-11-08 11:40 +0000
---

I’ll keep this one short and to the point. Mostly copy-paste commands.

1. We’ll use sample go-lang helloworld application from this link: https://github.com/freakynit/go-k8s. Don’t worry if you don’t know go-lang. This tutorial has nothing to do with the programming language.
2. For k8s cluster, we’ll use [k3d](https://k3d.io/), an excellent tool to setup local kubernetes cluster.
3. Loadbalancer component will allow us to expose our k8s services externally.
4. Private registry(docker registry) will allow us to speed-up our code-build-push-pull iterations as we’ll not need to push new image every time we make changes to docker hub or any other public registry

#### Let’s begin
1. Clone the repo: https://github.com/freakynit/go-k8s
2. cd into it: `cd go-k8s`
3. Install k3d by following their official guide
4. Edit your docker config file (`~/.docker/daemon.json`) and add following (enables insecure registries, our private one basically):```json
"insecure-registries": [
 "registry.localhost:5000"
],
"registry-mirrors": [
 "https://registry-1.docker.io"
]
```
5. Start local registry server in docker container:```shell
k3d registry create registry.localhost --port 5000
```
6. Create multi-node kubernetes cluster with name: `mycluster` and `2 worker nodes`. Notice that we are also specifying `loadbalancer` and our local registry config file path(k3d-registries.yaml):```
k3d cluster create --api-port 0.0.0.0:6550 -p "8081:80@loadbalancer" --registry-use k3d-registry.localhost:5000 --registry-config k3d-registries.yaml --agents 2 mycluster
```
7. Build docker image for application:```shell
docker build -t freakynit/go-k8s:1.0.0 .
```
8. Tag this image with local registry host:```shell
docker tag freakynit/go-k8s:1.0.0 k3d-registry.localhost:5000/go-k8s:1.0.0
```
9. Add following entries to `/etc/hosts` so that you can access your k8s services on `loadbalancer` host and local registry:```shell
127.0.0.1 loadbalancer
127.0.0.1 k3d-registry.localhost
::1       k3d-registry.localhost
```
10. Push your app image to local registry:```shell
docker push k3d-registry.localhost:5000/go-k8s:1.0.0
```
11. Apply kubernetes config file:```shell
kubectl apply -f k8s-deployment.yaml
```
12. Check if pods are running.. keep trying every few seconds until all pods show status as running:```shell
kubectl get pod
```
13. Access your application:```shell
curl localhost:8081/
# OR
curl loadbalancer:8081/
```
> Once done, you can delete the cluster using:```shell
k3d cluster delete mycluster
```

---

k3d has a lot more options that allow much configuration and customization. Do explore these.

That’s all folks. Let me know if you face any issues in this.
Functions in JavaScript
Tags: javascript, function, decleration, argument
Published: 2022-11-09 13:01:45

Function is a piece of code created to preform a certain task. The function structure is built once, then it works every time we "call" it, and produces different results different with arguments.
 
 There are some functions already created in local libraries of JavaScript, such as Math.sqrt(), console.log(), alert(),  toString(), etc.

 Yet we can **create functions** for the particular project.

Functions have certain design which we need to use to **declare** them. It has the following stracture:
   
                  function name(argument) {
                              statements
                           }

We write function, give it a unique **name**, **argumennt(s)** (if necessary) in the brackets, then, inside the curly brackets, we write the **code that defines the function**, which should work every time we call the function. 

In the code there may be used the given **arguments**, which are new variables created within the function. Inside the function, the arguments behave as **local variables** and the change is not reflected globally. The function may also not require arguments and work without them. In this case the brackets are left empty. 

After the necessary code that should be working when we call the function is written inside the function and we want to give back some value out of the function, we should **return** that value. For that, at the end of the function, we write return and add the **value** that should be returned.

                    function sayHi(name) {
                            return "Hello " + name;
                              }

A function can return only one value. If additional returns are added, JavaScript will just ignore them.

When the function is ready, we can **call** it every time we need it by writing the function name and adding the brackets, necesserally with the arguments:

              function sayHi(name) {
                            return "Hello " + name;
                              }

              let firstHi = myFunction(Kima);
              console.log(firstHi);

As a result in a console we'll have printed _Hello Kima_.

Functions can be used in all types of formulas, assignments, and calculations. 

              let x = German(library);
              let text = "This word is " + x + " in German";

or we can use the function directly in the variable:

      let text = "This word is " + German(library) + " in German";
Full text search in postgres
Published: 2022-11-09 17:36:52

https://twitter.com/ghousek1ofcl/status/1581141049933643777?s=20&t=eWq5-IcRzfMzFOM3JSXJVw
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4w5r5iogrf40hfmq4tx.png)
What is React ?
Tags: react, reactnative, javascript, webdev
Published: 2022-11-09 19:49:49



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g55wer2s2a4pi3zggson.jpg)


Today, front-end frameworks and libraries are becoming an essential part of the modern web development stack. React.js is a front-end library that has gradually become the go-to framework for modern web development within the JavaScript community.

The React.js framework is an open-source JavaScript framework and library developed by Facebook. It’s used for building interactive user interfaces and web applications quickly and efficiently with significantly less code than you would with vanilla JavaScript.

React allows developers to use individual parts of their application on both the client and server sides, and any changes they make will not affect the application’s logic. This makes the development process extremely fast. The use of HTML tags and JS codes makes it easy to work with a huge dataset containing DOM. 

React acts as an intermediary that represents the DOM and helps you decide which component requires changes to get accurate results.React is incredibly user-friendly and makes any UI interactive. It also allows you to quickly and efficiently build applications, which is time-saving for clients and developers alike. One-way data-binding in react implies that absolutely anyone can trace all the changes that have been made to a segment of the data.  This is also one of the reasons that makes React so easy.
Is the Developer Economy around the corner?
Tags: developereconomy, creatoreconomy, devtech, devtools
Published: 2022-11-10 08:58:45

The #CreatorEconomy with ~50 million creators after only 10 years is estimated at over [$100 billion in 2022](https://www.forbes.com/sites/theyec/2022/07/18/make-the-most-of-the-creator-economy/?sh=1cf199e316e9).

Today, we have approx. 27 million Software Developers worldwide growing with 1 million YoY. Not including Low-Code / No-Code developers, Data Scientists, and DevOps Engineers. Github even claims there are [91 million Open-Source developers](https://twitter.com/github/status/1590403278793101312). 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv0akw81e5m94riiqr5p.png)

When will a #DeveloperEconomy emerge for #DevTech, #DevTools, and #OpenSource with software creators as well as dev influencers - similar to the #CreatorEconomy?

What do you think?
How to run Azure CLI with Docker
Tags: azure, cli, docker, nelsoncode
Published: 2022-12-11 02:39:33

To run the Azure CLI in a Docker container, you can use the following command:

### Azure CLI

```bash
docker run -it --rm -v ${PWD}:/work -w /work --entrypoint /bin/sh mcr.microsoft.com/azure-cli:latest
```

### Login to Azure

```bash
az login
az account list
```

### Output
```json
[
  {
    "cloudName": "AzureCloud",
    "id": "00000000-0000-0000-0000-000000000000",
    "isDefault": true,
    "name": "PAYG Subscription",
    "state": "Enabled",
    "tenantId": "00000000-0000-0000-0000-000000000000",
    "user": {
      "name": "user@example.com",
      "type": "user"
    }
  }
]
```

### Set suscription

```bash
az account set --subscription="00000000-0000-0000-0000-000000000000"
```
Advent of Code 2022 - Day 11
Published: 2022-12-11 08:00:28

---
title: Advent of Code 2022 - Day 11
published: true
description: I'm trying to solve all the Advent of Code puzzles in this video series.
tags:
cover_image: https://i.ytimg.com/vi/Aot_ORkkvP4/maxresdefault.jpg
---

{% youtube Aot_ORkkvP4 %}

I'm trying to solve all the Advent of Code puzzles in this video series.
Cannot connect to sftp server
Tags: linux, ssh, beginners, cloud
Published: 2022-12-11 13:43:16

Cannot connect to sftp server — “Too many authentication failures for user”
I faced this issue when trying to use Filezilla client to access a remote ftp location.

The initial stack trace ( with debug level set to 3) is as follows.
```
Trace:   Trying Pageant key #0
Trace:   Server refused public key
Trace:   Trying Pageant key #1
Trace:   Server refused public key
Trace:   Trying Pageant key #2
Trace:   Received disconnect message (protocol error)
Trace:   Disconnection message text: Too many authentication failures for facade
Trace:   Server sent disconnect message
Trace:   type 2 (protocol error):
Trace:   "Too many authentication failures for facade"
Error:   Server sent disconnect message
Error:   type 2 (protocol error):
Error:   "Too many authentication failures for facade"
Trace:   CSftpControlSocket::ResetOperation(66)
Trace:   CControlSocket::ResetOperation(66)
Error:   Could not connect to server
Status:   Waiting to retry...

```
Thanks to this post:

https://www.howtouselinux.com/post/2-ways-to-fix-ssh-too-many-authentication-failures

I identified that the reasons for this issue are follows.

- At the time of the issue, I had used “ssh-add” to add several keys for accessing multiple other instances.
- FileZilla does’t know which keys it needs to try and tries every available keys
- The server had set a maximum retry count (3) and as I had more than 3 keys, FileZilla failed after trying only 3 keys.
How to Make Responsive Accordion in HTML
Tags: html, css, javascript, beginners
Published: 2022-12-11 14:57:28

In this article, we will make Responsive Accordion in HTML CSS & JavaScript. So what we do here is, we will add some divs for accordion titles, in which we will write some information and details. This information and details will be hidden by default, so to show that we will add a plus icon to extend the accordion. Once the information gets extended then we will replace the plus icon with cross icon to hide again the details.
[Read More](https://rocoderes.com/how-to-make-responsive-accordion-in-html-css-js/)
Comparar dos Objetos en JavaScript
Tags: javascript, tutorial, beginners, spanish
Published: 2022-12-14 15:00:00

En ocasiones es necesario comparar dos objetos en JavaScript, por ejemplo, para saber si son iguales o no. En este artículo veremos cómo hacerlo.

A simple vista, parece que comparar dos objetos en JavaScript es una tarea sencilla, pero no lo es. Esto se debe a que los objetos en JavaScript son referencias a una ubicación de memoria, por lo que si dos variables apuntan al mismo objeto, entonces son iguales.

Por ejemplo, si utilizamos el operador de igualdad `===` no funcionará dado que las variables apuntan a una ubicación de memoria diferente, y no se comparan valores como en los datos primitivos.

Otra forma de realizar esta comparación es convirtiendo los objetos a cadenas de texto con `JSON.stringify` y luego compararlas con el operador de igualdad `===`, pero si los atributos del objeto no están en el mismo orden, entonces no serán iguales.

## Comparar dos Objetos en JavaScript

Para realizar la comparación de dos objetos podemos crear una función que realice esta tarea implementando diferentes validaciones, dado que los objetos pueden tener diferentes tipos de datos, y objetos anidados.

```js
function compareObjects(obj1, obj2) {
  const firstObjectKeys = Object.keys(obj1);
  const secondObjectKeys = Object.keys(obj2);
  
  if (firstObjectKeys.length !== secondObjectKeys.length)
    return false;
  
  return firstObjectKeys.every((key) => {
    if(obj1[key] === null && obj2[key] === null)
      return true;
    
    if(obj1[key] === null || obj2[key] === null)
      return false;
    
    if(typeof obj1[key] === 'object' && typeof obj2[key] === 'object')
      return compareObjects(obj1[key], obj2[key])
    
    return obj1[key] === obj2[key] 
  });
}
```

Esta función realiza la validación de diferentes escenarios: 

* Objetos con atributos en diferente ordene.
* Objetos con diferentes cantidades de atributos.
* Objetos con atributos de diferentes tipos de datos.
* Objetos con atributos anidados.
* Objetos con atributos nulos.
* Objetos con objetos anidados.

Por ejemplo, se tienen los siguientes dos objetos:

```js
const personOne = {
  name: 'John',
  age: 30,
  address: {
    street: 'Main Street',
    number: 123,
    city: 'New York',
    country: 'USA',
  },
};

const personTwo = {
  age: 30,
  name: 'John',
  address: {
    street: 'Main Street',
    number: 123,
    city: 'New York',
    country: 'USA',
  },
};
```

Si ejecutamos la función `compareObjects` con los objetos `personOne` y `personTwo` como parámetros, nos devolverá `true`:

```js
compareObjects(personOne, personTwo); // true
```

En conclusión, podemos comparar dos objetos en JavaScript de diferentes formas, la mostrada en este artículo es una de ellas, pero existen otras formas de realizar esta tarea.
Java By Example: Values
Tags: java, beginners, programming
Published: 2022-12-12 06:09:27

Java has various value types including `String` , `Integer`, `Double`, `Boolean`, etc. Here are a few basic examples.

The usage of these data types are shown in the below code block
```java
class Values {
  public static void main(String[] args) {
    
    // Strings, that can be added together with +.
    System.out.println("Java" + " " + "Lang"); 

    // Integer and Double
    Integer sum = 1+1;
    Double division = 7.0/3.0;
    System.out.println("1+1 = " + sum);
    System.out.println("7.0/3.0 =" + division);
    
    //Booleans, with boolean operators as you’d expect.
    System.out.println(true && false);
    System.out.println(true || false); 
    System.out.println(!true);
  }
}
```

Below are the commands and output.
```shell
javac Values.java
java Values
# Java Lang
# 1+1 = 2
# 7.0/3.0 = 2.3333333333333335
# false
# true
# false
```
How to make a python algorithm that will predict the results of a soccer game
Published: 2022-12-12 10:33:22

It is not possible to create an algorithm that can accurately predict the results of a soccer game, let alone a World Cup semi-final. Soccer is a complex sport with many variables at play, including the skills and strengths of the individual players, the tactics of the coaches, and the specific conditions of the game (e.g. the field, the weather, etc.). There are too many unknowns and factors that can affect the outcome of the game to create a reliable predictive algorithm.

Even if you could somehow gather all the necessary data about the teams and players, the best you could hope for is to create a model that would give you the probability of each team winning, drawing, or losing. But even then, the model's predictions would not be guaranteed to be accurate, as there are always unexpected events and circumstances that can influence the outcome of a soccer game.

Here is an example of how you could approach creating a simple model to predict the outcome of a soccer game using Python:

Gather data on the teams and players, such as their past performance, individual player stats, and team tactics.
Use this data to create features that represent the relevant characteristics of each team and player. For example, you could create features for each team's average number of goals per game, the number of shots on target, the percentage of passes completed, etc.
Use a machine learning algorithm, such as a decision tree or a random forest, to train a model on this data. The model will learn to predict the outcome of a game based on the input features.
Test the model on a separate dataset to evaluate its accuracy.
However, as mentioned earlier, even the most advanced models and algorithms will not be able to accurately predict the outcome of a soccer game with complete certainty. The best you can do is to create a model that will give you an indication of the likely outcome based on the available data.
How VuePress can save your time?
Tags: vue, jamstack, javascript, tutorial
Published: 2022-12-12 17:40:35

VuePress is a static site generator based on the Vue.js JavaScript framework. It is designed to be simple and easy to use, and it allows developers to quickly create and publish static sites with minimal configuration.

Today we are going to take a look at VuePress's features to make a simple content, Git-Based Blog.

1. Install VuePress: To use VuePress, you first need to install it. You can do this by running the following command:

```
npm install -g vuepress
```

2. Create a new project directory: Next, create a new directory for your project and navigate to it in your terminal.

3. Initialize the project: Once you are in your project directory, run the following command to initialize the project:

```
vuepress init
```

4. Create a new markdown file: **VuePress** uses _markdown_ files to generate static pages, so you will need to create a new markdown file for your blog post. To do this, create a new file called **blog-post.md** in your project directory.

5. Add the content for your blog post: Open the blog-post.md file in a text editor and add the content for your blog post. You can use regular markdown syntax to format your text and add images, links, and other elements.

6. Start the VuePress development server: VuePress includes a built-in development server that allows you to preview your blog post as you work on it. To start the development server, run the following command:

```
vuepress dev
```

7. Preview your blog post: Once the development server is running, you can preview your blog post by opening a web browser and navigating to the following URL:
```
http://localhost:8080/blog-post.html
```

8. Build the static site: Once you are satisfied with your blog post, you can build the static site by running the following command:

```
vuepress build
```

For more about `VuePress` visit the Vuepress docs [here](https://vuepress.vuejs.org/guide/)

> I hope this helps! Let me know if you have any other questions.
HackNITR 4.0
Tags: hackathon, programming, community, beginners
Published: 2022-12-13 06:59:25

[Register here](https://www.hacknitr.com/)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3s3zttunhzutz3p4u905.png)
As the legacy continues, we bring our flagship event back. HackNITR 4.0 is a collaboration between DSC NIT Rourkela and OpenCode, is all set to get the ball rolling with a larger definition than the previous editions. With more than 2200 registrations, 50+ sponsors and INR 5,00,000+ worth prizes, HackNITR 3.0 is in itself a testimony to the grandeur we await this time.
Buckle up! HackNITR 4.0 is going to be a bumpy ride full of perks, goodies, experience and fun.
With the love and feedback that we received from the last edition, here are a few added perks why you should definitely join us in this hacking extravaganza

**About HackNITR 4.0**

HackNITR 4.0 is a hackathon to encourage you to use your imagination and invention to develop cutting-edge technology-based solutions to challenges in the real world. It was put together by a large group of tech enthusiasts from Google Developer Student Club (GDSC) NIT Rourkela and OpenCode. The main goal is to grow our local community and give hackers an unforgettable experience. The plethora of fun and excitement is waiting for you from 6th Jan 2023.

**HackNITR accomplishments so far!**

HackNITR is glad to announce its 1000+ registration. But this is just the beginning. We provide you with this wonderful opportunity to network with others who share your interests, collaborate with them, and share expertise to quickly create exceptional projects and find answers to urgent real-world problems.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcs4h1zdyibuje6xcl97.png)
Register now to experience one of the largest student-run hackathon of India.

**How can I participate?**

As the countdown starts for D-day Our HackNITR team is all set to begin with the registrations. Still here? Head over to the website link given below and register right away for the largest student-run hackathon in East India, HackNITR 4.0 and complete the first step to discovering all that we have in store for you.

PS - There is absolutely no prerequisite. If you look forward to your first hackathon or craving an offline tint to your hacking journey, we have it all covered.

[Registration Link](https://www.hacknitr.com/)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqj09xlo6jjg73k2fiyp.gif)


Follow our Social Handles to stay tuned
[HackNITR Website](https://www.hacknitr.com/)
[HackNITR Instagram](https://www.instagram.com/hacknitr/)
[HackNITR LinkedIn](https://www.linkedin.com/company/hacknitr/)
[HackNITR Twitter](https://twitter.com/hacknitr)

Let's make this event grand and succesfull
Thank you❤️
Amazon CloudWatch Tutorial | AWS Certification | Cloud Monitoring Tools | AWS Tutorial
Tags: aws, cloudwatch, cloud, tutorial
Published: 2022-12-13 12:46:55

This Tutorial on "Amazon CloudWatch Tutorial” will help you understand how to monitor your AWS resources and applications using Amazon CloudWatch a versatile monitoring service offered by Amazon.

Following are the list of topics covered in this session:

1. What is Amazon CloudWatch?
2. Why do we need Amazon CloudWatch Events?
3. What do Amazon CloudWatch Logs do?
4. Hands-on   

{% embed https://www.youtube.com/watch?v=__knpcBRLHg %}