Skip to content

Instantly share code, notes, and snippets.

View eloylp's full-sized avatar
🎯
Focusing

eloylp eloylp

🎯
Focusing
View GitHub Profile
@eloylp
eloylp / Fedora35Hibernation.md
Last active February 27, 2024 05:57
Fedora 35 hibernation with swapfile, only for hibernation and resume
View Fedora35Hibernation.md

Fedora35 hibernation

This guide helps to configure the hibernation on a default Fedora35 (also worked fine in previous Fedora34) installation by using a swap file. The Fedora35 installation comes with btrfs as default filesystem. Also, it comes with a zram swap device:

$ swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition   8G   0B  100
@eloylp
eloylp / Dockerfile
Created May 2, 2021 09:59
A Go vanity url server deployment based on https://github.com/GoogleCloudPlatform/govanityurls
View Dockerfile
## You can PULL this image from https://hub.docker.com/r/eloylp/go-vanity-urls-server
FROM golang:1.16.3 AS build
WORKDIR /src
COPY . .
# Dont run your programs as root.
RUN useradd -u 10001 nonprivuser
ARG VERSION
RUN git clone https://github.com/GoogleCloudPlatform/govanityurls.git app \
@eloylp
eloylp / Dockerfile
Created October 16, 2020 08:08
Optmized Dockerfile for golang projects
View Dockerfile
FROM golang:1.15.3 AS build
WORKDIR /src
COPY . .
# Dont run your programs as root.
RUN useradd -u 10001 nonprivuser
# CGO_ENABLED=0 -Disable CGO to discard CGO stuff and completely use pure Go net stack.
# -trimpath -Skip your local paths in error stacktraces, take only from the root of the repo.
# -ldflags="-s -w" -Skip debugging symbol table (DWARF tables) from the binary. About ~25 % less of weight.
# -tags timetzdata -Add tzdata for be docker image indepent. Around ~800KB more size.
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -tags timetzdata -o my-binary
@eloylp
eloylp / startup_script_backups.sh
Last active February 10, 2020 09:52
startup_script_backups.sh
View startup_script_backups.sh
#!/bin/bash
curl -fsSl https://gist.githubusercontent.com/eloylp/7bd966d2b9895770dd0d47c199009b7f/raw/ad13d9636068b267ded1148c74ef8c782a0d955e/node_exporter_setup.sh | bash \
&& curl -fsSL https://gist.githubusercontent.com/eloylp/f05b4de931cc0a0cdd1e713b015639ba/raw/2651a96ae5d4a266d52fe2caa63c0546c17e37d1/install_and_expose_dockerd.sh | bash
@eloylp
eloylp / install_and_expose_dockerd.sh
Last active February 3, 2020 10:43
Install docker and expose docker daemon over TCP. Prepared for GCP metadata startup script.
View install_and_expose_dockerd.sh
#!/bin/bash
curl -fsSL https://get.docker.com | bash
DOCKER_CONFIG_OVERRIDE_DIR=/etc/systemd/system/docker.service.d
mkdir -p $DOCKER_CONFIG_OVERRIDE_DIR
cat <<EOF > $DOCKER_CONFIG_OVERRIDE_DIR/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376
@eloylp
eloylp / traefik.yml
Last active December 26, 2019 21:53
Traefik 2.x sample configuration with Lets encrypt
View traefik.yml
log:
level: INFO
entryPoints:
web:
address: ":80"
web-secure:
address: ":443"
metrics:
address: ":9090"
@eloylp
eloylp / node_exporter_setup.sh
Last active February 10, 2020 09:52
Node exporter setup
View node_exporter_setup.sh
#!/bin/bash
cat << EOF > /etc/systemd/system/node_exporter.service
[Unit]
After=network.target
[Service]
ExecStart=/usr/local/bin/node_exporter
@eloylp
eloylp / del_stuck_namespace.sh
Created May 4, 2019 17:44
Force delete stuck kubernetes namespaces
View del_stuck_namespace.sh
#!/bin/bash
NAMESPACE=$1
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
rm temp.json
@eloylp
eloylp / cert.sh
Created April 21, 2019 19:17
Self signed certificate with own ca
View cert.sh
openssl req -new -x509 -days 720 -extensions v3_ca -keyout my-ca.key -out my-ca.crt
openssl genrsa -out server.key
openssl req -out server.csr -key server.key -new
openssl x509 -req -in server.csr -CA my-ca.crt -CAkey my-ca.key -CAcreateserial -out server.crt -days 720
@eloylp
eloylp / gcloud_commands_cli_docker.sh
Created April 12, 2019 18:33
Gcloud cli with docker
View gcloud_commands_cli_docker.sh
docker pull google/cloud-sdk:latest
docker run -ti google/cloud-sdk:latest gcloud version
docker run -ti --name gcloud-config google/cloud-sdk gcloud auth login
docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk gcloud config set project <your-project-id>
docker run --rm -ti -v $(pwd):/src -v /var/run/docker.sock:/var/run/docker.sock:ro --volumes-from gcloud-config google/cloud-sdk bash
## kubernetes
gcloud container clusters get-credentials <your_cluster> --zone <your_zone> --project <your-project-id>