Skip to content

Instantly share code, notes, and snippets.

@adiii717
adiii717 / k8s-jprofiler-attach.sh
Last active August 31, 2021 01:16 — forked from smola/k8s-jprofiler-attach.sh
Attach JProfiler agent to a JVM running in a Kubernetes pod
#!/bin/bash
set -ex
usage()
{
echo "usage: k8s-jprofiler-attach.sh pod_name"
}
k8s_jvm_pod="${1}"
@adiii717
adiii717 / get_instance_ip_for_ecs_service.sh
Created July 3, 2020 07:01
Get EC2 IP address for all tasks running in a particular AWS ECS services against cluster
#!/bin/bash
CLUSTER_NAME="mycluster"
SERVICE_NAME="app-service"
REGION="us-west-2"
echo "[INFO] Fetching tasks list for Cluster: $CLUSTER_NAME and Service: $SERVICE_NAME"
TASKS_ARN=($(aws ecs list-tasks --cluster $CLUSTER_NAME --service $SERVICE_NAME --query 'taskArns[]' --output text))
for task in ${!TASKS_ARN[@]}; do
container_instances=$(aws ecs describe-tasks --cluster $CLUSTER_NAME --tasks ${TASKS_ARN[$task]} --query 'tasks[].containerInstanceArn' --output text)
ec2_instance_id=$(aws ecs describe-container-instances --cluster $CLUSTER_NAME --container-instances $container_instances --region $REGION --query 'containerInstances[*].ec2InstanceId' --output text)
@adiii717
adiii717 / get_instanceid_ecs_task.sh
Created July 3, 2020 02:28
Find instance or instance ID of AWS ECS running TASK or Services
#!/bin/bash
CLUSTER_NAME=default
CONTAINER_INSTANCE="$(aws ecs list-container-instances --cluster $CLUSTER_NAME --query 'containerInstanceArns[]' --output text)"
for container in $CONTAINER_INSTANCE; do
TASK=$(aws ecs list-tasks --cluster $CLUSTER_NAME --container-instance $container --query 'taskArns[]' --output text)
EC2_INSTANCE_ID=$(aws ecs describe-container-instances --cluster prod-bgworker --container-instances $container --region us-west-2 --query 'containerInstances[*].ec2InstanceId' --output text)
echo "**************************************"
echo "ECS TASK having ARN is $TASK"
echo "Running in EC2 instance having ID $EC2_INSTANCE_ID"
done
@adiii717
adiii717 / keybase.md
Created March 27, 2020 03:01
keybaseio

Keybase proof

I hereby claim:

  • I am adiii717 on github.
  • I am adilm717 (https://keybase.io/adilm717) on keybase.
  • I have a public key ASC58eiAyViWB-nuhW5AFP3yLtFcWlcGDu4G4TMawi5kZwo

To claim this, I am signing this object:

@adiii717
adiii717 / Jenkinsfile
Created February 7, 2020 14:13
Terraform simple pipeline with Jenkins
pipeline {
agent any
options { timestamps ()
disableConcurrentBuilds() }
environment {
TERRAFORM_CMD='terraform'
}
stages {
stage('Build') {
steps {