Skip to content

Instantly share code, notes, and snippets.

View cmcconnell1's full-sized avatar

Chris McConnell cmcconnell1

View GitHub Profile
@cmcconnell1
cmcconnell1 / main.rs
Created October 10, 2024 01:02
rust local IP test
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
/// Checks if a given `SocketAddr` is within the specified local IP ranges:
/// - 127.0.0.1 (loopback address)
/// - 10.0.0.0/8
/// - 172.16.0.0/12
/// - 192.168.0.0/16
fn is_local(addr: &SocketAddr) -> bool {
match addr.ip() {
IpAddr::V4(ip) => {

Kubectl Cheat Sheet

  • focusing on kubectl commands commonly used for development, debugging, and maintenance tasks.
  • This can be imported as markdown and saved as a Confluence page etc. for easy reference.

Overview

This cheat sheet covers some essential kubectl commands for platform engineers. It includes syntax examples for inspecting resources, managing configurations, debugging, and performing essential tasks.


Cheat-sheet / troubleshooting guide for tracking down issues between Prometheus and Grafana when metrics are not showing up. This guide assumes Prometheus is collecting metrics but Grafana is not displaying them.

1. Verify Prometheus Service Status

Ensure that the Prometheus service is up and running and accessible within the Kubernetes cluster.

kubectl get pods -n <prometheus-namespace> -l app=prometheus
kubectl get svc -n <prometheus-namespace> -l app=prometheus
# http://documentup.com/skwp/git-workflows-book
[user]
name = First Last
email = [email protected]
#token =
[url "[email protected]:"]
insteadOf = https://github.com/
[core]
excludesfile = /Users/youruserid/.gitignore_global
@cmcconnell1
cmcconnell1 / gcp-label-project.sh
Last active December 2, 2020 19:34
enable compute.googleapis.com and label all gcp projects
#!/bin/bash
# gcloud configuration options to reduce output verbosity:
# gcloud config set core/log_http False;
# gcloud config set core/user_output_enabled True;
# debug, info, warning, error, and none
# gcloud config set core/verbosity warning;
function usage() {
printf "\nUsage: $0 [-help ] [-h]\n"
@cmcconnell1
cmcconnell1 / global-awspricing-ec2.py
Last active August 10, 2020 20:45
example using lyfts awspricing module to get global AWS region EC2 on-demand and reserved instance pricing
#!/usr/bin/env python3
import boto3
import awspricing
import os
# example using lyfts awspricing module to get global AWS region EC2 on-demand and reserved instance pricing
# created as answer/response for another user on realypython slack.
# ./simple-awspricing.py
@cmcconnell1
cmcconnell1 / aws-lambda-dev-usw2-scale-up-error
Created July 27, 2020 23:43
terraform-aws-github-runner lambda scale up SQS PEM error
2020-07-27T16:33:53.349-07:00
2020-07-27T23:33:53.349Z fa882d3a-bfeb-579f-b680-7aa3d978a21f INFO {
Records: [
{
messageId: '4ead6fb3-1461-46d2-beb7-29fecf44195a',
receiptHandle: 'AQEB5K0sqP+/kRXkevHdoRCjkj5htZzO+TqfHmBcwbFP8vVgBVzFayhVsLzjUkULTOvLUN2MCHprzLoe4nLLvxDtXPi3j0x83EWpT8V56rttxYNUivcHG4JPpUepHc4G26WrIocNAch5vGU7wMZYvsI5zCoeWJaMQO5rHIYHLsZx1vrCLHuPshPe8RVSDEn/7ni/V5hNsszbgZSLrnFok2LuFPLD6rvIvUWy1jg4TrFcd7yX9+2J/uUgESBfA0Pp8vY+A/nEzZ4oD9zpMWwWdgXF3JV7Pfe7AR5xSKGGsFs8M7Q=',
body: '{"id":916373631,"repositoryName":"cmcc-test-runner","repositoryOwner":"terradatum","eventType":"check_run","installationId":10551986}',
attributes: [Object],
messageAttributes: {},
md5OfBody: 'bc2b7f5c76ad9b37b1e23e97ce2a5519',
@cmcconnell1
cmcconnell1 / k8s-service-account-kubeconfig.sh
Last active August 21, 2019 00:58 — forked from ericchiang/k8s-service-account-kubeconfig.sh
dynamic generation of kubeconfig files for ci and cd macos and linux
#!/usr/bin/env bash
# ref: https://gist.github.com/ericchiang/d2a838ddad3f44436ae001a342e1001e
# thanks to ericchiang for the initial gist, just tweaked for macos or linux and dynamic file naming.
# Creates kubeconfig files using tokens.
# Copy these files to where the ci or cd processes/envs run kubectl commands--i.e.: jenkins, etc.
#
# Usage ./k8s-service-account-kubeconfig.sh ( namespace ) ( service account name )
# i.e.: k8-sevice-account-kubeconfig.sh ci ci
# i.e.: k8-sevice-account-kubeconfig.sh cd cd
# this is for the naming the kubeconfig file naming us "kubeconfig-$KUBE_USER"
@cmcconnell1
cmcconnell1 / kube-aws-v0.10.2-autoscaler-node-pools-kiam-cluster.yaml
Created September 24, 2018 17:00
proposal for kube-aws docs to include working examples of kube-aws cluster.yaml files with working nodepools, autoscaler, kiam, etc.
# this is an example offered as proposal to include in kube-aws docs/examples
# ref: https://github.com/kubernetes-incubator/kube-aws/issues/1050
clusterName: opsinfra
s3URI: s3://my-bucket-kube-aws-us-west-1/
releaseChannel: stable
amiId: "ami-0a86d340ea7fde077"
disableContainerLinuxAutomaticUpdates: true
apiEndpoints:
- # The unique name of this API endpoint used to identify it inside CloudFormation stacks
name: default
@cmcconnell1
cmcconnell1 / cluster.yaml
Created September 14, 2018 18:50
kube-aws new/latest version v0.10.2 cluster.yaml kube2iam CrashLoopBackOff error: level=fatal msg="route ip+net: no such network interface"
clusterName: opsinfra
s3URI: s3://my-bucket-kube-aws-us-west-1/
releaseChannel: stable
amiId: "ami-0a86d340ea7fde077"
disableContainerLinuxAutomaticUpdates: true
apiEndpoints:
- # The unique name of this API endpoint used to identify it inside CloudFormation stacks
name: default
dnsName: opsinfra.myfoo.com
loadBalancer: