Skip to content

Instantly share code, notes, and snippets.

View isweluiz's full-sized avatar

Luiz isweluiz

View GitHub Profile
@isweluiz
isweluiz / K3s.md
Last active October 22, 2022 18:28

Lightweight Kubernetes. Production ready, easy to install, half the memory, all in a binary less than 100 MB.

Great for:

  • Edge
  • IoT
  • CI

First, if you need :) here you are the official documentation

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "your_email@example.com"

If you are facing the following issue while using pip install application_name:

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url

The following solution will help solve the problem:

Update the /etc/pip.conf with the following config:

Sometimes we need to read a list of files, a list of lines, a list of directories or other list, which we need to use some parameter to read those list. With Ansible we have a lot of different kind of options to do that, sometimes looks complex, due to the reason to have many ways to do the same thing, but lets uncomplicate that.

How I said Ansible support many mechanism to interact over loops, the most common is with_items, the documentation with all the avalable option is here.

Let's see some good way and option, to review and remember later.

loops-options

How to switch your ansible version in the same env?

Ansible is just a python package,if you have virtualenv installed on your host it is just a matter of creating a new venv for each ansible version you want, and then pip install it.

First, verify the installed Python version and path. Create a virtual environment using the python3 -m venv <environment-name> command. You can give any name to your Python virtual environment. I want to try the Ansible 2.10 version, so I named it in a way to identify the directory easily:

$mkdir ~/venvs/
$cd !$
$python3 -m venv ansible2.10
@isweluiz
isweluiz / k8s-rancher-v1.2.4.md
Last active September 16, 2022 12:06
un Rancher agent in k8s v1.24 - no secret exists for service account cattle-system/cattle

Run Rancher agent in k8s v1.24 - no secret exists for service account cattle-system/cattle

I noticed some errors related to secret for service user acctount to import the Kubernetes cluster version v1.24 for rancher server v2.6, below I show the reason for that, and explain the reason based on the documentation. This error starts to happen after the K8s version 1.24 when some new features were enabled in Kubernetes version 1.24, including how the tokens are generated. Looks like many people departed with the same issue, see here. k8s

*The LegacyServiceAccountTokenNoAutoGeneration feature gate is beta, and enabled by default. When enabled, Secret API objects containing service account tokens are no longer auto-generated for every ServiceAccount. Use the [TokenRequest API](https://kubernetes.io/docs/reference/kubernetes-api/authentication-res

RKE vs RKE2

RKE-image

RKE2, also known as RKE Government, is Rancher's next-generation Kubernetes distribution.

It is a fully conformant Kubernetes distribution that focuses on security and compliance within the U.S. Federal Government sector.

To meet these goals, RKE2 does the following:

  • Provides defaults and configuration options that allow clusters to pass the CIS Kubernetes Benchmark v1.6 with minimal operator intervention
  • Enables FIPS 140-2 compliance

How to modify a list of dictionaries with Ansible

For the below scenario, what we'are trying to solve to do?

  • Looking for directories and change their permissions
  • Change the permission non-recursive
  • Change just the folder that match with the specific permission

Ansible Modules