Skip to content

Instantly share code, notes, and snippets.

View jgato's full-sized avatar
🎩
Open unlocks the world's potential

Jose Gato Luis jgato

🎩
Open unlocks the world's potential
View GitHub Profile
#! /bin/bash
#
# This script takes a sitconfig file and it will move
# for each node
# the nodeNetwork section into a separated NMStateconfig
#
# It can be helpful to reduce a siteconfig file, moving
# the network configuration to separate NMStateconfig files
# Then everything will be merged together with ArgoCD
# to start a deployment
@jgato
jgato / ztp-tricks.sh
Created December 4, 2023 16:29
ZTP Tips and Tricks
# get all the policies ordered by ztp-wave:
$> oc -n <CLUSTER_NAME> get policies -o json | jq -r '.items[] | "Policy: " + .metadata.name + " on wave: " + .metadata.annotations."ran.openshift.io/ztp-deploy-wave"' | sort -g -t ":" -k 3
@jgato
jgato / create-cgu.sh
Created August 24, 2023 09:08
very simple template to create a ZTP CGU
#! /bin/bash
if [ $# -lt 2 ]
then
echo "Usage: ./script.sh <CGU-NAME> <CLUSTER-NAME>"
exit 1
fi
export CGUNAME=$1
export CLUSTERNAME=$2
#! /bin/bash
#
echo "Execute the command from a directory containing a Git repo of the assisted-agent"
echo "Also, exports a proper KUBECONFIG to your Openshift cluster with RHACM installed"
IMAGE=`oc -n open-cluster-management get deployment infrastructure-operator -o yaml | grep assisted-installer-agent-rhel8 | grep value | awk '{print $2}'`
echo "#########################################"
echo "Assisted Agent image is: $IMAGE"
@jgato
jgato / ztp-cluster-pre-req.sh
Created June 1, 2023 12:18
for a given cluster-name (NAMESPACE) and a list of hosts, it will create the needed secrets to prepare the deployments. It will ask for the BMC user/password of each host
#! /bin/bash
if [ $# -lt 2 ]
then
echo "Usage: ./script.sh <NAMESPACE> <HOSTNAME_1> ... <HOSTNAME_N>"
exit 1
fi
export CLUSTERNS=$1
export HOSTNAME=$2
@jgato
jgato / pod-hello.yaml
Created May 30, 2023 09:51
just helloworld pod with an image from open quay.io
apiVersion: v1
kind: Pod
metadata:
name: hello
labels:
app: hello
namespace: test
spec:
serviceAccount: testuser
serviceAccountName: testuser
@jgato
jgato / get_RHCOS_version.sh
Created April 19, 2023 09:53
Get the RHCOS version for each OCP version
#!/bin/bash
if [ -z "$CHANNEL" ]
then
echo Provide the channel via \'export CHANNEL=stable-4.x\'
exit 1
fi
rm -f version_maps &> /dev/null
VERSIONS=$(curl -sH 'Accept: application/json' "https://api.openshift.com/api/upgrades_info/v1/graph?channel=${CHANNEL}" | jq '.nodes[].version' -r)
apiVersion: v1
kind: Namespace
metadata:
name: reproducer-sync-waves
annotations:
argocd.argoproj.io/sync-wave: "0"
spec: {}
apiVersion: v1
kind: ServiceAccount
metadata:
@jgato
jgato / get-assisted-service-version.sh
Last active November 3, 2023 12:39
Script to get information from an assisted image container image
#! /bin/bash
#
echo "Execute the command from a directory containing a Git repo of the assisted-service"
echo "Also, exports a proper KUBECONFIG to your Openshift cluster with RHACM installed"
IMAGE=`oc -n multicluster-engine get deployment infrastructure-operator -o yaml | grep agent-service-rhel8 | grep image | awk '{print $2}'`
echo "#########################################"
echo "Assisted service image is: $IMAGE"
@jgato
jgato / agent_from_bmh.sh
Last active January 5, 2023 11:47
Find out the Agent object corresponding to a BMH
# It returns all the BMH of an spoke cluster
# and its corresponding Agent
# it could be useful when scaling down a cluster with ZTP
# ZTP only controls (and delete) the BMH object
# but the Agent is not under the Gitops control
# and it has to be manually deleted
oc -n <SPOKE_CLUSTER_NS> get Agent.agent-install.openshift.io -o json \
| jq '.items[].metadata | "BMH resource: " + .labels."agent-install.openshift.io/bmh" + " with Agent: " + .name '