Skip to content

Instantly share code, notes, and snippets.

View fischerdr's full-sized avatar
:octocat:

David R. Fischer fischerdr

:octocat:
View GitHub Profile
import os
import logging
import hvac
from argparse import ArgumentParser
def setup_logging():
"""Set up the logging configuration."""
logging.basicConfig(
level=logging.INFO,
import logging
import os
import click
from kubernetes import client, config
from kubernetes.client.exceptions import ApiException
import yaml
# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
from kubernetes import client, config
from concurrent.futures import ThreadPoolExecutor, as_completed
def count_ns_resources_for_ns(ns, c_core, c_apps, c_batch, c_custom):
"""
Helper function to count resources for a single namespace.
:param ns: Namespace to query
:param c_core: CoreV1Api client
:param c_apps: AppsV1Api client
from kubernetes import client, config
def count_resources_by_namespace():
"""
Count all standard resources and custom resources (CRDs) grouped by namespace.
:return: A dictionary with namespaces as keys and resource counts as values.
"""
# Load kubeconfig
config.load_kube_config()
import click
import os
import re
import random
from kubernetes import client, config, utils
from kubernetes.client.rest import ApiException
# Function to load Kubernetes config from the environment or kubeconfig file
def load_k8s_config(kubeconfig_path=None):
if kubeconfig_path:
import tkinter as tk
from tkinter import filedialog, messagebox, ttk, simpledialog
from cryptography import x509
from cryptography.hazmat.backends import default_backend
import os
import ssl
import socket
class X509CertViewer:
def __init__(self, root):

This Dockerfile includes etcdctl for interacting with etcd and the AWS CLI for uploading backups to S3. Dockerfile

Use a lightweight base image

FROM alpine:3.18

Install necessary tools: etcdctl, aws-cli, and bash

RUN apk add --no-cache
etcd
aws-cli
bash \

@fischerdr
fischerdr / run_template_restapi.py
Last active November 18, 2024 01:22
run template in ansible tower using rest api
import os
import requests
import json
import click
import logging
from time import sleep
# Configure logging
logging.basicConfig(
filename="ansible_tower.log",
@fischerdr
fischerdr / check_k8s_node_vmwarethrd.py
Last active November 15, 2024 02:26
Threaded version of check nodes
import click
import logging
import ssl
import queue
from kubernetes import client, config
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim
from concurrent.futures import ThreadPoolExecutor, as_completed
import sys
@fischerdr
fischerdr / k8s_vmwarenodestatus.py
Created November 14, 2024 14:35
check all nodes in kubernetes against its vcenter cluster and shows ip,status,and disk status
import click
import logging
import ssl
from kubernetes import client, config
from pyVim.connect import SmartConnect, SmartConnectNoSSL, Disconnect
from pyVmomi import vim
# Set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)