Skip to content

Instantly share code, notes, and snippets.

View sergsoares's full-sized avatar

Sergio Soares sergsoares

View GitHub Profile
@sergsoares
sergsoares / main.go
Last active May 15, 2022 15:28
Example in pure go of read a ENV VAR and leaving default value if not exists (In that case already convert from string to integer)
import (
"os"
"strconv"
)
func main() {
tc := 1
if temp := os.Getenv("THREADS"); temp != "" {
number, err := strconv.Atoi(temp)
if err != nil {
@sergsoares
sergsoares / main.tf
Created May 11, 2022 17:30
Example of kubernetes_ingress with Kubernetes provider for terraform
resource "kubernetes_ingress" "node0_ingress" {
metadata {
name = local.node0
namespace = local.namespace
annotations = {
"kubernetes.io/ingress.class" = "nginx"
"nginx.ingress.kubernetes.io/backend-protocol" = "HTTP"
"nginx.ingress.kubernetes.io/enable-cors" = "true"
}
}
@sergsoares
sergsoares / deployment.tf
Created May 11, 2022 17:24
Example of deployment with Kubernetes provider for terraform (kubectl_manifest)
resource "kubectl_manifest" "node0_deployment" {
apply_only = true
wait_for_rollout = false
yaml_body = <<YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${local.node0}
namespace: ${local.namespace}
@sergsoares
sergsoares / manifest.yml
Created May 11, 2022 17:23
Deployment Structure
apiVersion: apps/v1
kind: Deployment
metadata:
name: node0
namespace: namespace
labels:
app: node0
spec:
replicas: 3
selector:
@sergsoares
sergsoares / script.sh
Created May 10, 2022 16:49
Ubuntu server - Minimal Desktop possible with lxde
sudo apt-get install lxde xorg lxdm --no-install-recommends
@sergsoares
sergsoares / main.tf
Created May 9, 2022 14:32
Terraform example for process a list of names, adding a domain and join all in a single string.
# File: main.tf
locals {
# Static variables
domain = "domain.com"
name_list = [
"name1",
"name2",
"name3"
]
@sergsoares
sergsoares / lxqt-rc.xml
Created March 26, 2022 14:07
Openbox configuration
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file, it will be overwritten on install.
Copy the file to $HOME/.config/openbox/ instead. -->
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
<resistance>
<strength>10</strength>
<screen_edge_strength>20</screen_edge_strength>
</resistance>
<focus>
<focusNew>yes</focusNew>
@sergsoares
sergsoares / providers.tf
Created February 25, 2022 17:06
Example of Terraform providers configuration
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
@sergsoares
sergsoares / get-ecr-image.sh
Created February 16, 2022 12:38
Get ECR image using split in shell
get-ecr-image(){
# Split URI in shell
splittedUri=(${1//./ })
# Get needed positions (account & region)
ACCOUNT=${splittedUri[0]} # account
REGION=${splittedUri[3]} # region
# Get ECR password & Login in ECR
aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin "${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com"
@sergsoares
sergsoares / bash.sh
Created January 29, 2022 19:53
Script to get all configmaps values being used in a Namespace
kubectl get configmap -o json -n namespace | jq '.items[] | [.metadata.namespace, .metadata.name, .data ]'