Skip to content

Instantly share code, notes, and snippets.

View nanox's full-sized avatar
🏣
Remote

Jose Leonardo Alvarez nanox

🏣
Remote
View GitHub Profile
const fs = require('fs');
/**
* This script transfers bash history to zsh history
* Change bash and zsh history files, if you don't use defaults
*
* Usage: node bash_to_zsh_history.js
*
* Author: Matteo Gaggiano
*/
@nanox
nanox / bash_to_zsh_history.rb
Created August 12, 2023 01:41 — forked from goyalankit/bash_to_zsh_history.rb
Import bash history to zsh history.
#################################################################
# = This script transfers bash history to zsh history
# = Change bash and zsh history files, if you don't use defaults
#
# = Usage: ruby bash_to_zsh_history.rb
#
# = Author: Ankit Goyal
#################################################################
# change if you don't use default values
@nanox
nanox / clean-up-arch-linux.md
Created March 26, 2024 17:26 — forked from rumansaleem/clean-up-arch-linux.md
Instructions to clean up Arch Linux (Manjaro)

Contents

  • Clean pkg cache
  • Remove unused packages (orphans)
  • Clean cache in /home
  • remove old config files
  • Find and Remove
    • duplicates
    • empty files
    • empty directories
  • broken symlinks
@nanox
nanox / install_oracle_xe_18c_under_wsl2.md
Last active June 19, 2024 01:05 — forked from dungsaga/install_oracle_xe_18c_under_wsl2.md
install Oracle XE 18x under WSL2

Install Oracle XE 18 under WSL2

  • install package is RPM, it's easier to use CentOS 7 or 8 (from CentOS-WSL or wsldl)
  • if you want to use Debian/Ubuntu, you must convert RPM to DEB (but conversion with alien fails under Debian)
  • first, install oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
  • second, install oracle-database-xe-18c-1.0-1.x86_64.rpm
  • see https://mikesmithers.wordpress.com/2019/01/03/installing-and-configuring-oracle-18cxe-on-centos/
  • run as root: /etc/init.d/oracle-xe-18c configure
  • it would fail if host IP is auto-generated to be 127.0.1.1
  • you can update the IP in /etc /hosts and try it again
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-latest-tag
spec:
validationFailureAction: audit
background: true
rules:
- name: require-image-tag
match:
apiVersion: batch/v1
kind: CronJob
metadata:
name: kyverno-events-cleanup
namespace: openshift-ops # Infra-only-namespace
spec:
schedule: "*/10 * * * *"
concurrencyPolicy: Forbid #do not allow the creation of new job before the previous one had finished
jobTemplate:
spec:
for NAMESPACE in $(oc get namespace --no-headers | awk '{print $1}' | grep -v "openshift-*") ;
do
oc get deployment,deploymentconfig -o name -n $NAMESPACE |\
xargs -n 1 -I OBJECT oc get OBJECT -o json -n $NS 2>/dev/null |\
jq -r 'select(.spec.template.spec.containers[].securityContext!={}) |
"Kind: " + .metadata.kind,
"NAME: " + .metadata.name,
"NAMESPACE: " + .metadata.namespace,
"To see the exact SCC, run:",
"oc get " + .kind + " " + .metadata.name + " -n " .metadata.namespace + " -o jsonpath={.spec.template.spec.containers[].securityContext} | jq .",
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: block-cluster-admin-openshift-etcd-ns
annotations:
policies.kyverno.io/title: Block Cluster Admin on Openshift-etcd Namespace
policies.kyverno.io/category: Sample
policies.kyverno.io/subject: RBAC
spec:
validationFailureAction: enforce
@nanox
nanox / ConfigMap-silence-alerts-script.yaml
Created September 20, 2024 23:31 — forked from tommeramber/ConfigMap-silence-alerts-script.yaml
K8s-CronJob-Silence-Alerts-Without-Duplicates
apiVersion: v1
kind: ConfigMap
metadata:
name: silence-alerts-script
namespace: openshift-monitoring
data:
runScript.sh: |
#!/bin/bash
oc -n openshift-monitoring exec alertmanager-main-0 -- amtool silence --alertmanager.url="http://localhost:9093" -o json | jq -r '.[].comment' >> /tmp/existing-silences.txt
kind: ServiceAccount
apiVersion: v1
metadata:
name: ldap-group-syncer
namespace: openshift-authentication
labels:
app: cronjob-ldap-group-sync
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole