Skip to content

Instantly share code, notes, and snippets.

@pwillis-els
pwillis-els / Heap_Dump_Java_AWS_ECS.md
Created June 29, 2020 14:13
Dumping heap of a Java process running in AWS ECS

Heap dumping a Java process running in AWS ECS

Note: this guide is designed for AWS ECS services, but starting from Step 4 is functionally equivalent to any Docker container on a Linux host.

Step 1. Look up ECS service

  1. Log into the AWS Console using the appropriate AWS account
  2. Navigate to AWS ECS service clusters (https://console.aws.amazon.com/ecs/home)
  3. Make sure you are in the correct region, if not, switch to the correct region (second drop-down menu in top right corner)
  4. Select the correct cluster (ex: https://console.aws.amazon.com/ecs/home?region=us-east-1#/clusters//services)
  5. In the Services tab, In the 'Filter in this page' text box, type the name of the service
@pwillis-els
pwillis-els / attach_ebs.sh
Last active December 6, 2023 07:03
Bash script to attach an EBS volume to an EC2 instance after boot-time
#!/bin/sh
# attach_ebs.sh - Attach an EBS volume to an EC2 instance.
# Copyright (C) 2020 Peter Willis <peterwwillis+github@gmail.dotcom>
#
# This script is designed to create and mount a single EBS volume based on its tag:Name
# in order to implement persistent storage. If there is more than one EBS volume
# with the same tag, this script will fail.
#
# Order of operations:
# 1. Detect EBS volume based on "tag:Name" "$TAG_NAME"
@pwillis-els
pwillis-els / how-to-switch-roles-aws-adfs.md
Last active June 23, 2023 07:05
How to set up AWS CLI profiles to switch between roles while using Federated SAML authentication

Using profiles, assume-role, and Federated SAML authentication with AWS CLI

Let's say you use a Federated authentication method for AWS (like ADFS), and by default you have access to multiple roles and accounts. You want to be able to easily switch between accounts, roles, and even assume a second role after assuming a first one. The following guide explains how this works using [aws-adfs][1] and the [AWS CLI][2].

Background info about profiles

Profiles are how AWS CLI configures the settings for individual credentials, and allows you to switch between them. You can specify a profile either by passing the --profile NAME option to AWS CLI, or with an environment variable AWS_PROFILE=name.

@pwillis-els
pwillis-els / Jenkinsfile
Created November 25, 2020 06:07
Supply Git username/password via environment variables, plus sample Jenkinsfile
node('node-label') {
stage('Checkout') {
scm checkout
}
stage('Tag') {
sh 'git tag my-tag'
sh 'sh git-credential-env.sh --install'
withCredentials([[
@pwillis-els
pwillis-els / readme.md
Last active June 9, 2022 18:53
How I manage Terraform & AWS infrastructure

My development environment

I use a couple tools to make it easier for me to get work done:

  • cliv. This installs all my typical Ops tools that aren't packaged by my Linux distribution. This also allows me to switch versions of any tool at any time, either by specifying a particular version of a tool, or by pinning a version in a .COMMAND-versions file. No need for tfenv.

  • terraformsh. This wrapper for Terraform makes it much easier to manage lots of environments and run common Terraform commands. It's simpler than TerraGrunt and still allows me

@pwillis-els
pwillis-els / JenkinsAntiPattern-OpsToil.md
Last active May 31, 2022 19:56
Jenkins: A DevOps Anti-Pattern

Jenkins: A DevOps Anti-Pattern

Jenkins is the WordPress of CI/CD. Designed in another era, it creates more problems than it needs to and is more complex than it needs to be. But because it’s free and user-friendly, it is ubiquitous and perennial, like a weed. Every year, people will try to use it, unaware of the problems it will create.

The "tl;dr" is that Jenkins was not designed to be used like modern Cloud-native DevOps-friendly software. You can "make it work", in the same sense that you can make pigs fly.... but they're really not designed to fly.

What is Jenkins?

Jenkins is an “automation server”. Basically it’s software that can continuously run automated tasks for you. It has a friendly web-based user interface, and because it’s written in Java, you can run it on any computer. And it has a lot of plugins to add features to do whatever you need.

@pwillis-els
pwillis-els / Make_a_Git_Changelog_by_hand.md
Created January 25, 2022 16:24
Make a Git Changelog by hand

Making a Changelog by hand with Git

If you need to create a ChangeLog for a repository, there's a lot of software out there than can help you generate one. But most of it works by having your Git commits include certain information. What if you want to make a ChangeLog for software whose commit messages are not uniform?

Basically, just use git log to compare commits to your existing ChangeLog, and format the Changelog entry for a new release (using the Keep A Changelog format).

First add a shortcut to format Git logs to only show you the changes:

@pwillis-els
pwillis-els / AdminBestPractice.md
Created January 8, 2022 19:56
Kubernetes notes, tips, tricks, and best practices, for both administration and development

Kubernetes Administration Best Practice

Reliability

Networking Reliability

  • AWS VPC Container Network Interface (CNI) for Kubernetes has an inherent limit on number of pods per instance, due to using one ENI per pod per instance. The workaround is to use Calico CNI. The Calico CNI can be deployed in EKS to run alongside the VPC CNI, providing Kubernetes Network Policies support.

Manifest Reliability

@pwillis-els
pwillis-els / gist:2df85ee1658b8bf40c2a3d52392c081c
Last active November 22, 2021 01:35
Kubernetes Multitenancy: November 2021

This is an overview of the different options for multi-tenancy in Kubernetes as of November 2021.

Kubernetes Multi-Tentancy SIG (https://github.com/kubernetes-sigs/multi-tenancy)

@pwillis-els
pwillis-els / Simple_Atomic_File_Locking_Linux.md
Last active November 10, 2021 17:21
Simple Atomic File Locking in Linux

Simple Atomic File Locking in Linux

If you have access to a traditional programming language, there are many methods1 to use2 locks in linux3. However, we don't necessarily have access to those methods within a shell script. In addition, using locks over different kinds of filesystems (such as NFS) can also have inconsistencies and bugs.

What if you just want a very simple form of locking that works on all filesystems? The answer is Maildir locking. The way Qmail / Maildir works is specific to mail files, so I'll break it down in a more general way below. You also don't have to strictly follow this method; the general idea can be modified.