Skip to content

Instantly share code, notes, and snippets.

View nastacio's full-sized avatar

Denilson Nastacio nastacio

View GitHub Profile
@nastacio
nastacio / AI draft to prompt for instructions
Last active June 10, 2024 21:48
AI Response to prompt
Original Prompt
> Write the step-by-step instructions for the following problem, grouping the information in sections titled "Overview," "Prerequisites," "Steps," "Validation," "Troubleshooting," and "References."
>
> I want the result in markdown format that I can use on a README.md file.
>
> On each step, add a "Command reference" link to the original documentation page describing the commands.
>
> Here is the problem:
>
@nastacio
nastacio / kubenstein-output-0.0.1.md
Created October 8, 2023 14:05
Transcription of Kubenstein v0.0.1 Troubleshooting Session

kubenstein:

You are a Kubernetes administrator asked to validate whether a cluster is running properly.

I am logged in to the cluster as a system administrator and can invoke the "kubectl" command-line interface from a terminal.

It is extremely important that you give me a single command at a time and wait for me to execute the command and give you the output.

Whenever you give me a command, observe the rules in this list named "prompt-rules":
@nastacio
nastacio / create-machine-set.sh
Last active October 19, 2022 01:11
Clone and modify machine sets in OCP cluster
#!/bin/sh
infra_id=$(kubectl get Infrastructure cluster -o jsonpath='{.status.infrastructureName}')
instance_size=${1:-c5a.xlarge}
kubectl get MachineSet \
-n openshift-machine-api \
-l hive.openshift.io/machine-pool=worker \
-l hive.openshift.io/managed=true \
-o yaml \
@nastacio
nastacio / kubectl-probes.sh
Created December 22, 2021 05:16
kubectl cheatsheet for container probes
# All containers, probes, restarts, duration of startup, and an assessment of probe settings relative to the startup time:
cat<<EOF > podlist.gotemplate
{{- range .items -}}{{\$pod := .}}
{{- .metadata.name -}}{{- "," -}}
{{- .metadata.namespace -}}{{- "," -}}
{{- range .status.conditions -}}
{{- if eq .type "PodScheduled" -}}
{{- .lastTransitionTime -}}
{{- end -}}
@nastacio
nastacio / delete_k8s_namespace.sh
Created May 19, 2021 15:58
Force deletion of k8s namespace
function delete_namespace() {
local namespace=${1}
kubectl get namespace ${namespace} -o jsonpath={.status.conditions} \
| jq '.[] | select(.type=="NamespaceContentRemaining" and .reason=="SomeResourcesRemain") .message' \
| sed "s| |\\n|g" | grep "\." \
| xargs -Iresource oc get resource -n ${namespace} -o name \
| xargs -I r2 oc patch r2 -n ${namespace} --type=merge --patch '{"metadata":{"finalizers":[]}}'
}
delete_namespace ${1}
#
# Updates the target branch for all ArgoCD applications on a namespace
#
# arg1 name of the new gitops branch
# arg2 namespace for the ArgoCD applications to be patched
#
function set_argo_branch() {
local new_branch=${1}
local namespace=${2:-openshift-gitops}
@nastacio
nastacio / gist:58fda519094746d75614fb630e9b6a0f
Created November 22, 2019 11:53
DB2 local instance with sample database
### (Optional) Create local DB2 instance
#### Create local network
```
docker network create workshop_nw
```
#### Create DB2 database (local docker container)
@nastacio
nastacio / kabanero-minishift.sh
Last active September 23, 2019 14:59
kabanero-minishift.sh
#!/bin/bash
set -e
set +x
curdir=`pwd`
scriptdir=`dirname "${0}"`
scriptname=`basename "${0}"`
#
@nastacio
nastacio / aact.sql
Last active January 27, 2019 02:39
Useful AACT queries
--
-- Count of clinical trials for each intervention type
--
select i.intervention_type, count(distinct i.nct_id)
from
interventions as i
group by
i.intervention_type
--
try {
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:/Users/nastacio/tmp/jndi");
InitialContext ctx = new InitialDirContext(env);
for (Entry<String, DB2SimpleDataSource> ds : dss.entrySet()) {
String name = ds.getKey();
CompositeName cn = new CompositeName(name);
Context subCtx = ctx;