Skip to content

Instantly share code, notes, and snippets.

@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

Ansible Inventory report with ansible-cmdb

Ansible-cmdb takes the output of Ansible's fact gathering and converts it into a static HTML overview page (and other things) containing system configuration information.

It supports multiple types of output (html, csv, sql, etc) and extending information gathered by Ansible with custom data. For each host it also shows the groups, host variables, custom variables and machine-local facts.

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

Infrastructure as Code is based on a few practices

sketch

  • Use Definition Files: all configuration is defined in executable configuration definition files, such as shell scripts, Ansible playbooks, Chef recipes, or Puppet manifests. At no time should anyone log into a server and make on-the-fly adjustments. Any such tinkering risks creating SnowflakeServers, and so should only be done while developing the code that acts as the lasting definition. This means that applying an update with the code should be fast. Fortunately computers execute code quickly, allowing them to provision hundreds of servers faster than any human could type.

  • Self-documented systems and processes: rather than instructions in documents for humans to execute with the usual level of human reliability, code is more precise and consistently executed. If necessary, other human readable documentation can be generated from this code.

  • Version all the things: Keep all this code in source con

@isweluiz
isweluiz / GitCommitEmoji.md
Created June 8, 2022 11:25 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
### Automating push with just a single bash command
```bash
vim git-push
```
```bash
@isweluiz
isweluiz / jinja-split-line.md
Last active June 4, 2022 14:50
How to remove the line when the variable is not defined in jinja2 template

How to remove the line when the variable is not defined in jinja2 template

I have the JINJA2 template below, and so the issue is that when some variable is not defined the conditional will have just a blank line, this is not what I would expect. See the result below the code and let's try to solve it.

If you wanna to do some live test I really recommend try to use https://j2live.ttl255.com/ .

My template:

@isweluiz
isweluiz / markdown-details-collapsible.md
Created April 13, 2022 10:13 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets