Skip to content

Instantly share code, notes, and snippets.

View alioualarbi's full-sized avatar

Alioua Larbi alioualarbi

  • Everflow
  • Montréal, Québec, Canada
  • 23:33 (UTC -12:00)
View GitHub Profile
@alioualarbi
alioualarbi / jenkinsfile
Created April 27, 2023 23:56 — forked from mbaitelman/jenkinsfile
Jenkinsfile-Terraform-Deployments
pipeline {
agent {
docker {
image 'hashicorp/terraform:0.12.29'
args '--entrypoint=""'
}
}
parameters {
choice choices: ['us-west-2', 'us-east-2'], description: '', name: 'region'
choice choices: ['Plan', 'Apply', 'Destroy'], description: '', name: 'action'
@alioualarbi
alioualarbi / docker_console.sh
Created March 2, 2023 17:09 — forked from cbfn/docker_console.sh
Getting docker container id
# Don't forget to change <text> with the search term
#!/bin/bash
DOCKER_CONTAINER_NAME="container name or other text"
DOCKER_CONTAINER="$(docker ps | grep $DOCKER_CONTAINER_NAME | awk '{print $1;}')"
DOCKER_RUN_CONSOLE="docker exec -it $DOCKER_CONTAINER /bin/bash"
ascii_name() {
cat <<"EOT"
_ _ _
@alioualarbi
alioualarbi / Jenkinsfile
Created February 22, 2023 20:51 — forked from sweetpotatoman/Jenkinsfile
Jenkins Pipeline Jenkinsfile
// Every jenkins file should start with either a Declarative or Scripted Pipeline entry point.
node {
//Utilizing a try block so as to make the code cleaner and send slack notification in case of any error
try {
//Call function to send a message to Slack
notifyBuild('STARTED')
// Global variable declaration
def project = 'sa-android'
def appName = 'Sample App'
@alioualarbi
alioualarbi / Jenkinsfile
Created February 22, 2023 20:13 — forked from merikan/Jenkinsfile
Some Jenkinsfile examples
Some Jenkinsfile examples
@alioualarbi
alioualarbi / install.sh
Created February 20, 2023 15:55 — forked from hermanho/install.sh
This is an init.d/supervisor script for managing a easy_install \ pip install version of supervisor. Add the first file "supervisor" into /etc/init.d/supervisor and put "supervisord.conf" into /etc/supervisor/supervisord.conf
systemctl enable supervisord
systemctl start supervisord
systemctl status supervisord
@alioualarbi
alioualarbi / do_gcloud.sh
Created February 16, 2023 16:18 — forked from nhalm/do_gcloud.sh
A Google Cloud SDK install script
#!/bin/bash
set -x
function add_gcloud() {
echo "ADDING GCLOUD SDK"
gcloudversion=117.0.0
gcloudsha1=34a59db03cdc5ef7fc32ef90b98eaf9e4deff83f
gcloudfile=gcloud.gz.tar
pipeline {
agent any
stages {
stage('Triger CloudBuild..') {
steps {
googleCloudBuild credentialsId: '<ENTER-YOUR-CREDS-ID>' , request: inline('''steps:
# Creating a golden image
- name: gcr.io/cloud-builders/gcloud
id: create-golden-image
args:
@alioualarbi
alioualarbi / install-docker-debian.sh
Created January 24, 2023 18:02 — forked from MazenElzanaty/install-docker-debian.sh
Install docker on Debian and Debian based distributions
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
RED='\033[0;31m'
NC='\033[0m'
GREEN='\033[0;32m'
@alioualarbi
alioualarbi / gcr_delete_untagged.sh
Created January 10, 2023 19:38 — forked from lahsivjar/gcr_delete_untagged.sh
Script for deleting all untagged images in a specific project from Google Container Registry
#!/bin/bash
# Copyright [2018] [lahsivjar]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@alioualarbi
alioualarbi / prom-k8s-request-limits.md
Created January 3, 2023 21:01 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /