Skip to content

Instantly share code, notes, and snippets.

View fischerdr's full-sized avatar
:octocat:

David R. Fischer fischerdr

:octocat:
View GitHub Profile
@fischerdr
fischerdr / podcheck_ansible.yml
Last active November 13, 2024 15:13
grabs pods in a namespace with label then exec a cmd on each with check on results
---
- name: Get pods, retrieve secret, and execute command with secret data in each pod
hosts: localhost
gather_facts: no
vars:
namespace: "your-namespace"
label_selector: "app=myapp" # Adjust this label selector to match your pods
command_to_run: "your-command" # Replace with the command you want to execute
secret_name: "px-admin-token" # The name of the secret to retrieve
secret_key: "auth-token" # The key in the secret data to use as the environment variable value
@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)
@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 / 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",

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 \

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):
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:
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()
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
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__)