Skip to content

Instantly share code, notes, and snippets.

View hemanth22's full-sized avatar

Hemanth B hemanth22

View GitHub Profile
- Basic structure
- oc <verb> <noun> [name]
- There are some exceptions, like `oc help` or `oc logs <pod>` or `oc exec`
- Most commands support `oc <command> --help`
- Common resources (nouns)
- Pods
- Deployments
- Services
- Routes
- ConfigMaps
@ywzhang909
ywzhang909 / es_manager.py
Last active August 28, 2022 15:20
elasticsearch toolkit #elasticsearch
from elasticsearch import Elasticsearch
from elasticsearch import helpers
class ESmanager():
def __init__(self, host, port):
self._host = host
self._port = port
self.__elasticsearch = Elasticsearch([{'host': self._host, 'port': self._port}])
self._connectES()
@numanturle
numanturle / elasticsearch.py
Created August 25, 2021 14:43
elasticsearch
import json
import sys
from time import sleep
from datetime import datetime
from elasticsearch import Elasticsearch, helpers
es = Elasticsearch("localhost:9200")
def create_index(index):
es.indices.create(index=index, ignore=400)
@andrewdoss-bit
andrewdoss-bit / bitdotio_csv_upload.py
Last active August 21, 2022 07:07
Upload csv to bit.io from Python w/ psycopg2
import bitdotio
import pandas as pd
# This is to provide a reproducible csv,
# you can ignore and use your own csv
df_test = pd.DataFrame(
data=[[0, 1, 2], [3, 4, 5]],
columns=['a', 'b', 'c'])
df_test.to_csv('test.csv', index=False)
@bh7cw
bh7cw / OSD-7443
Last active December 4, 2021 13:42
OSD-7443 script
#!/bin/bash
# set -x
echo "INFO: start putting the cluster into an imbalanced state"
# target workloads to rebalance
TARGET_PODS="alertmanager-main|prometheus-k8s|prometheus-adapter|splunkforwarder-deployment"
# check all the target pods on each infra node
for NODE in $(oc get node -l node-role.kubernetes.io/infra= --no-headers | awk '{print $1}'); do
#!/usr/bin/env bash
# Versoin one
oc get $(oc api-resources --namspaced=true | tail -n+2 | awk '{ print $1 }' | xargs | sed -e 's/\s/,/g')
# Version two (from https://access.redhat.com/solutions/4165791)
oc api-resources --verbs=list --namespaced -o name | xargs -n 1 oc get --show-kind --ignore-not-found -n $PROJECT_NAME
@ikurni
ikurni / pods-stuck-in-terminating
Created April 27, 2021 16:03
Delete pods stuck in terminating
### Step 1
oc delete pod <podsname> -n myproject --grace-period=0 --force
### Step 2
oc edit pod <podsname>
#Remove deletionTimestamp
#Before: deletionTimestamp: 2019-12-31T11:40:28Z
#After: deletionTimestamp: null
#Remove Finalizers
#Before
@bergerhoffer
bergerhoffer / oc-by-example-content.adoc
Created March 31, 2021 14:56
Auto generated oc commands

OpenShift CLI (oc) commands

curl -k "https://basic-ocp-demo-basic-ocp-demo-project.apps.cluster1.example.com/healthz"
# or build the curl URL programmatically!
curl -k "https://$(oc get route basic-ocp-demo -o jsonpath="{.spec.host}")/healthz"

Quick Reference

  • Basic structure
    • oc [name]
    • There are some exceptions, like oc help or oc logs <pod> or oc exec
    • Most commands support oc <command> --help
  • Common resources (nouns)
    • Pods
    • Deployments
  • Services